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.
AISIX AI Gateway
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 Cloud Β· Roadmap
AISIX AI Gateway is a Rust-native gateway that 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 open-source gateway in your infrastructure, or connect it to AISIX Cloud for centralized management with team governance, budgets, audit, and a dashboard.
AISIX AI Gateway (this repo) is the open-source product. It runs without a control
plane using declarative configuration or etcd. When connected to
AISIX Cloud,
the same gateway serves as the data plane. AISIX Cloud adds a commercial control plane,
either hosted by API7 (Hybrid Cloud) or hosted by you in your infrastructure
(On-Premises). In both options, the gateway runs in your environment and calls
providers directly; live AI traffic does not pass through the control plane or API7.
The proxy API is identical throughout.
Talk to us about 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
formatversion: "1"
provider_keys: - display_name: openai-main provider: openai apikey: ${OPENAIAPI_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 keyenv: CALLERAPI_KEY # hashed at load; the plaintext is never stored allowed_models: ["my-model"]
export OPENAIAPIKEY="YOURPROVIDERKEY"
export CALLERAPIKEY="YOURCALLERKEY"
docker run -d --name aisix \ --platform linux/amd64 \ -v "$(pwd)/config.yaml:/etc/aisix/config.yaml:ro" \ -v "$(pwd)/resources.yaml:/etc/aisix/resources.yaml:ro" \ -e OPENAIAPIKEY -e CALLERAPIKEY \ -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 $CALLERAPIKEY" \
-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
base_url and switch models without changing code.
- A real gateway, in Rust. Single static binary, low cold-start, lock-free config reads
- Open source, free forever. Apache-2.0 licensed and built to run in your
- Production controls built in. Routing & failover, rate limits, guardrails, caching,
π§© 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, 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
- Routing & failover β virtual/routing models with six strategies:
round_robin,
weighted (with sticky/canary hashing), failover, plus metric-based least_cost,
leastlatency, and leastbusy. 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
- Semantic routing β one virtual model that dispatches by the meaning of each
- Rate limiting & concurrency β RPS/RPM/RPH/RPD + TPM/TPD + concurrency caps,
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
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;
- MCP gateway β register upstream MCP servers as first-class resources and front them
/mcp), with the gateway holding each server's upstream
credential, namespacing tools per server, and enforcing per-caller tool access. 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
- Inbound authentication β caller API keys (SHA-256 hashed, model allowlists, expiry,
- Observability β Prometheus
/metrics, structured per-request access logs, usage
- Declarative configuration β one
resources.yamlcarries all ten resource collections
aisix validate checks a file offline; SIGHUP
reloads it atomically.
- Operational endpoints β
/livezand/readyzon 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 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.
βοΈ Open source vs AISIX Cloud
Same gateway binary, same proxy API β in every form the gateway runs in your environment. AISIX Cloud adds a commercial control plane, either hosted by API7 (Hybrid Cloud) or hosted in your infrastructure (On-Premises).
![]() Overview β traffic, latency, error rate & spend at a glance ![]() Models β one alias per upstream: OpenAI, Anthropic, Bedrock, DeepSeekβ¦ ![]() Guardrails β pre-input & post-output policies, block on violation |
![]() Playground β test any model with live token & cost metering ![]() Observability β fan out traces & logs to OTLP, Datadog, object storage ![]() Budgets β hard-stop spend caps with warn-only tiers |
The AISIX Cloud dashboard β overview metrics, multi-provider models, guardrails, budgets (with hard-stop spend caps), and observability exporters, across all your gateways.
βΆ Try the live dashboard demo β aisix-demo.api7.ai
| | Open-source gateway (this repo) | AISIX Cloud (Hybrid Cloud or On-Premises) | |---|---|---| | Price | Free Β· Apache-2.0 Β· forever | Commercial β talk to us | | Configuration | Declarative resources.yaml, or etcd for a cluster | Dashboard + Cloud Admin API, multi-environment | | Tenancy | Single instance / namespace | Org β Team β Member β Environment | | Provider keys | In the resources file as ${VAR} env references, or in etcd | Envelope-encrypted at rest, write-only, in-place rotation | | Inbound auth | Caller keys (SHA-256 hashed, model allowlists, expiry), or OIDC/JWT bearers | Same, plus masked reveal, key ownership, and PATs | | Budgets | β (rate and token limits only) | Per key / provider / env / org / team, hard-stop & alerts | | RBAC | Admin key = read-only resource surface | Org roles (owner / admin / member), invites | | Audit log | β | Full org-scoped audit with diff viewer | | Usage & cost | Export logs, metrics, and usage events yourself | Managed usage views, model pricing catalog, spend reporting | | Surface | Status endpoints, OpenAPI read surface, playground | Full dashboard + per-environment playground |
β Want the AISIX Cloud control plane, governance, budgets, and dashboard? Talk to API7 about Hybrid Cloud or On-Premises, 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
π οΈ 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 resourcesfile to the local path, e.g. resourcesfile: ./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





