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.

v1.9.0发布于 2026-11-05 18:17 UTC218star +3 / 7 天47fork同步于 2026-11-10 12:04 UTC

怎么上手

由 README 提炼,执行前请确认
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
硬件要求按 README 说明

README 未说明具体硬件要求;以单个静态二进制运行,官方提供 ghcr.io/api7/aisix 容器镜像,未提及 GPU 或显存需求。

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

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 后端并统计节省成本

容易踩的坑

需要自行准备 config.yaml 和 resources.yaml 两个配置文件,并挂载到容器内;9090 端口的 metrics/status 监听器无认证,应只绑定回环或私有网络;resources_file 与 etcd 配置互斥,多副本集群需改用 etcd。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.9.0
  1. 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:

    📦 Download

    Pull the container image from the GitHub Container Registry:

    docker pull ghcr.io/api7/aisix:1.9.0
    

    The rolling latest tag and the docker.io/api7/aisix mirror 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 code and param, 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_claims lets tags follow the identity provider instead of being maintained on every API key.
    • Upstream errors read as text on every route (#1410, #1413): error.message is the upstream's text, and a 4xx carries code and param. This changes the error contract; see Breaking changes.
    • Failure records name their failure (#1397, #1398), and under content_mode: full they 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 error frame.
    • 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_key budget accounting, platform cost, the Logs page, control-plane API changes) are described in the AISIX release notes.

    ⚠️ Breaking changes

    resources.yaml has 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, code and param (#1410, #1413)

    On an upstream failure, error.message now 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's code and param. 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.message on these routes. Read error.message as text, and error.code and error.param as fields. The access log's error and the failure row's error_message read upstream returned HTTP 500: bad, and the full-content response field 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 as x, 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's code
  2. 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:

    📦 Download

    Pull the container image from the GitHub Container Registry:

    docker pull ghcr.io/api7/aisix:1.8.0
    

    The rolling latest tag and the docker.io/api7/aisix mirror 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-key header carries the gateway key so Authorization stays 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-cp changes) are described in the AISIX release notes.

    ⚠️ Breaking changes

    See Upgrade notes for what to update.

    • Debug response headers on /v1/chat/completions are off by default (#1364). x-aisix-call-id, x-aisix-served-by, x-aisix-route, x-aisix-cache, x-aisix-cache-layer and x-aisix-cache-similarity are no longer sent unless proxy.expose_debug_headers: true is set in the gateway config (Helm chart aisix: config.proxy.expose_debug_headers). The same facts are in usage events, access logs, metrics and traces. x-aisix-request-id, server, x-ratelimit-* and retry-after are 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_total is removed (#1367). Only Realtime ever put a value on it. Read spend from cost_usd on usage events, or the control plane's recorded cost. A config that still lists it under observability.metrics.labels boots and warns.
    • One inbound credential rule on every entry (#1383). An empty x-aisix-api-key, Authorization or x-api-key header counts as an offered credential and is a 401; 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. On gateway_key passthrough routes, an Authorization that is present but not a usable Bearer credential no longer falls back to x-api-key; it gets 401.
    • A connection whose first bytes are PROXY is read as a PROXY v1 header (#1374) and closed unless the peer is in proxy.real_ip.trusted_proxies. It used to get an HTTP 400.
    • 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
  3. 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:

    📦 Download

    Pull the container image from the GitHub Container Registry:

    docker pull ghcr.io/api7/aisix:1.7.1
    

    The rolling latest tag and the docker.io/api7/aisix mirror 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 400 naming the field. Answers come back in full, including every choice, logprobs, refusal and 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, annotations and legacy function_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_usage on every upstream (#1351).
    • Exporters accept plaintext http:// endpoints on any host (#1346).
    • Vertex AI global, us and eu locations 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/completions usage follows stream_options.include_usage on every upstream (#1351). With include_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 without include_usage. Usage events and TPM limits are unchanged. Clients that read usage from a stream must request include_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 stop to Grok or GPT 5.6 and later, temperature / top_p / logprobs to a reasoning GPT, the penalties and n, and a tool's strict for a model that does not take it can now get AWS's 400; on Vertex Gemini 2.5, so can a /v1/messages thinking.budget_tokens above the model's ceiling. Details are under Providers and endpoints.
    • Values that are illegal in the caller's own protocol answer 400 naming the field (#1351, #1353). This covers a body that is valid JSON but does not fit the request (for example max_tokens: invalid value: integer -1, expected u32 or missing field messages, instead of invalid JSON request body), a message content that is a number, boolean or object, and, on the Claude, Converse and Vertex Gemini bridges, a wrong-typed stop, max_tokens, max_completion_tokens, temperature, top_p, tool_choice, reasoning_effort or service_tier, a malformed tool, or a replayed tool call without id or function.name. These used to be dropped silently, forwarded raw or read as empty. On Bedrock Converse, a stop that is not a non-empty string or string array, and a max_completion_tokens that is not
  4. 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:

    📦 Download

    Pull the container image from the GitHub Container Registry:

    docker pull ghcr.io/api7/aisix:1.7.0
    

    The rolling latest tag and the docker.io/api7/aisix mirror 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/messages and /v1/messages/count_tokens go to each platform's own Anthropic Messages route, and prompt caching, including auto_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/systemone and /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 working count_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/systemone and /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.system is removed; use gen_ai.provider.name (a hosting platform wins, so Claude on Bedrock is aws.bedrock).
      • gen_ai.request.model is now the model name sent upstream. The model or Model Group name the caller sent moves to aisix.requested_model.
      • gen_ai.usage.input_tokens now includes cached tokens for Anthropic-shape usage (Anthropic, Bedrock Converse, and passthrough routes reporting cache_*_input_tokens). OpenAI-shape usage is unchanged. The Datadog exporter's gen_ai.usage.input_tokens changes the same way; its aisix.* counters do not.
      • Span names change: the operation span is {operation} {upstream model} (for example chat gpt-4o) instead of chat.completions, the SERVER span is POST /v1/chat/completions and the like, and MCP spans are tools/call {tool}.
      • Successful spans leave status unset instead of OK. A 4xx no 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.completion are removed. With content_mode: full, content is exported as gen_ai.input.messages, gen_ai.output.messages, gen_ai.system_instructions and `gen_ai.tool.definitio
  5. 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:

    📦 Download

    Pull the container image from the GitHub Container Registry:

    docker pull ghcr.io/api7/aisix:1.6.0
    

    The rolling latest tag and the docker.io/api7/aisix mirror 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 classifier block 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_name and policy_name labels beside the id labels.
    • Request headers on usage events (#1269) — observability.usage_event.request_headers records 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_ms bounds 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_kind and usage-event error_class share 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) and authentication_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. The error.type a client receives is unchanged. A streamed passthrough line now carries an error_kind where it used to be empty.
    • A semantic router with on_embedding_failure: fail answers a failed embedding with its own error code (#1274). It still answers 503, but with type: api_error, code: semantic_routing_failed and the message semantic router '<model>' could not pick a route (<reason>), where the reason is embedding_timeout, embedding_upstream or embedding_unavailable, instead of type: provider_unavailable ("no bri

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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.

    License: Apache 2.0 Built with Rust Docs Discord Website

    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_url and 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/messages as 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-based least_cost, least_latency, and least_busy. Per-target priority tiers (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 /mcp with gateway-held credentials, per-server tool namespaces, and per-caller access. It serves every Streamable HTTP revision from 2025-03-26 through stateless 2026-07-28 without downstream sessions. Upstreams use initialize by default or server/discover with protocol_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.yaml carries 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 validate checks a file offline; SIGHUP reloads it atomically.
    • Operational endpoints — /livez and /readyz on the proxy listener; /status/config, /status/ready, /status/models, and Prometheus /metrics on 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 the resources_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 familyReachesWire shape · auth
    openaiOpenAI + any OpenAI-compatible vendor — DeepSeek, Groq, Mistral, Together, Fireworks, Perplexity, vLLM, Ollama, or self-hosted OpenAI-compatible endpointsOpenAI chat completions · Bearer
    anthropicAnthropic ClaudeAnthropic Messages · x-api-key
    bedrockAWS Bedrock — Anthropic, Meta Llama, Mistral, Cohere, Amazon Titan/Nova, AI21Bedrock Converse + /invoke · SigV4
    vertexGoogle Vertex AI (Gemini)Vertex :generateContent · OAuth2
    azure-openaiAzure OpenAIAzure 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 EnterpriseAISIX Cloud
    LicenseApache-2.0CommercialCommercial
    Control planeNoneCustomer-hostedAPI7-hosted
    ConfigurationDeclarative resources.yaml, or etcd for a clusterDashboard + AISIX Cloud Admin APIDashboard + AISIX Cloud Admin API
    TenancySingle instance / namespaceOrganization-scoped environments, teams, and membersOrganization-scoped environments, teams, and members
    Provider keys${VAR} references in resources.yaml; plaintext credentials in etcdEncrypted at rest; operator-triggered in-place rotationEncrypted at rest; operator-triggered in-place rotation
    Budgets— (rate and token limits only)Per key, provider, environment, organization, and teamPer key, provider, environment, organization, and team
    RBAC and auditLocal admin key; no organization layerOrganization roles, invitations, and audit historyOrganization roles, invitations, and audit history
    OperationsYou operate the gatewayYou operate the control plane and gatewaysAPI7 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

    If AISIX is useful to you, a ⭐ helps other engineers find it.

    📄 License

    Apache 2.0.