需要自行准备 config.yaml 和 resources.yaml 两个配置文件,并挂载到容器内;9090 端口的 metrics/status 监听器无认证,应只绑定回环或私有网络;resources_file 与 etcd 配置互斥,多副本集群需改用 etcd。
aisix
api7Apache-2.0活跃维护用 Rust 写的开源 AI 网关,把 OpenAI、Anthropic、Gemini、Bedrock 等模型统一到一个 OpenAI 兼容接口,顺带做路由、护栏、缓存、限流和可观测性。
Open-source AI gateway for LLMs & AI agents, built in Rust. One OpenAI-compatible API for OpenAI, Anthropic, Gemini, Bedrock & more — routing, guardrails, caching, rate limits, observability.
docker run -d --name aisix -v "$(pwd)/config.yaml:/etc/aisix/config.yaml:ro" -v "$(pwd)/resources.yaml:/etc/aisix/resources.yaml:ro" -e OPENAI_API_KEY -e CALLER_API_KEY -p 3000:3000 -p 127.0.0.1:9090:9090 ghcr.io/api7/aisix:latestREADME 未说明具体硬件要求;以单个静态二进制运行,官方提供 ghcr.io/api7/aisix 容器镜像,未提及 GPU 或显存需求。
Rust 编写的开源 AI 网关,用一套 OpenAI 兼容 API 统一路由、治理和观测所有 LLM 流量
用 Rust 写的开源 AI 网关,把 OpenAI、Anthropic、Gemini、Bedrock 等模型统一到一个 OpenAI 兼容接口,顺带做路由、护栏、缓存、限流和可观测性。
核心能力
- 用一套 OpenAI 兼容 API 接入 OpenAI、Anthropic、Gemini、Bedrock 等多家模型
- 支持六种路由策略与故障转移,含优先级池、重试预算和冷却
- 内置 RPS、TPM 与并发限流,可按 key、模型、团队等维度组合
- 提供关键词、PII、Presidio、Lakera 等内容护栏,支持监控模式
- 精确匹配响应缓存,支持内存与 Redis 后端并统计节省成本
容易踩的坑
- v1.9.0v1.9.0 — Per-user MCP sign-in, tags from JWT claims, upstream errors as text最新正式版2026-11-05 · 2026-11-05 18:17 UTC
🚀 Get started
New to AISIX? Get the gateway running and route your first LLM request in minutes:
- 📖 Documentation — https://docs.api7.ai/ai-gateway/
- ⚡ Gateway quickstart (one container, declarative
resources.yaml) — https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart
📦 Download
Pull the container image from the GitHub Container Registry:
docker pull ghcr.io/api7/aisix:1.9.0The rolling
latesttag and thedocker.io/api7/aisixmirror for private/offline deployments are listed on the package page.
AISIX 1.9.0 lets each user sign in to upstream MCP servers from their MCP client, and turns claims of a verified token into cost-attribution tags. Upstream failures now reach callers as the upstream's own text with its
codeandparam, and failure records say what went wrong.- Per-user OAuth to upstream MCP servers (#1394, #1399, #1400, #1402): each user signs in to the upstream from their MCP client, with or without a gateway credential, and the gateway calls the upstream with that user's token.
- Cost-attribution tags from JWT claims (#1407):
oidc_providers.tag_claimslets tags follow the identity provider instead of being maintained on every API key. - Upstream errors read as text on every route (#1410, #1413):
error.messageis the upstream's text, and a 4xx carriescodeandparam. This changes the error contract; see Breaking changes. - Failure records name their failure (#1397, #1398), and under
content_mode: fullthey carry the request and response bodies on every endpoint and status. - A refused realtime session answers and records as a failure (#1410, #1411, #1412, #1413), with the upstream's reason in the client's
errorframe. - Vertex AI Gemini returns reasoning and generated images (#1391, #1393).
Control-plane, console and AISIX Enterprise / AISIX Cloud changes in this release (administering connected MCP users,
provider_keybudget accounting, platform cost, the Logs page, control-plane API changes) are described in the AISIX release notes.⚠️ Breaking changes
resources.yamlhas no format break in this release: existing files load as they are. The changes below are in gateway behaviour, and each says what to update.Upstream error responses carry text,
codeandparam(#1410, #1413)On an upstream failure,
error.messagenow holds the upstream's text rather than its whole error body as a JSON string. This applies to/v1/rerank(including Cohere),/v1/audio/speech,/v1/audio/transcriptions,/v1/audio/translations,/v1/images/edits, and native/v1/responses(including streaming). A 4xx now also carries the upstream'scodeandparam. A 5xx carries neither. Status codes do not change.Before:
{"error":{"message":"{\"error\":{\"message\":\"bad\",\"type\":\"invalid_request_error\",\"code\":\"bad_param\",\"param\":\"x\"}}","type":"upstream_error"}}After:
{"error":{"message":"bad","type":"upstream_error","param":"x","code":"bad_param"}}Before upgrading, change any caller that parses JSON out of
error.messageon these routes. Readerror.messageas text, anderror.codeanderror.paramas fields. The access log'serrorand the failure row'serror_messagereadupstream returned HTTP 500: bad, and the full-contentresponsefield still holds the upstream's body as sent.Related changes:
- Other error body shapes, on every route. A body shaped
{"message":"x"},{"error":"x"},{"detail":"x"}, or{"detail":{"message":"x"}}now reads asx, including on chat, completions, embeddings, images, messages, count tokens, and bridged responses, which used to return the raw body text. A blank field no longer hides the text of a later one. A non-JSON body stays the text as sent. /v1/decisions. A 4xx now carries the upstream'scode
- v1.8.0v1.8.0 — MCP on the caller's behalf, PROXY protocol, gateway-side budgets2026-10-29 · 2026-10-29 15:44 UTC
查看更新说明
true v1.8.0
🚀 Get started
New to AISIX? Get the gateway running and route your first LLM request in minutes:
- 📖 Documentation — https://docs.api7.ai/ai-gateway/
- ⚡ Gateway quickstart (one container, declarative
resources.yaml) — https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart
📦 Download
Pull the container image from the GitHub Container Registry:
docker pull ghcr.io/api7/aisix:1.8.0The rolling
latesttag and thedocker.io/api7/aisixmirror for private/offline deployments are listed on the package page.
AISIX 1.8.0 lets MCP servers act on the caller's behalf, accepts PROXY protocol headers from trusted load balancers, and moves budget decisions onto the gateway itself, so a control-plane outage no longer turns into a blanket refusal. An idle gateway now needs a fraction of the memory it used to.
- MCP servers can act on the caller's behalf (#1361, #1362): relay the caller's own token upstream, or exchange it for a downstream token through the Microsoft Entra ID On-Behalf-Of grant. A new
x-aisix-api-keyheader carries the gateway key soAuthorizationstays free for the caller's own token. - PROXY protocol v1 and v2 from trusted load balancers (#1374), on every proxy listener, detected automatically.
- Budgets are decided on the gateway (#1366) from budget state the control plane pushes with the configuration. A control-plane or database outage no longer refuses traffic.
- Every proxy route emits every per-request metric family that applies to it (#1367), and access logs carry token counts on every endpoint (#1365).
- Unknown startup-config keys are ignored with a warning instead of stopping the gateway (#1368).
- Idle memory drops from about 120 MiB to under 10 MiB (#1370).
Control-plane, console and AISIX Enterprise / AISIX Cloud changes in this release (two-factor sign-in, password policy, control-plane API and Helm
aisix-cpchanges) are described in the AISIX release notes.⚠️ Breaking changes
See Upgrade notes for what to update.
- Debug response headers on
/v1/chat/completionsare off by default (#1364).x-aisix-call-id,x-aisix-served-by,x-aisix-route,x-aisix-cache,x-aisix-cache-layerandx-aisix-cache-similarityare no longer sent unlessproxy.expose_debug_headers: trueis set in the gateway config (Helm chartaisix:config.proxy.expose_debug_headers). The same facts are in usage events, access logs, metrics and traces.x-aisix-request-id,server,x-ratelimit-*andretry-afterare still sent. - Four access-log fields take their usage-event names (#1365):
status→status_code,error_kind→error_class,model→requested_model,latency_ms→downstream_latency_ms. Only the new names are written. aisix_llm_spend_micro_usd_totalis removed (#1367). Only Realtime ever put a value on it. Read spend fromcost_usdon usage events, or the control plane's recorded cost. A config that still lists it underobservability.metrics.labelsboots and warns.- One inbound credential rule on every entry (#1383). An empty
x-aisix-api-key,Authorizationorx-api-keyheader counts as an offered credential and is a401; it is no longer skipped, so an MCP client using anonymous access that sends one of them empty is now refused instead of served anonymously. Ongateway_keypassthrough routes, anAuthorizationthat is present but not a usableBearercredential no longer falls back tox-api-key; it gets401. - A connection whose first bytes are
PROXYis read as a PROXY v1 header (#1374) and closed unless the peer is inproxy.real_ip.trusted_proxies. It used to get an HTTP400. - Dual-stack (
[::]) listeners report and match IPv4 clients as plain IPv4 (#1374) instead of::ffff:a.b.c.d, in allowlists, usage events, OTLP `client.a
- v1.7.12026-10-27 · 2026-10-27 11:38 UTC
查看更新说明
🚀 Get started
New to AISIX? Get the gateway running and route your first LLM request in minutes:
- 📖 Documentation — https://docs.api7.ai/ai-gateway/
- ⚡ Gateway quickstart (one container, declarative
resources.yaml) — https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart
📦 Download
Pull the container image from the GitHub Container Registry:
docker pull ghcr.io/api7/aisix:1.7.1The rolling
latesttag and thedocker.io/api7/aisixmirror for private/offline deployments are listed on the package page.
AISIX 1.7.1 is a patch release. The gateway now handles every request field by what the target platform documents: a parameter the target can carry is sent as written and the upstream's own error comes back, a parameter it cannot carry is dropped, and a value that is illegal in the caller's own protocol is a
400naming the field. Answers come back in full, including every choice,logprobs,refusaland annotations.- Request parameters follow the target platform's contract (#1352, #1353): Bedrock, Vertex Gemini and Claude receive the fields they document, in the slot they document, and the upstream's rejection reaches the caller.
- Answers come back in full (#1353, #1354, #1356): every choice,
logprobs,refusal,annotationsand legacyfunction_call, and answers whose content is an array of parts work end to end. - Legacy function calling works on every provider (#1353), including Claude, Vertex Gemini and Amazon Bedrock.
- Streamed chat usage follows
stream_options.include_usageon every upstream (#1351). - Exporters accept plaintext
http://endpoints on any host (#1346). - Vertex AI
global,usandeulocations reach Google's endpoints, and transcription usage and latency are recorded more completely (#1357, #1359, #1360).
⚠️ Behavior changes
See Upgrade notes for what to update.
- Streamed
/v1/chat/completionsusage followsstream_options.include_usageon every upstream (#1351). Withinclude_usage: true, usage is sent exactly once, on its own chunk (choices: []) after every other chunk. Without it, no chunk carries usage, as with OpenAI. Before, Claude (any platform), Vertex Gemini and OpenAI-compatible upstreams that report usage on the finish chunk showed it there even withoutinclude_usage. Usage events and TPM limits are unchanged. Clients that read usage from a stream must requestinclude_usage. - Parameters the gateway used to drop now reach the upstream (#1352, #1353). Fields the target defines go out as the caller wrote them, and the upstream's rejection reaches the caller with its status and message; the gateway no longer drops, rewrites or pre-validates them. On Amazon Bedrock this means
stopto Grok or GPT 5.6 and later,temperature/top_p/logprobsto a reasoning GPT, the penalties andn, and a tool'sstrictfor a model that does not take it can now get AWS's400; on Vertex Gemini 2.5, so can a/v1/messagesthinking.budget_tokensabove the model's ceiling. Details are under Providers and endpoints. - Values that are illegal in the caller's own protocol answer
400naming the field (#1351, #1353). This covers a body that is valid JSON but does not fit the request (for examplemax_tokens: invalid value: integer -1, expected u32ormissing field messages, instead ofinvalid JSON request body), a messagecontentthat is a number, boolean or object, and, on the Claude, Converse and Vertex Gemini bridges, a wrong-typedstop,max_tokens,max_completion_tokens,temperature,top_p,tool_choice,reasoning_effortorservice_tier, a malformed tool, or a replayed tool call withoutidorfunction.name. These used to be dropped silently, forwarded raw or read as empty. On Bedrock Converse, astopthat is not a non-empty string or string array, and amax_completion_tokensthat is not
- v1.7.0v1.7.0 — Native Claude on Bedrock and Vertex AI2026-10-22 · 2026-10-22 03:49 UTC
查看更新说明
🚀 Get started
New to AISIX? Get the gateway running and route your first LLM request in minutes:
- 📖 Documentation — https://docs.api7.ai/ai-gateway/
- ⚡ Gateway quickstart (one container, declarative
resources.yaml) — https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart
📦 Download
Pull the container image from the GitHub Container Registry:
docker pull ghcr.io/api7/aisix:1.7.0The rolling
latesttag and thedocker.io/api7/aisixmirror for private/offline deployments are listed on the package page.
AISIX 1.7.0 serves Claude on Amazon Bedrock and Vertex AI natively, stops dropping media on native-protocol upstreams, and brings exported telemetry onto the released OpenTelemetry GenAI conventions.
/v1/messagesand/v1/messages/count_tokensgo to each platform's own Anthropic Messages route, and prompt caching, includingauto_prompt_caching, now works there. Images, audio and files in chat requests reach Vertex Gemini, Anthropic and Bedrock instead of being dropped. Bedrock gains API-key, default-credential-chain and assumed-role authentication. API keys, teams and members can carry cost-attribution tags that flow to every usage event and can drive rate limits. Two decision endpoints,/v1/systemoneand/v1/decisions, are new.- Claude on Bedrock and Vertex AI, natively (#1318, #1316, #1323, #1325): signed thinking, native stop reasons and cache counters on
/v1/messages, a workingcount_tokens, and prompt caching on every entry point. - Media reaches native-protocol upstreams (#1314, #1327): image, audio and file parts are translated for Vertex Gemini, Anthropic, Claude on Vertex AI and Bedrock, and URLs the upstream cannot read are downloaded by the gateway behind one SSRF setting.
- Bedrock, broadened (#1319, #1322, #1328): API-key, default-chain and AssumeRole authentication, GPT 5.6+ and Grok on Bedrock's Chat Completions endpoint, Converse requests that follow what the caller sent, and the proxy environment honoured.
- Telemetry on the GenAI semantic conventions (#1288, #1299, #1300): OTLP spans follow v1.41.1, and the OTLP, Datadog and SLS exporters carry structured messages with reasoning and tool calls. Each exporter chooses its own headers to record.
- Cost-attribution tags (#1301) on API keys, teams and members, stamped on every usage event and usable as
tag:<key>rate-limit dimensions. - Decision endpoints (#1293, #1294):
/v1/systemoneand/v1/decisions, with conversion between the two formats.
⚠️ Breaking changes
- OTLP spans follow the OpenTelemetry GenAI semantic conventions v1.41.1 (#1288, #1299). Saved queries and dashboards keyed on the old names must be updated:
gen_ai.systemis removed; usegen_ai.provider.name(a hosting platform wins, so Claude on Bedrock isaws.bedrock).gen_ai.request.modelis now the model name sent upstream. The model or Model Group name the caller sent moves toaisix.requested_model.gen_ai.usage.input_tokensnow includes cached tokens for Anthropic-shape usage (Anthropic, Bedrock Converse, and passthrough routes reportingcache_*_input_tokens). OpenAI-shape usage is unchanged. The Datadog exporter'sgen_ai.usage.input_tokenschanges the same way; itsaisix.*counters do not.- Span names change: the operation span is
{operation} {upstream model}(for examplechat gpt-4o) instead ofchat.completions, the SERVER span isPOST /v1/chat/completionsand the like, and MCP spans aretools/call {tool}. - Successful spans leave status unset instead of
OK. A4xxno longer marks the SERVER span as an error, and a caller that hung up (499) is not an error on any span. gen_ai.prompt/gen_ai.completionare removed. Withcontent_mode: full, content is exported asgen_ai.input.messages,gen_ai.output.messages,gen_ai.system_instructionsand `gen_ai.tool.definitio
- v1.6.0v1.6.0 — Classifier routing and readable metrics2026-10-12 · 2026-10-12 18:29 UTC
查看更新说明
🚀 Get started
New to AISIX? Get the gateway running and route your first LLM request in minutes:
- 📖 Documentation — https://docs.api7.ai/ai-gateway/
- ⚡ Gateway quickstart (one container, declarative
resources.yaml) — https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart
📦 Download
Pull the container image from the GitHub Container Registry:
docker pull ghcr.io/api7/aisix:1.6.0The rolling
latesttag and thedocker.io/api7/aisixmirror for private/offline deployments are listed on the package page.
AISIX 1.6.0 lets a semantic router decide with a classification model, puts readable names on metrics, and makes what the gateway records describe what actually happened. A semantic router can pick its route with TypeSafe's jev decision model instead of embedding similarity. Prometheus series can carry API key, team, provider key and policy names beside their ids, and usage events can record request headers you choose. Streamed responses are counted in the request metrics when they end, under the status they ended on, and every refusal the gateway makes itself is named on both the access log and the usage event. Function calling now works end to end on Vertex AI Gemini, reasoning crosses the Anthropic Messages and chat bridges, and passthrough routes enforce their boundaries, their concurrency and their guardrails for the whole stream.
- jev classifier for semantic routers (#1257) — a semantic model can carry a
classifierblock and route by each route's description instead of examples and thresholds; every semantic router's access-log line now names its decision. - Readable name labels on metrics (#1268) — opt-in
api_key_name,team_name,provider_key_nameandpolicy_namelabels beside the id labels. - Request headers on usage events (#1269) —
observability.usage_event.request_headersrecords the headers you list on every usage event. - Streamed responses are recorded at stream end with their real status (#1273), and gateway refusals carry their reason on the usage event and the access log (#1275, #1279).
- Tools work on Vertex AI Gemini, and Claude tool calls reach streaming OpenAI-protocol clients (#1277, #1280, #1276); reasoning crosses the Messages/chat bridges (#1267), and Claude models that reject the effort parameter get a thinking budget for
reasoning_effort(#1274). - Passthrough routes hold their boundaries (#1262) — unsafe paths and conflicting queries are refused, redirects are relayed,
timeout_msbounds event streams, concurrency is held for the whole stream, and output guardrails fail closed on a response they cannot evaluate.
⚠️ Breaking changes
- Access-log
error_kindand usage-eventerror_classshare one vocabulary (#1273). Non-streamed access-log lines, and terminal usage events of failed requests that carry no attempt record, change these values:upstream_error→upstream_status,transport_error→transport,upstream_decode_error→upstream_decode,upstream_in_band_error→upstream_in_band,config_error→config,invalid_request_error→invalid_config(invalid upstream configuration) andauthentication_error→invalid_credentials. Per-attempt events and streamed lines already used the new names. Log and event pipelines that match the old values must accept the new ones. Theerror.typea client receives is unchanged. A streamed passthrough line now carries anerror_kindwhere it used to be empty. - A semantic router with
on_embedding_failure: failanswers a failed embedding with its own error code (#1274). It still answers503, but withtype: api_error,code: semantic_routing_failedand the messagesemantic router '<model>' could not pick a route (<reason>), where the reason isembedding_timeout,embedding_upstreamorembedding_unavailable, instead oftype: provider_unavailable("no bri
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
AISIX OSS
The open-source, Rust-native AI gateway for LLMs and AI agents
One OpenAI-compatible API in front of every model. Route, govern, secure, cache, and observe all your LLM and AI-agent traffic from a single control point — shipped as one static binary with low per-request overhead. Run it in your infrastructure for free, forever.
Built by the original creators of Apache APISIX.
Start free · Documentation · Quickstart · AISIX Enterprise and AISIX Cloud · Roadmap
AISIX OSS is the open-source product built around the Rust-native AISIX gateway. The gateway puts a single, OpenAI-compatible API in front of every LLM provider — OpenAI, Anthropic, Google Gemini, AWS Bedrock, Azure OpenAI, DeepSeek, and any OpenAI-compatible endpoint. It gives platform teams one place to route, govern, secure, and observe LLM traffic, with first-class SSE streaming and low gateway overhead.
It runs as a single static binary — low cold-start, lock-free config reads, and hot
configuration reloads with no restarts: declare resources in one resources.yaml and
reload on SIGHUP, or point the gateway at etcd for a multi-replica cluster. Run the
gateway in your infrastructure, or connect it to AISIX Enterprise or
AISIX Cloud
for centralized management with team governance, budgets, audit, and a dashboard.
AISIX OSS (this repo) is the open-source product. It runs without a control plane using declarative configuration or etcd. The same gateway binary serves as the data plane in the commercial products: customers host the control plane with AISIX Enterprise, while API7 hosts it with AISIX Cloud. In all three products, the gateway runs in your environment and calls providers directly; live AI traffic does not pass through either control plane. The proxy API is identical throughout. Talk to us about AISIX Enterprise or AISIX Cloud →
⚡ Quickstart
One container. No control plane, no database, no configuration store — the gateway reads
every dynamic resource from one declarative resources.yaml.
# config.yaml
resources_file: /etc/aisix/resources.yaml
proxy:
addr: "0.0.0.0:3000"
admin:
enabled: false # a declarative gateway needs no admin listener
observability:
metrics:
prometheus:
enabled: true
addr: "0.0.0.0:9090"
# resources.yaml
_format_version: "1"
provider_keys:
- display_name: openai-main
provider: openai
api_key: ${OPENAI_API_KEY} # interpolated from the environment
models:
- display_name: my-model
provider: openai
model_name: gpt-4o-mini
provider_key: openai-main
api_keys:
- display_name: local-dev
key_env: CALLER_API_KEY # hashed at load; the plaintext is never stored
allowed_models: ["my-model"]
export OPENAI_API_KEY="YOUR_PROVIDER_KEY"
export CALLER_API_KEY="YOUR_CALLER_KEY"
docker run -d --name aisix \
-v "$(pwd)/config.yaml:/etc/aisix/config.yaml:ro" \
-v "$(pwd)/resources.yaml:/etc/aisix/resources.yaml:ro" \
-e OPENAI_API_KEY -e CALLER_API_KEY \
-p 3000:3000 -p 127.0.0.1:9090:9090 \
ghcr.io/api7/aisix:latest # proxy → :3000, metrics + status → :9090
# ^ the metrics/status listener is unauthenticated;
# keep it on loopback or a private network
Then call the gateway exactly like OpenAI:
curl http://localhost:3000/v1/chat/completions \
-H "Authorization: Bearer $CALLER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"my-model","messages":[{"role":"user","content":"hello"}]}'
Edit resources.yaml and send SIGHUP (docker kill -s HUP aisix) to apply changes with
no restart — an invalid file is rejected whole and the last good configuration keeps
serving. Check a file before booting with aisix validate --resources resources.yaml.
Full walkthrough: the
Gateway Quickstart ·
every field: the resources file reference.
For a multi-replica cluster, point the gateway at etcd instead — resources_file and
etcd are mutually exclusive.
✨ Why AISIX
- One API, every model. Speak the OpenAI or Anthropic wire format in; the gateway
translates to whichever provider each model points at. Point an OpenAI or Claude SDK at
one
base_urland switch models without changing code. - A real gateway, in Rust. Single static binary, low cold-start, lock-free config reads on the hot path, native streaming.
- Open source, free forever. Apache-2.0 licensed and built to run in your infrastructure. Choose AISIX Enterprise or AISIX Cloud when you want centralized management through a control plane and dashboard.
- Production controls built in. Routing & failover, rate limits, guardrails, caching, and observability ship in the box. (Budgets and spend caps are AISIX Enterprise and AISIX Cloud features — the gateway enforces the control plane's decisions.)
🧩 Features — available today
Covered by 183 end-to-end scenario files (496 cases) that run against real gateway processes.
- OpenAI-compatible proxy (
:3000) —chat/completions,completions,responses,embeddings,rerank,images/{generations,edits},audio/{speech,transcriptions,translations},videos(submit → poll → fetch),files,batches,fine_tuning/jobs,realtime,GET /v1/models, plus a root-level/passthrough/:provider/*escape hatch. Native SSE streaming, tool/function calling, JSON mode, vision/multimodal input, and reasoning-content support. - Anthropic Messages API —
POST /v1/messagesas a first-class route, working against any configured upstream: requests and responses (including streaming) are translated both ways when a model points at a non-Anthropic provider. - Routing & failover — virtual/routing models with six strategies:
round_robin(smooth weighted round-robin),consistent_hash(session affinity keyed by header / cookie / API key / client IP),failover, plus metric-basedleast_cost,least_latency, andleast_busy. Per-targetprioritytiers (active/backup pools), retry budgets, cooldowns, tag-conditional targets, and per-attempt timeouts. - Ensemble models — fan one request out to a panel of models concurrently, then have a judge model synthesize a single answer, with a minimum-successful-responses threshold.
- Semantic routing — one virtual model that dispatches by the meaning of each request: it embeds the prompt, scores it against per-route example utterances, and routes to the best match (or a default). See the semantic routing docs.
- Rate limiting & concurrency — RPS/RPM/RPH/RPD + TPM/TPD + concurrency caps,
AND-combined across caller keys, models, and policy scopes (
api_key/model/team/member/team_member). Counters are per-process by default, or shared across replicas with the Redis backend. - Guardrails — content-policy enforcement on input and output, in-process or through a
provider: keyword/regex, built-in PII detection and redaction, Presidio, Lakera, OpenAI
Moderation, AWS Bedrock Guardrails, Azure AI Content Safety (Prompt Shield + text
moderation), and two Alibaba Cloud services. A block returns
422 content_filter; monitor mode records what would have happened without blocking. - Caching — exact-match response cache with per-policy TTL and model/key scope matchers; memory and Redis backends; cost-saved telemetry on every hit. Separately, automatic prompt caching can be enabled per direct Anthropic model to inject cache breakpoints, so callers get provider-side prompt discounts without changing their requests.
- MCP gateway — front registered upstream MCP servers at
/mcpwith gateway-held credentials, per-server tool namespaces, and per-caller access. It serves every Streamable HTTP revision from2025-03-26through stateless2026-07-28without downstream sessions. Upstreams useinitializeby default orserver/discoverwithprotocol_version: "2026-07-28". CI runs the official MCP suite's applicable tools-only protocol scenarios. Also exposes a REST API as MCP tools from its OpenAPI description. - A2A agent gateway — front A2A (Agent-to-Agent) agents at
/a2a/:agent, serving each agent's card with URLs rewritten to the gateway, over JSON-RPC 2.0. - Inbound authentication — caller API keys (SHA-256 hashed, model allowlists, expiry, rotation), or OIDC/JWT bearer tokens validated against registered providers (Entra ID, Okta, Google Workspace, or any OIDC issuer) with JWKS caching.
- Observability — Prometheus
/metrics, structured per-request access logs, usage events, OTLP/GenAI span export (Langfuse, Honeycomb, Grafana Cloud, or any OTLP receiver), plus dedicated Datadog and Aliyun SLS log exporters and object-storage (S3/GCS/Azure Blob) telemetry. - Declarative configuration — one
resources.yamlcarries all ten resource collections (provider keys, models, caller keys, guardrails, MCP servers, A2A agents, cache policies, observability exporters, rate-limit policies, OIDC providers), validated against the same JSON Schemas the gateway uses at runtime.aisix validatechecks a file offline;SIGHUPreloads it atomically. - Operational endpoints —
/livezand/readyzon the proxy listener;/status/config,/status/ready,/status/models, and Prometheus/metricson a dedicated metrics listener (:9090). The admin listener (:3001) additionally serves a read-only resource surface, OpenAPI 3 with a Scalar UI, and a playground. Resources are managed declaratively — through theresources_file(reloaded on SIGHUP) or direct etcd writes — not through the admin listener; its former write endpoints were removed.
🔌 Supported providers
AISIX dispatches through five native adapter families — distinct wire-protocol bridges, not one generic relabel. Whatever the upstream protocol, the client-facing API stays OpenAI-shaped.
| Adapter family | Reaches | Wire shape · auth |
|---|---|---|
openai | OpenAI + any OpenAI-compatible vendor — DeepSeek, Groq, Mistral, Together, Fireworks, Perplexity, vLLM, Ollama, or self-hosted OpenAI-compatible endpoints | OpenAI chat completions · Bearer |
anthropic | Anthropic Claude | Anthropic Messages · x-api-key |
bedrock | AWS Bedrock — Anthropic, Meta Llama, Mistral, Cohere, Amazon Titan/Nova, AI21 | Bedrock Converse + /invoke · SigV4 |
vertex | Google Vertex AI (Gemini) | Vertex :generateContent · OAuth2 |
azure-openai | Azure OpenAI | Azure deployments · api-key / Entra ID |
Plus specialized handling for vendor quirks (e.g. DeepSeek reasoning content) and dedicated rerank / embeddings vendors (Cohere, Jina). Details in adapter protocol families.
☁️ Choose an AISIX Product
Same gateway binary, same proxy API — in every form the gateway runs in your environment. AISIX Enterprise adds a customer-hosted commercial control plane. AISIX Cloud adds an API7-hosted commercial control plane.
| AISIX OSS (this repo) | AISIX Enterprise | AISIX Cloud | |
|---|---|---|---|
| License | Apache-2.0 | Commercial | Commercial |
| Control plane | None | Customer-hosted | API7-hosted |
| Configuration | Declarative resources.yaml, or etcd for a cluster | Dashboard + AISIX Cloud Admin API | Dashboard + AISIX Cloud Admin API |
| Tenancy | Single instance / namespace | Organization-scoped environments, teams, and members | Organization-scoped environments, teams, and members |
| Provider keys | ${VAR} references in resources.yaml; plaintext credentials in etcd | Encrypted at rest; operator-triggered in-place rotation | Encrypted at rest; operator-triggered in-place rotation |
| Budgets | — (rate and token limits only) | Per key, provider, environment, organization, and team | Per key, provider, environment, organization, and team |
| RBAC and audit | Local admin key; no organization layer | Organization roles, invitations, and audit history | Organization roles, invitations, and audit history |
| Operations | You operate the gateway | You operate the control plane and gateways | API7 operates the control plane; you operate gateways |
→ Want centralized governance, budgets, and a dashboard? Talk to API7 about AISIX Enterprise or AISIX Cloud, or book a demo.
🏗️ Architecture
A single Cargo workspace; the aisix-server crate builds one binary named aisix that
wires the crates together.
crates/
├── aisix-core Config, snapshot, resource model, resources.yaml source, errors
├── aisix-etcd Config provider + watch supervisor
├── aisix-gateway Hub & bridge, SSE parser, provider trait
├── aisix-proxy /v1/*, /mcp, /a2a handlers, routing, middleware
├── aisix-admin Read-only resource surface + playground + OpenAPI
├── aisix-provider-* openai · anthropic · azure-openai · bedrock · vertex
├── aisix-mcp MCP gateway — server registry, tool ACL, transports
├── aisix-a2a A2A agent gateway — agent cards, JSON-RPC bridge
├── aisix-ratelimit fixed-window + token accounting + concurrency (local | redis)
├── aisix-cache memory + redis backends
├── aisix-redis shared Redis connection for cache + rate limits
├── aisix-guardrails pre/post content-policy hooks
├── aisix-obs tracing, metrics, access log, exporters
└── aisix-server the `aisix` binary — bootstrap + CLI
🗺️ Roadmap
Highlights on the roadmap; tracked live in issues:
- Semantic (embedding-similarity) response caching
- More observability sinks — Langsmith, Helicone, Slack alerts
- Prompt templates managed as gateway resources
- Llama-Guard as a guardrail provider
Shipped since this list was last written: the MCP gateway, the A2A agent gateway, OIDC/JWT inbound auth, Redis-backed distributed rate limiting, and the Lakera, Presidio, PII, and OpenAI Moderation guardrails — see Features above.
🛠️ Development
Prerequisites: the Rust toolchain pinned in rust-toolchain.toml. Docker is only needed
for the tests that exercise etcd, Redis, or provider emulators.
cargo check --workspace
cargo fmt --check
cargo clippy --workspace -- -D warnings
cargo test --workspace
# Coverage (matches the CI gate)
cargo llvm-cov --workspace --lcov --output-path lcov.info
# Run locally against a resources.yaml (no etcd needed). Copy the Quickstart's two files
# and change resources_file to the local path, e.g. resources_file: ./resources.yaml
cargo run -p aisix-server --bin aisix -- --config config.local.yaml
# Check a resources file without starting a listener
cargo run -p aisix-server --bin aisix -- validate --resources resources.yaml
💬 Community
- Discord — discord.gg/dUmRZ7Rvf
- Issues & discussions — github.com/api7/aisix/issues
- Contributing — CONTRIBUTING.md
- Website — api7.ai/ai-gateway
If AISIX is useful to you, a ⭐ helps other engineers find it.