Resources File Reference
The open-source AISIX gateway can load provider credentials, models, caller credentials, and runtime policies from a declarative resources.yaml file. A resources file is a set of etcd documents written down: each entry is a resource's ID plus the document etcd would store for that resource. The gateway reads the file into the rows etcd would return and loads them with the same loader it uses for etcd, so a document loads from a file exactly when it would load from etcd.
Set resources_file in the startup configuration to select the file. To create and load a working configuration, start with the AISIX OSS getting-started guide. Use the CLI Reference to validate changes and Configuration Status to inspect the active or rejected configuration.
File Format
AISIX loads exactly one YAML document from one resources file. The filename is not fixed: resources.yaml is the convention used in these docs, but resources_file can point to any readable file path.
The setting accepts one path only. AISIX does not load a directory, resolve include or import directives, or combine multiple resource files. If you maintain the configuration as separate source fragments, assemble them into one YAML document before validating and loading it.
Apply Resource Examples Safely
AISIX does not merge a resources file with the previously loaded configuration. Each successful load replaces the active resource snapshot. Start with the complete file your gateway currently uses when adding or changing resources; entries and collections omitted from the assembled file disappear from the active configuration.
Code-block titles distinguish complete documents from partial blocks:
- A block titled
resources.yamlis a self-contained document with_format_version. Read the nearby prose to determine whether it is a new-gateway configuration or a reference example. - A title such as
resources.yaml (OIDC provider)identifies a partial block without_format_version. The short parenthetical description names the block's contents; the surrounding prose states whether to add, replace, update, or only inspect it.
When applying a partial block, start with the complete file your gateway currently uses. Update or create each affected collection once, preserve unrelated entries and collections, and do not create a second copy of an existing top-level collection key. An entry that a partial block shows with an id already in your file replaces that entry; keep the id of an entry you edit.
The IDs in these examples are sample values. A partial block that references an entry from another example uses that example's ID, so replace both together when you choose your own.
After assembling any partial blocks, validate the complete file rather than a partial block alone.
The document's top level is a mapping with a mandatory _format_version and the resource collections:
_format_version: "2"
provider_keys:
- id: 0b6f3c1e-2f0a-4c5e-9d55-7d1a8b0c2e11
display_name: openai-prod
provider: openai
api_key: ${OPENAI_API_KEY}
models:
- id: 6efd592d-a73b-473d-8e2c-e9e103692f92
display_name: gpt-4o
provider: openai
model_name: gpt-4o-2024-11-20
provider_key_id: 0b6f3c1e-2f0a-4c5e-9d55-7d1a8b0c2e11
api_keys:
- id: 4a1c9e2b-7d3f-4b6a-8c5e-1f2a3b4c5d6e
display_name: ci-bot
key_hash: ${CI_BOT_KEY_SHA256}
allowed_model_ids: ["6efd592d-a73b-473d-8e2c-e9e103692f92"]
rate_limit_policies:
- id: 48af7a5c-79ff-4813-9a33-f4f5f5ace21f
name: cap-gpt4o
scope: model
scope_ref: 6efd592d-a73b-473d-8e2c-e9e103692f92
window: minute
max_requests: 300
global:
pricing:
- id: 2b7e4f10-6c3a-4d58-9e21-8f0a1b2c3d4e
key: openai/gpt-4o
input_per_1k: 0.0025
output_per_1k: 0.01
This reference documents the following collections:
| Collection | Purpose |
|---|---|
provider_keys | Store upstream provider credentials and connection settings. |
models | Define caller-facing model aliases and dispatch behavior. |
api_keys | Authenticate callers and control their model, MCP tool, and A2A agent access. |
oidc_providers | Trust JWT issuers for caller authentication. |
mcp_auth_settings | Configure OAuth discovery and optional anonymous access for MCP clients. |
claim_mappings | Resolve verified JWT claims to caller API keys. |
guardrails | Screen or transform request and response content. |
guardrail_attachments | Bind a guardrail to the traffic it inspects. |
mcp_servers | Expose MCP servers or OpenAPI operations as tools. |
a2a_agents | Register upstream agents for A2A callers. |
passthrough_routes | Relay matched HTTP traffic to a provider endpoint with gateway auditing and policy. |
cache_policies | Cache matching non-streaming model responses. |
observability_exporters | Export request telemetry to external systems. |
rate_limit_policies | Apply conditional or single-scope request and token limits. |
The file accepts every resource kind the etcd loader reads, so the other kinds the control plane stores, such as mcp_policies, teams, users, and pricing, load from a file the same way. The optional global mapping holds the documents of the shared prefix that the control plane uses for its pricing catalog, which accepts only pricing.
Entries and etcd Keys
A collection name is the kind segment of an etcd key, and an entry is the document stored under that key plus its id. The models entry above is the row etcd holds at /aisix/models/6efd592d-a73b-473d-8e2c-e9e103692f92, and the global.pricing entry is the row at /aisix/global/pricing/2b7e4f10-6c3a-4d58-9e21-8f0a1b2c3d4e. Fields, types, defaults, and references are those of the stored document. A document that loads from etcd loads unchanged from a file, and aisix export writes the documents of an etcd store as a resources file.
Resource IDs
Every entry needs an id:
- The value is a UUID in lowercase hyphenated form, such as
0b6f3c1e-2f0a-4c5e-9d55-7d1a8b0c2e11. References compare IDs as strings, so an uppercase, braced, or URN spelling is not accepted. - An ID is unique within its collection. Two collections can use the same UUID.
- The ID is the resource's identity, not its name. Keep the ID when you edit an entry: a different ID is a different resource, and every reference to the old ID stops matching.
Generate an ID with any UUID tool, for example:
uuidgen | tr '[:upper:]' '[:lower:]'
display_name and name are ordinary document fields. The loader does not require them to be unique, but keep them unique within a collection, because a reference by name resolves to only one entry.
References
A field that references another resource by ID takes that entry's id: provider_key_id, allowed_model_ids, semantic.classifier.model_id, guardrail_id and scope_id on an attachment, scope_ref and the api_key and model condition values on a rate limit policy, resolve.api_key_id, anonymous.api_key_id, anonymous_key_id, and applies_to: "api_key:<id>".
Fields that the documents themselves define by name keep taking names, exactly as on etcd: allowed_models, a routing target's model, ensemble panel[].model and judge.model, a semantic router's embedding_model, route target, and default, applies_to: "model:<name>", jwt_provider, allowed_agents, allowed_routes, mcp_access patterns, mcp_rate_limits keys, and anonymous.servers.
The loader does not check that a referenced ID or name exists. An entry whose reference matches nothing still loads, and the reference resolves to nothing at request time, as it does on etcd.
Caller API Key Hashes
A caller API key document stores key_hash, never the plaintext key. The value is the SHA-256 digest of the plaintext key as 64 lowercase hexadecimal characters, with no prefix: the digest the gateway computes from the key a caller presents. Compute it in the shell and supply it through interpolation:
export CALLER_API_KEY="YOUR_CALLER_API_KEY"
export CALLER_API_KEY_SHA256="$(printf '%s' "$CALLER_API_KEY" | sha256sum | cut -d ' ' -f 1)"
api_keys:
- id: 85b60b85-09dc-40fc-a403-5c7c8beb4e8d
display_name: quickstart-caller
key_hash: ${CALLER_API_KEY_SHA256}
printf '%s' hashes the key without a trailing newline; echo adds one, and that digest matches no request. On macOS, use shasum -a 256 in place of sha256sum. The gateway process needs only the hash variable. The loader does not check the value's format, so an uppercase or otherwise wrong digest loads but authenticates no request.
YAML Structure
_format_version must be exactly the string "2", quoted so YAML parses it as a string. A missing or different version means the file cannot be loaded, and an unquoted 2 gets a dedicated error asking you to quote it.
The gateway applies the following YAML constraints:
- The file must contain exactly one YAML document whose top level is a mapping. Multiple documents separated by
---cannot be loaded. - The top level and every nested mapping must use string keys.
- Each collection, when present, must be a sequence of mappings. An absent or
nullcollection loads as empty. A collection name is one key segment and cannot contain/. - A top-level key that is not a known collection is read as a resource kind, the same as an unknown kind segment in an etcd key. Its entries are reported as unknown kinds and are not served.
- A field the loader does not define is ignored and reported as partially compatible, the same as an unknown field in an etcd document. A misspelled field name therefore does not reject its entry: check the warnings from
aisix validate. - YAML anchors and aliases can reuse values. Merge keys (
<<) are not expanded; the loader ignores<<as an unknown field.
Environment Interpolation
${VAR} references resolve against the gateway process environment only when they appear in string scalars. The value is substituted into the parsed YAML tree, so an environment value can never inject YAML structure, and mapping keys are never interpolated.
This interpolation is for user-defined process variables. For AISIX-defined startup and connection variables, see Environment Variables.
- Partial interpolation is supported:
api_base: https://${UPSTREAM_HOST}/v1. - A variable that is unset or empty means the file cannot be loaded. The error names the variable but never its value.
- Shell-style fallback and required-value expressions, such as
${VAR:-default}and${VAR:?message}, are not supported. $$produces a literal$; a bare$VARwithout braces passes through untouched; an unterminated${or empty${}is an error.- Non-string scalars, including integer, float, boolean, and
nullvalues, are never interpolated.
Loading, Errors, and Reload
The gateway reads the file at startup and on SIGHUP. It does not watch the file for changes, so an edit takes effect only after the next SIGHUP or restart. aisix validate runs the same read and load without starting a listener.
Problems fall into two levels.
The first level is the file itself. The file cannot be turned into rows when it cannot be read, is not valid YAML, does not have a mapping at the top level, has a missing or wrong _format_version, has a collection that is not a sequence of mappings, or has an entry with a missing, malformed, or duplicate id or an unset ${VAR}. Every such problem is reported together, identified by collection and position, for example models[2]. At startup, the gateway exits. On a SIGHUP reload, it keeps serving the configuration it already has, GET /status/config reports out_of_sync with each problem in rejected, and the next SIGHUP reads the file again.
The second level is each entry, checked exactly as an etcd row is. The loader validates the document against the gateway's lenient read schema, which enforces types, required fields, ranges, closed enums, and the shape of each resource, and then decodes it. An entry that fails is rejected: it is dropped and reported in the rejected array of /status/config and in aisix_config_rejected_resources, and the rest of the file serves. A rejected entry does not stop the gateway at startup. On a reload, an entry that stops loading keeps serving its last valid value, and its rejected item carries serving_stale_since.
Format Version 2
From 1.11.0, the resources file format is version 2, and a version-1 file no longer loads: the gateway reports unrecognized _format_version "1" and does not start. Version 1 identified each entry by name, derived its ID from that name, and accepted name forms that the stored documents do not have. Version 2 removes them all:
| Version 1 | Version 2 |
|---|---|
_format_version: "1" | _format_version: "2" |
No id; IDs derived from <kind>/<name> | id: <UUID> on every entry |
provider_key: <name> on a model, passthrough route, or semantic classifier | provider_key_id: <id> |
semantic.classifier.model_ref: <name> | semantic.classifier.model_id: <id> |
key_env: VAR | key_hash: ${VAR_SHA256}, with the digest computed as in Caller API Key Hashes |
anonymous_key: <name> on a passthrough route | anonymous_key_id: <id> |
anonymous.api_key: <name> on mcp_auth_settings | anonymous.api_key_id: <id> |
resolve.api_key: <name> on a claim mapping | resolve.api_key_id: <id> |
guardrail_id and scope_id on an attachment as names | The guardrail's and the target's IDs; a team scope keeps the team ID |
scope_ref and api_key or model condition values on a rate limit policy as names | The target entry's ID |
applies_to: "api_key:<derived ID>" | applies_to: "api_key:<id>" with the caller API key's id |
secret on a provider key | api_key |
display_name on an MCP server, A2A agent, or passthrough route | name |
A semantic guardrail with deny_examples or allow_examples but no matching threshold, which loaded at 0.75 | deny_threshold or allow_threshold set explicitly, measured as described in Calibrate Semantic Screening Guardrails |
The following file is the same configuration in both versions. Version 1:
_format_version: "1"
provider_keys:
- display_name: openai-prod
provider: openai
api_key: ${OPENAI_API_KEY}
models:
- display_name: gpt-4o
provider: openai
model_name: gpt-4o
provider_key: openai-prod
api_keys:
- display_name: ci-bot
key_env: CI_BOT_KEY
allowed_models: ["gpt-4o"]
Version 2:
_format_version: "2"
provider_keys:
- id: 0b6f3c1e-2f0a-4c5e-9d55-7d1a8b0c2e11
display_name: openai-prod
provider: openai
api_key: ${OPENAI_API_KEY}
models:
- id: 6efd592d-a73b-473d-8e2c-e9e103692f92
display_name: gpt-4o
provider: openai
model_name: gpt-4o
provider_key_id: 0b6f3c1e-2f0a-4c5e-9d55-7d1a8b0c2e11
api_keys:
- id: 4a1c9e2b-7d3f-4b6a-8c5e-1f2a3b4c5d6e
display_name: ci-bot
key_hash: ${CI_BOT_KEY_SHA256}
allowed_models: ["gpt-4o"]
Loading behavior changes with the format:
- An invalid entry is rejected on its own instead of rejecting the whole file, as described in Loading, Errors, and Reload.
- An unknown field is ignored and reported instead of rejecting the file, and an unknown top-level key is reported as an unknown kind.
- The checks that only the file performed are gone: unique names, references that must name an entry in the file, two caller API keys with the same credential, a unique
jwt_providerandjwt_subjectpair, and the strict write-schema checks that the read schema does not repeat.
Provider Keys
A provider key stores an upstream credential together with the connection settings used for that provider. Models and passthrough routes reference a provider key by its id through provider_key_id.
| Field | Type | Required | Description |
|---|---|---|---|
display_name | string | yes | Name of the provider key. |
api_key | string | conditional | The upstream provider's API key. Supply it as ${VAR}. The gateway does not read the former spelling secret: an entry that still uses it has no api_key and is rejected. Some provider credentials contain more than one field. For these providers, supply a JSON credential document through one environment variable. See the credential shapes for AWS Bedrock and Azure OpenAI with Entra ID. |
provider | string | no | Upstream provider identifier, such as openai or deepseek. An open string used for provider-specific dispatch. Default: empty. |
adapter | enum | no | Upstream protocol family used when no provider-specific dispatch applies: openai, anthropic, bedrock, vertex, or azure-openai. See Adapter Protocol Families. |
api_base | string | no | Override base URL for the upstream provider. Required in practice for private OpenAI-compatible endpoints. Supports partial interpolation, such as https://${UPSTREAM_HOST}/v1. |
api_version | string | no | Azure OpenAI REST API version for this key's requests: a dated version such as 2024-10-21 or 2025-04-01-preview, or v1 (preview and latest are aliases of v1). Applies only when adapter is azure-openai; other adapters ignore it. Default: each operation's own dated version. See Set the API Version. |
apis | object | no | Native API surfaces this endpoint serves, and where. Present with a surface omitted means that surface is not served natively and the gateway translates to chat completions instead. Omit the block entirely to resolve every surface from provider and adapter, which is the default. The bedrock, vertex, and azure-openai adapters do not accept it. See Declare the API Surfaces. |
apis.responses | object | no | The endpoint serves /v1/responses natively. Authoritative once apis is present: leaving it out is how you state the endpoint has no such route. The surface is unavailable with bedrock, vertex, and azure-openai adapters, which use the bridge. Codex Lite-mode requests add a provider-dependent exception; see Lite-Mode Tool Requests. |
apis.messages | object | no | The endpoint serves /v1/messages and /v1/messages/count_tokens natively. Additive — a key whose adapter is anthropic serves them either way; listing the surface adds them to a key whose adapter is something else. |
apis.<surface>.base | string | no | Base URL for that surface, when the endpoint serves it on a different path from api_base. Same shape rules as api_base. Omit it when the surface is served at api_base. |
strip_headers | array of strings | no | Inbound headers removed before forwarding on inject-mode passthrough routes that use this key, on top of the credential slots those routes always remove. Default: authorization, cookie, set-cookie, x-api-key. Entries are trimmed, lowercased, and deduplicated. An explicit [] clears this list and releases no credential slot: inject mode always strips authorization, proxy-authorization, x-api-key, api-key, x-goog-api-key, cookie, x-amz-security-token, x-amz-date, and x-amz-content-sha256. Not an absolute prohibition: the route's own forward_client_headers overrides it, a credential slot needs a pattern that names it exactly, and for a name that is neither a credential nor a trace-context header a glob such as x-* is enough to put the header back on the wire. |
tls | object | no | Per-endpoint TLS settings for HTTP provider dispatch. Amazon Bedrock and Realtime dispatch ignore this block; use the applicable deployment-wide upstream.tls setting instead. |
tls.ca_cert | string | no | PEM-encoded certificate authority certificates trusted as additional issuers for this HTTP endpoint. A bundle can contain several certificates. See TLS and mTLS. |
tls.verify | boolean | no | Whether to verify this HTTP endpoint's certificate. Default: true. Setting it to false accepts any certificate and is for test environments only. |
resolve_addresses | array | no | IP addresses the gateway connects to for this key's api_base host, instead of resolving that host through DNS. Each entry is an IPv4 or IPv6 address literal, without a port and without brackets; they are tried in the order given. Host, the TLS server name, the certificate check, the scheme, and the port keep coming from api_base. Not honored for Amazon Bedrock, for /v1/realtime, or when the gateway reaches its upstreams through a forward proxy. See Pin the Endpoint Addresses. |
telemetry_tags | object | no | Attribution tags emitted with requests routed through this key. |
telemetry_tags.kind | enum | no | Attribution category: catalog or byo. |
telemetry_tags.featured | boolean | no | Whether the provider key is featured. Default: false. |
telemetry_tags.branded_provider | string | no | Branded provider slug for catalog entries. |
telemetry_tags.pk_label | string | no | Operator-defined provider-key label, such as production. |
telemetry_tags.byo_label | string | no | Operator-defined bring-your-own label, such as a team name. |
request | object | no | Request-shape overrides applied before dispatch. |
request.param_renames | map of string to string | no | Top-level request body keys named on the left are renamed to the key on the right before dispatch. |
request.param_constraints | object | no | Clamp bounds for temperature in chat completion bodies. |
request.param_constraints.temperature_min | number | no | Minimum accepted temperature. When omitted, no lower bound is applied. |
request.param_constraints.temperature_max | number | no | Maximum accepted temperature. When omitted, no upper bound is applied. |
request.default_headers | map of string to string | no | Headers added to the outbound request. Because the loader resolves ${...} from the environment first, write request-context references as $${...}; for example, $${request.api_key.team_id} loads as ${request.api_key.team_id} for per-request rendering. A header whose variables have no value is dropped rather than sent empty. These headers outrank a header relayed by forward_client_headers for every name except a credential slot, where the forwarded value wins; and they cannot replace a name the gateway sets itself. host, the hop-by-hop headers, and x-aisix-* are dropped whatever the source, and the AISIX Cloud Admin API rejects those same names when you save the provider key. A credential name is accepted on both paths, and reaches the upstream only in a slot the provider bridge left empty. This half of the request block does not apply on /v1/realtime, where only forward_client_headers takes effect. See Upstream Request Headers. |
request.forward_client_headers | array of strings | no | Inbound client headers relayed to the upstream, as exact names or single-* globs such as x-trace-*, matched case-insensitively. Empty (the default) forwards nothing, with one exception: on /v1/messages and /v1/messages/count_tokens sent to Anthropic or an Anthropic-compatible endpoint, the caller's anthropic-beta is forwarded as sent, every value of it, without being listed here. An anthropic-beta that default_headers sets on the request applies in its place. Listing anthropic-beta here, by name or by a pattern that matches it such as * or anthropic-*, still sends only the caller's value, under the rules for listed headers, so only its first value is forwarded. A credential slot and the trace-context headers traceparent / tracestate are relayed only when a pattern names them exactly; a glob never matches them, x-amz-* included. A relayed credential takes the slot this key would otherwise inject into, never joining it. host, hop-by-hop headers, x-aisix-*, the body and negotiation headers the gateway re-serializes (content-type, content-length, accept, accept-encoding, content-encoding, expect), set-cookie, anthropic-version, and x-stainless-* are never relayed. On a Bedrock-shaped key the SigV4-signed names (authorization, x-amz-date, x-amz-content-sha256, x-amz-security-token, x-amz-target, x-amzn-bedrock-accept) are dropped rather than delivered. To Claude on Amazon Bedrock or Vertex AI, anthropic-beta is filtered to the betas that platform accepts, and Bedrock receives it in the body's anthropic_beta rather than as a header; on /v1/messages the caller's betas reach the platform even when no pattern names the header. See Claude Beta Values. On /v1/realtime the handshake slots that face owns (sec-websocket-accept, sec-websocket-extensions, sec-websocket-key, sec-websocket-protocol, sec-websocket-version) are refused even when a pattern names one in full. See Upstream Request Headers. |
request.default_body_fields | map of string to JSON value | no | Top-level body fields added to the outbound request when the caller did not set them. |
response | object | no | Response-shape overrides applied by provider bridges that support them. |
response.stream_done_marker | enum | no | Whether the upstream SSE stream is expected to emit data: [DONE]: required, optional, or none. Omitted accepts either. |
response.content_list_to_string | boolean | no | When true, flattens a messages[*].content array of text blocks into a single string before dispatch. Default: false. |
response.reasoning_field | string | no | Path used to lift reasoning content from the provider response, such as delta.reasoning_content. |
response.error_envelope | string | no | Stored error-envelope preference kept for compatibility with control-plane configuration; the proxy does not currently apply it. |
The following example brings those settings together. It defines one OpenAI provider key and one private OpenAI-compatible endpoint. The private endpoint declares the openai adapter, builds its base URL from the environment, and trusts an additional certificate authority.
_format_version: "2"
provider_keys:
- id: 83eba07c-0ad3-4b81-b760-247f2d978e95
display_name: openai-prod
provider: openai
api_key: ${OPENAI_API_KEY}
- id: dd566077-11b5-4131-84b7-7eeeef830acb
display_name: internal-vllm
provider: internal-vllm
adapter: openai
api_base: https://${UPSTREAM_HOST}/v1
api_key: ${INTERNAL_LLM_KEY}
# Only needed when this endpoint's certificate is signed by a
# private or enterprise certificate authority.
tls:
ca_cert: |
-----BEGIN CERTIFICATE-----
MIIB...
-----END CERTIFICATE-----
Models
A model entry defines a caller-facing alias. Direct, embedding, routing, ensemble, and semantic aliases all appear in /v1/models; wildcard patterns do not (see Model Aliases). Every entry uses exactly one dispatch shape: direct, routing, ensemble, or semantic. An entry that mixes shapes is rejected.
The following fields for timeouts, retries, access, cost, and inline limits are shared across model shapes, but each is accepted only on the kinds where the gateway resolves it — the Applies to column lists them. A field set on a kind that does not resolve it is ignored and reported as partially compatible:
| Field | Type | Applies to | Description |
|---|---|---|---|
display_name | string | all | The caller-facing alias. Required on every shape. Keep it unique within models, because name references resolve to one entry. |
timeout | integer (ms) | direct, embedding, routing, semantic | End-to-end deadline for non-streaming upstream calls. On a routing model or semantic router this is the group/router-level slot applied to every target that does not set its own; absent falls back through that slot, then the deployment-wide upstream.timeout_ms default (6000000 ms = 6000 s). 0 disables it. Ignored on ensemble — its per-call deadline is ensemble.timeout_ms. |
stream_timeout | integer (ms) | direct, embedding, routing, semantic | Maximum gap between upstream streaming chunks. 0 or absent falls back to the group/router stream_timeout, then to timeout, then to the deployment defaults. Ignored on ensemble. |
retries | integer | direct, embedding, semantic | Retry attempts against this model after a retryable upstream failure. On a semantic router this is the router-level slot. 0 disables same-target retries. A routing model does not take a top-level retries — its group slot is routing.retries (below); a routing target's own retries overrides that. Ignored on ensemble. |
rate_limit | object | all | Per-model request, token, and concurrency limits, enforced on the entry the caller addressed. See below. |
allowed_cidrs | array of strings | all | Client IP allowlist in CIDR notation (IPv4 and IPv6). Empty or absent allows all clients. With a restriction configured, a missing or malformed source IP is denied. |
cost | object | direct, embedding | Per-token price metadata for least_cost ranking: input_per_1k and output_per_1k, both prices per 1,000 tokens and both required when the block is present. Set it on the direct/embedding models a group dispatches to, not on the group. |
Within rate_limit, each field is optional and unlimited when absent:
| Field | Limit |
|---|---|
rate_limit.rps | Requests per fixed 1-second window. |
rate_limit.rpm | Requests per 60-second window. |
rate_limit.rph | Requests per 3,600-second window. |
rate_limit.rpd | Requests per 86,400-second window. |
rate_limit.tpm | Tokens per 60-second window. |
rate_limit.tpd | Tokens per 86,400-second window. |
rate_limit.concurrency | Maximum in-flight requests. This is a semaphore, not a window. |
rate_limit.window_type | fixed (default) or sliding. How rpm, rph, rpd, tpm, and tpd count; rps and concurrency are not affected. See Choose a Window Type. Requires gateway 1.10.0 or later. |
With the default fixed, windows are aligned to the UTC clock and reset as a whole at each boundary: the top of the second, minute, or hour, and 00:00 UTC for rpd and tpd.
Direct Models
The direct shape names one upstream model behind one provider key:
| Field | Type | Required | Description |
|---|---|---|---|
provider | string | yes | Vendor identity such as openai or anthropic. Starts with a lowercase letter or digit; ., _, and - are allowed after the first character; 1–64 characters. |
model_name | string | yes | Upstream model identifier sent in provider requests, such as gpt-4o-2024-11-20. |
provider_key_id | string | yes | id of the provider_keys entry the model sends its requests with. |
embedding | object | no | Marks the model as embedding-capable: dimensions (required, vector dimensionality) and normalize (default true, whether the endpoint already returns L2-normalized vectors). The model can then serve /v1/embeddings and back a semantic router. |
background_model_check | object | no | Background health checks. See Health Checks. Sub-fields enabled, interval_seconds (min 5), timeout_seconds, prompt, max_tokens, and stale_after_seconds are required when the block is present; ignore_statuses (array of status codes) is optional. |
cooldown | object | no | Request-path cooldown after retryable upstream failures. Cooldown is opt-in: omit the block, or leave enabled unset, and request-path failures never take the model out of rotation. See below. |
auto_prompt_caching | object | no | Automatic Anthropic prompt-cache marker injection. Supported only for direct models whose provider is anthropic. enabled is required when the object is present; ttl is 5m (default) or 1h. See Anthropic Prompt Caching. |
effort_mapping | object of strings or null | no | Direct-model request-effort rewrites. Each key is a caller value and each value is the upstream value, or null to remove the effort. The key "" matches a request that sets no effort and "*" matches any other value without an entry of its own. The lookup runs once after final target selection — exact key first, then "*"; absent or empty disables it. See Reasoning Effort Mapping. |
The optional cooldown object accepts these settings. Only enabled: true turns cooldown on; the remaining settings are the parameters it uses once it is on, and setting one of them on its own does not enable the feature:
| Field | Default | Behavior |
|---|---|---|
cooldown.enabled | false | Enables request-path cooldown tracking. A model that omits the cooldown block, or leaves this field unset, stays in rotation regardless of upstream failures. |
cooldown.default_seconds | 30 | Sets the cooldown TTL when no usable Retry-After header exists. 0 switches cooldown off for the model entirely, including the Retry-After path, rather than producing a zero-length cooldown. |
cooldown.max_seconds | 600 | Caps a cooldown derived from Retry-After. |
cooldown.honor_retry_after | true | Uses a valid Retry-After value when available. |
cooldown.trigger_statuses | [401, 408, 429, 500, 502, 503, 504] | Status codes that trigger cooldown. Setting the field replaces the complete default list. |
cooldown.trigger_on_timeout | true | Triggers cooldown after an upstream timeout. |
cooldown.trigger_on_transport | true | Triggers cooldown after an upstream transport failure, or an in-band error that carries no status. On /v1/realtime, a refused handshake has a status and takes trigger_statuses, and a dial past upstream.connect_timeout_ms takes trigger_on_timeout. |
Embedding settings, background model checks, and cooldown are accepted only on direct models; an entry of another shape that sets one is rejected. Automatic prompt caching applies only to direct models whose provider is Anthropic.
Routing Models
A routing entry selects one target per request and dispatches through that target model's upstream configuration:
| Field | Type | Required | Description |
|---|---|---|---|
routing.targets | array | yes | Ordered target set with at least one entry. Per-request routing-tag and allowed_cidrs filters narrow this set before the configured strategy orders the survivors. |
routing.targets[].model | string | yes | Name of an existing direct model that can receive routed traffic. |
routing.targets[].weight | integer | no | Default: 1. Sets the rotation share under round_robin, the share of the hash ring under consistent_hash, and the denominator max(weight, 1) of the least_busy score. At runtime, 0 is treated as 1. failover, least_cost, and least_latency accept but ignore it. |
routing.targets[].priority | integer | no | Default: 0. Splits eligible targets into tiers, with higher values preferred. A lower tier is tried after no higher-tier target remains available; use -1 for a backup tier. |
routing.targets[].tags | array of strings | no | Tags used for per-request eligibility. If no target has tags, tag filtering is inactive and all targets remain eligible. Otherwise, a request carrying tags keeps targets with at least one match, then falls back to targets tagged default if none match. An untagged request prefers default targets and otherwise leaves all targets eligible. |
routing.strategy | enum | no | round_robin (smooth weighted round-robin), consistent_hash, failover (default), least_cost, least_latency, or least_busy. Positional strategies pick a starting target per priority tier and walk forward on failure; metric strategies rank targets best-first within each tier. |
routing.retries | integer | no | Default retry attempts on each target before failing over. A target model's retries overrides it. If neither is set, AISIX moves to the next eligible target without retrying and applies the deployment-wide default only to the last target. |
routing.max_fallbacks | integer | no | Maximum later targets attempted after the initial target fails. Default: all later targets. 0 disables failover. |
routing.retry_on_429 | boolean | no | Whether an upstream 429 participates in retries and failover. Default false. |
routing.fallback_on_statuses | array of integers | no | Additional 4xx status codes treated as retryable, for providers that use them for transient conditions, such as [408, 409]. 5xx codes are already retryable. |
routing.when_all_unavailable | enum | no | fail (default): return 503 when health and cooldown state rule out every target. try_anyway: attempt every target in declaration order regardless. |
routing.hash_on | array | no | consistent_hash only: the ordered hash-key source chain, first non-empty value winning. Each entry is {type, name?} with type one of header, cookie (both named by name), api_key, or client_ip. Default: the x-aisix-routing-key header, then the caller's API key. |
See Multi-Target Routing and Failover for configuration, routing behavior, and a runnable failure test.
Ensemble Models
An ensemble entry fans each request out to every panel member concurrently, then has a judge model synthesize one answer:
| Field | Type | Required | Description |
|---|---|---|---|
ensemble.panel | array | yes | Panel members, minimum one. panel[].model names a direct model; optional panel[].temperature and panel[].seed override sampling per member; panel[].weight is accepted and currently ignored. |
ensemble.judge | object | yes | judge.model names the direct model that performs synthesis; optional judge.synthesis_prompt overrides the built-in synthesis prompt. |
ensemble.min_responses | integer | no | Minimum successful panel responses required before synthesis. Default: the smaller of 2 and the panel size. Clamped to the panel size, floored at 1. |
ensemble.timeout_ms | integer (ms) | no | Per-call deadline for each panel member and the judge call. 0 or absent disables it. |
See Ensemble Models for behavior and response shape.
Semantic Routers
A semantic entry embeds the request's latest user text, scores it against each route's example embeddings, and dispatches to the best route above the threshold. When no route clears the threshold, it dispatches to default.
| Field | Type | Required | Description |
|---|---|---|---|
semantic.embedding_model | string | conditional | Name of an embedding-capable direct model (one carrying an embedding block). Required unless semantic.classifier is set. |
semantic.routes | array | yes | Routes, minimum one. Each route requires name (recorded in the access log's semantic_route field, and surfaced in the x-aisix-route response header when proxy.expose_debug_headers is true), target (the name of a direct model or a model group), and examples (at least one example utterance; embedded on the first request that needs them and cached); optional description (documentation only) and threshold (overrides match.threshold for this route). |
semantic.default | string | yes | Direct model or model group that receives requests matching no route. |
semantic.match | object | conditional | Required unless semantic.classifier is set. Shared matching parameters: threshold (required, 0.0–1.0, higher is stricter), distance_metric (cosine, the only supported value), and aggregation (max, the only supported value; a route scores by its best-matching example). |
semantic.embedding_timeout_ms | integer (ms) | no | Deadline for the embedding call. 0 or absent disables it. |
semantic.on_embedding_failure | enum or object | no | What to do when the embedding call fails: default (route to the default model; this is the default behavior), fail (reject with 503), or { target: "<alias>" } (route to a specific direct model or model group). |
semantic.classifier | object | no | Selects the route with a TypeSafe jev decision model instead of embeddings. When set, the router must not set embedding_model, embedding_timeout_ms, on_embedding_failure, or match, and its routes take a required description and no examples or threshold. See Semantic Routing with TypeSafe Jev. |
semantic.classifier.model_id | string | no | id of the direct model the classifier calls for its decisions, on a typesafe provider key. When set, the classifier's provider_key_id and model are not read. See Configure a Jev Router. |
semantic.session_affinity | object | no | Keeps a session on the route its first matched request took: enabled (default false) and ttl_seconds (default 3600, 60–604800), how long a pin lasts after the last request that used it. Absent, every request is classified. See Pin a Session to Its Route. |
See Semantic Routing for behavior and tuning.
The complete example below shows how the four model shapes relate. The three direct models are reusable targets; the remaining entries compose them into a session-pinned router, an ensemble, and a semantic router.
_format_version: "2"
provider_keys:
- id: 06475d5a-8aea-457e-856d-55d34d7cafbb
display_name: openai-main
provider: openai
api_key: ${OPENAI_API_KEY}
models:
- id: ccd6c189-04bb-44a9-bd0a-1545a04504e9
display_name: gpt-4o
provider: openai
model_name: gpt-4o
provider_key_id: 06475d5a-8aea-457e-856d-55d34d7cafbb
timeout: 30000
rate_limit:
rpm: 100
tpm: 100000
cost:
input_per_1k: 0.0025
output_per_1k: 0.01
- id: 9f46bd07-eaae-4c3e-a1ae-61b420c32f10
display_name: gpt-4o-mini
provider: openai
model_name: gpt-4o-mini
provider_key_id: 06475d5a-8aea-457e-856d-55d34d7cafbb
- id: 43d4a2fa-448c-4cd1-844d-6fb18a240f89
display_name: text-embed
provider: openai
model_name: text-embedding-3-small
provider_key_id: 06475d5a-8aea-457e-856d-55d34d7cafbb
embedding:
dimensions: 1536
- id: 5183df2e-1711-4a45-915f-2671dcd3fb34
display_name: balanced
routing:
strategy: consistent_hash
targets:
- model: gpt-4o
weight: 90
- model: gpt-4o-mini
weight: 10
retries: 1
retry_on_429: true
- id: 737e8e4e-8846-4bb3-89da-f788076a7e47
display_name: council
ensemble:
panel:
- model: gpt-4o
- model: gpt-4o-mini
temperature: 0.2
judge:
model: gpt-4o
min_responses: 2
timeout_ms: 45000
- id: f090a30f-1528-4a66-972a-4890f95ec274
display_name: smart-router
semantic:
embedding_model: text-embed
routes:
- name: coding
target: gpt-4o
examples:
- "Write a Python function that parses CSV"
- "Debug this stack trace"
threshold: 0.8
default: gpt-4o-mini
match:
threshold: 0.75
on_embedding_failure: default
Caller API Keys
A caller API key entry authenticates the applications that call the gateway. The file never holds the plaintext key: the entry carries its SHA-256 digest in key_hash, as described in Caller API Key Hashes.
| Field | Type | Required | Description |
|---|---|---|---|
display_name | string | no | Name of the caller API key. |
key_hash | string | yes | SHA-256 digest of the plaintext key, as 64 lowercase hexadecimal characters. Supply it as ${VAR}. |
allowed_models | array of strings | no | Models this key may use. Entries are single-* globs: "*" grants every model, "team-a/*" grants matching names, and an entry without * matches the model with that display_name. Read only when allowed_model_ids is absent. Omitting both fields, or giving an empty array, grants the key no model at all — model access is always granted explicitly. |
allowed_model_ids | array of strings | no | Models this key may use, by id. When present, including as an empty array, it is authoritative and allowed_models is not read. |
allow_all_models | boolean | no | Grants every model defined in the file, of every kind, including models added later. When true, allowed_model_ids and allowed_models are not read. It covers models only: allowed_agents, allowed_routes, and mcp_access still govern agents, passthrough routes, and MCP tools. Default false. |
rate_limit | object | no | Per-key limits with the same sub-fields as a model's rate_limit: rps, rpm, rph, rpd, tpm, tpd, concurrency. |
mcp_rate_limits | object | no | Per-MCP-server request and concurrency limits for this key. Keys are registered MCP server names; see below. |
mcp_access | object | no | MCP tools this key may call: an allow list (required) and an optional deny list of <server>__<tool> names, matched as single-* globs — "github__*" covers every tool on one server. Omitting the block means no MCP tool access here; see below. |
allowed_agents | array of strings | no | A2A agents this key may reach, by registered name, matched as single-* globs. Omitted, null, or empty means no A2A agent access. |
allowed_routes | array of strings | no | Passthrough routes this key may use, by route name, matched as single-* globs. Omitted, null, or empty means no passthrough route access. |
jwt_subject | string | no | External identity selected from a verified JWT. Set it together with jwt_provider. |
jwt_provider | string | no | Name of the oidc_providers entry allowed to assert jwt_subject. Required when jwt_subject is set. |
expires_at | string | no | RFC 3339 timestamp after which the key stops authenticating with 401. Omitted means the key never expires. A malformed timestamp rejects the entry at load rather than silently never expiring. |
disabled | boolean | no | Administratively disable the key: requests are rejected with 401 until it is enabled again. Default false. |
team_id | string | no | Team attribution, matched verbatim by rate_limit_policies with scope: team. |
user_id | string | no | Owning member attribution, matched verbatim by member-scope policies. |
user_name | string | no | Readable owner name for telemetry labels only. |
MCP Tool Access and Limits
Grant MCP tool access with mcp_access. In AISIX Enterprise and AISIX Cloud, the block is one layer of a three-layer ACL, intersected with the environment and team access policies stored as mcp_policies. A resources file loads mcp_policies entries the same way; without them, the block is the key's only layer, and a key without one reaches no MCP tool. allow is required — send ["*"] for a key that should narrow nothing and rely on deny alone, or [] for one that may call nothing.
Use mcp_rate_limits to give one caller key a separate limit for each registered MCP server. Each server entry supports the following fields:
| Field | Limit |
|---|---|
rps | Requests per second. |
rpm | Requests per minute. |
rph | Requests per hour. |
rpd | Requests per day. |
concurrency | Maximum in-flight tool calls. |
window_type | fixed (default) or sliding. How rpm, rph, and rpd count. Requires gateway 1.10.0 or later. |
These limits apply to tools/call requests alongside the key's general rate_limit; initialization and tool-list requests are not counted.
This example gives one caller access to a model and every tool exposed by the github MCP server. The general rate_limit applies alongside the tool limits, while mcp_rate_limits.github adds a tighter limit for that server's tool calls.
_format_version: "2"
provider_keys:
- id: 06475d5a-8aea-457e-856d-55d34d7cafbb
display_name: openai-main
provider: openai
api_key: ${OPENAI_API_KEY}
models:
- id: ccd6c189-04bb-44a9-bd0a-1545a04504e9
display_name: gpt-4o
provider: openai
model_name: gpt-4o
provider_key_id: 06475d5a-8aea-457e-856d-55d34d7cafbb
mcp_servers:
- id: 631940a7-bdb5-4d67-9ffd-74798b91df52
name: github
type: mcp
url: https://api.example.com/mcp
api_keys:
# MY_APP_KEY_SHA256 holds the SHA-256 digest of the caller key;
# the plaintext never appears in the file.
- id: 961a73a4-00c3-4379-a4af-99a8bd9dd7ec
display_name: my-app
key_hash: ${MY_APP_KEY_SHA256}
allowed_models: ["gpt-4o"]
mcp_access:
allow: ["github__*"]
rate_limit:
rpm: 60
concurrency: 5
mcp_rate_limits:
github:
rpm: 30
concurrency: 2
OIDC Providers
An oidc_providers entry defines how the gateway verifies JWT tokens from an external token issuer. A verified identity maps to the caller API key whose jwt_provider and jwt_subject fields match the provider and token.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Provider name. Caller API keys and claim mappings reference the provider by this name through jwt_provider. |
issuer | string | yes* | Expected JWT iss claim, compared exactly. A configured issuer must be distinct among enabled providers. Required for JWKS verification and optional when hmac_secret is set; an issuer-less shared-secret provider does not check iss. |
audiences | array of strings | yes* | Accepted JWT aud values. JWKS verification requires at least one, and the token must contain a match. With hmac_secret, omit the field or use an empty list to skip audience validation. |
jwks_uri | string | no | JWKS endpoint used to fetch signing keys. When omitted, AISIX resolves it from <issuer>/.well-known/openid-configuration. Must be absent when hmac_secret is set. |
hmac_secret | string | no | Shared secret for HMAC-signed tokens. Setting it switches the entry to HMAC verification: tokens are accepted only under HS256, HS384, or HS512, no signing keys are fetched, and issuer and audiences become optional. Its UTF-8 bytes are the HMAC key as-is — nothing is base64-decoded or derived — and it must be at least 32 bytes long. Supply it as ${VAR}. Default: unset, meaning JWKS verification. |
identity_claim | string | no | Claim whose string value selects a caller API key's jwt_subject. The whole string is first read as one claim name, then dots traverse nested objects. Default: sub. |
required_scopes | array of strings | no | Scopes that must all appear in the token's scope claim. The claim may be a space-delimited string or an array. Default: no required scopes. |
bound_claims | object | no | Additional claim requirements that must all pass. Each key is first read as one claim name, then dots traverse nested claims. Each value is a string or a nonempty array; a string claim must equal an accepted value, and an array claim must contain one. |
tag_claims | object | no | Cost attribution tags read from the verified token on each request, as tag key to claim path. Per tag key, a value read this way takes precedence over the caller API key, its team, and its member. Keys match ^[a-z][a-z0-9_]{0,62}$, paths are non-empty, and at most 32 entries are allowed. See How a Claim Becomes a Tag Value. |
leeway_secs | integer | no | Clock-skew allowance from 0 to 300 seconds for exp and nbf. Default: 0. |
login | object | no | OAuth client the gateway signs users in with, for MCP clients configured with only a URL: client_id (required), client_secret (supply it as ${VAR}), and scopes. Needs an issuer and no hmac_secret, and only one enabled entry can have it. See Interactive MCP Sign-In. |
enabled | boolean | no | Whether the provider participates in authentication. Default: true. |
Keep credential-like query parameters, such as access_token or client_secret, out of issuer and jwks_uri.
User information in these URLs (user:password@) is accepted and used as written, and gateway logs can include the issuer. Prefer credential-free HTTPS endpoints or network-level access controls.
An entry without hmac_secret is verified against a JWKS: it requires issuer and audiences, accepts asymmetric JWT signing algorithms, and rejects HMAC-signed tokens. See JWT Authentication for supported algorithms, request behavior, and key rotation.
AISIX rejects an entry that sets both jwks_uri and hmac_secret, one without hmac_secret that lacks an issuer or at least one audience, and an hmac_secret shorter than 32 bytes.
The following configuration trusts the corp-keycloak issuer and maps the JWT subject agent-billing-01 to the billing-agent caller entry.
Every caller entry still requires key_hash, even when JWT authentication is enabled. Set BILLING_AGENT_KEY_SHA256 in the gateway process environment before loading this example. The empty allowed_models list denies model access; add model aliases when this identity should call model endpoints.
_format_version: "2"
oidc_providers:
- id: f1aac41c-d83d-41ef-b2d3-abae0b774fbe
name: corp-keycloak
issuer: https://sso.example.com/realms/agents
audiences: ["aisix-gateway"]
required_scopes: ["ai.access"]
bound_claims:
department: ai-lab
api_keys:
- id: 733cfd25-85c2-45cb-a502-734de9b9bd97
display_name: billing-agent
key_hash: ${BILLING_AGENT_KEY_SHA256}
allowed_models: []
jwt_subject: agent-billing-01
jwt_provider: corp-keycloak
This entry instead trusts an issuer that signs with a shared secret. JWT_HMAC_SECRET holds the secret in the gateway process environment, so the plaintext stays out of the file. The entry pins no issuer and no audiences, so those claims are not checked; add them when the issuer sets them and you want them enforced.
oidc_providers:
- id: 7a6ec1e8-3a10-4c31-8463-19f6c122c46f
name: partner-hmac
hmac_secret: ${JWT_HMAC_SECRET}
required_scopes: ["ai.access"]
Give each issuer-less shared-secret entry its own secret. Two that share one secret both verify the same token, so whichever sorts first by name always wins.
MCP Authentication Settings
The optional mcp_auth_settings collection controls how clients authenticate at /mcp and /mcp/{server}. It is a per-environment singleton, so keep at most one entry. The loader accepts a second entry, but the gateway then keeps both OAuth discovery and anonymous access off until only one entry remains, rather than choosing between them. The entry carries two independent settings: resource_url enables OAuth discovery when an OIDC provider is also enabled, while anonymous opens selected MCP entries to callers from trusted networks that present no credential.
| Field | Type | Required | Description |
|---|---|---|---|
resource_url | string | no | Canonical public URL of the gateway's /mcp endpoint. OAuth discovery activates when the value parses as an absolute http or https URL, has no query or fragment, and its path ends with /mcp. Use a percent-encoded path without empty, . or .. segments so a front gateway does not normalize it differently from the resource URL AISIX publishes. A prefix before /mcp, as in /team-a/mcp, is for a gateway in front of AISIX that strips it before forwarding; see Run Behind a Path-Prefix Gateway. The URL is published as written on an unauthenticated endpoint, user information included, so do not put credentials in it. The gateway does not compare it with a token's aud; see OAuth Sign-In for what audiences must list. |
anonymous | object | no | Anonymous-access settings. When omitted, every MCP request must present a valid gateway API key or trusted OAuth access token. |
anonymous.enabled | boolean | no | Whether anonymous access is active. Default: true. Set it to false to retain the settings while closing anonymous access. |
anonymous.api_key_id | string | yes* | id of the api_keys entry that anonymous requests run as. The key's MCP grant, limits, guardrails, and usage attribution apply normally. Required when anonymous is set. |
anonymous.source_cidrs | array of strings | yes* | Non-empty list of client source CIDRs allowed to enter anonymously. AISIX matches the resolved client address from its real-IP configuration, not an untrusted caller-supplied header. Required when anonymous is set. |
anonymous.servers | array of strings | yes* | Non-empty list of MCP server names anonymous callers may reach. The list is also a ceiling on the principal's access through the aggregated /mcp endpoint. Required when anonymous is set. |
anonymous.aggregate_entry | boolean | no | Whether the aggregated /mcp endpoint also serves anonymous callers. Default: false. Enabling it suppresses the 401 that otherwise starts OAuth discovery for a client without credentials. |
This example enables OAuth discovery and opens the docs server anonymously to one trusted network. It names the anonymous-mcp key by its id in anonymous.api_key_id:
_format_version: "2"
oidc_providers:
- id: 5a46d289-7c60-48f0-8a3b-4c32045efdea
name: corp-sso
issuer: https://sso.example.com/realms/agents
audiences:
- https://gateway.example.com/mcp
required_scopes:
- mcp:tools
api_keys:
- id: 4e651924-0b3e-4bcc-a782-0c4ed895171e
display_name: anonymous-mcp
key_hash: ${ANONYMOUS_MCP_KEY_SHA256}
allowed_models: []
mcp_access:
allow:
- docs__*
mcp_servers:
- id: 4a9f320a-6f52-48bc-b137-7a43fa4d86e1
name: docs
type: mcp
url: https://docs.example.com/mcp
mcp_auth_settings:
- id: 294d3ba9-93df-4477-b637-18c8a834cb0b
resource_url: https://gateway.example.com/mcp
anonymous:
api_key_id: 4e651924-0b3e-4bcc-a782-0c4ed895171e
source_cidrs:
- 10.0.0.0/8
servers:
- docs
aggregate_entry: false
Set ANONYMOUS_MCP_KEY_SHA256 in the gateway process environment. For the authentication workflows and security implications, see Client Authentication.
Claim Mappings
A claim mapping resolves the verified claims of a JWT to an existing caller API key when no key binds the token's subject directly. Enabled mappings for the matched provider are evaluated in priority order (lower first, ties broken by name); the first mapping whose conditions all hold selects the key, and a token matching no mapping is rejected. See JWT Claim Mappings for evaluation semantics.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Mapping name. Also the evaluation tie-break for equal priorities. |
jwt_provider | string | yes | Name of the oidc_providers entry whose tokens this mapping applies to. |
priority | integer | no | Evaluation order among the provider's mappings; lower values are evaluated first. Default: 0. |
match | array of objects | yes | Claim conditions that must all hold. Each carries claim (read as one claim name first, then dots traverse nested objects), op (exact for a string claim, contains for an array claim; non-string array items are ignored), and values (accepted alternatives). The list must contain at least one condition. |
resolve.api_key_id | string | yes | id of the caller API key that matching requests run as. |
enabled | boolean | no | Whether the mapping participates in evaluation. Default: true. |
An empty match list rejects the entry. The loader does not check that the provider and the key exist; see References.
_format_version: "2"
oidc_providers:
- id: f1aac41c-d83d-41ef-b2d3-abae0b774fbe
name: corp-keycloak
issuer: https://sso.example.com/realms/agents
audiences: ["aisix-gateway"]
api_keys:
- id: d597a758-39d4-4d3f-bb1a-31800c47dcd3
display_name: finance-policy-key
key_hash: ${FINANCE_POLICY_KEY_SHA256}
allowed_models: []
claim_mappings:
- id: 262a8c5b-b3b8-4fdc-b147-4c8af398ed86
name: finance-dept
jwt_provider: corp-keycloak
priority: 100
match:
- claim: department
op: exact
values: ["finance"]
resolve:
api_key_id: d597a758-39d4-4d3f-bb1a-31800c47dcd3