Skip to content

About

Open-source LLM gateway in Rust. One endpoint for OpenAI, Anthropic, Gemini and every other vendor. Any SDK, any model, any tool.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1.2k stars

Watchers

90 watching

Forks

Respan

Respan Gateway: one universal adapter for AI.

Y Combinator W24 PyPI crates.io License: MIT or Apache-2.0 Discord

Quickstart · Docs · Hosted models · Endpoints · ▶ Demo

Respan Gateway is an open-source AI gateway: a single Rust binary between your code and every AI API. Not just LLMs: chat, realtime voice, images, video, speech, embeddings and tools, from every major provider. Point the SDK you already use at it, and call any of them, with fallback, tools and a live log of every call built in.

A terminal running pip install respan-gateway, then respan-gateway listening on 127.0.0.1:8080 with OpenAI, Anthropic and Gemini as providers

Features

Keep your SDK, call any model

OpenAI, Anthropic and Gemini clients can all call any chat model. Streaming, tools, images and reasoning are translated both ways.

Docs →

The Anthropic SDK calling gpt-6-luna; the gateway translates Messages to Chat Completions and back

Multimodal

Realtime voice (OpenAI Realtime ⇄ Gemini Live), images, video, speech, transcription and embeddings, through the same gateway and the SDKs you already use.

Docs →

A realtime voice waveform, a generated image, video frames and an embedding vector

Server-side tools

Put MCP servers or built-in tools (web search, browsers, code sandboxes, memory) behind the gateway. It runs the tool loop server side, so any model can use them from a plain chat call.

Docs →

A chat that calls web search, a browser fetch and memory through MCP before answering

Built-in fallback and retries

A failed call falls back to the next provider, with retries and backoff. Hedged requests race a slow provider against the next one. Pick the first, cheapest or fastest.

Docs →

Claude returns 529 and the call falls back to GPT; a hedged request where Gemini wins after 800ms

Your own plugin in minutes

One trait, four hooks: a plugin is a few lines of Rust, on the same API every built-in feature uses. Start from a recipe: guardrails, PII masking, billing or an LLM judge.

Docs →

A plugin from examples/recipes/pii.rs that replaces emails with placeholders before the provider sees them

Built-in observability

Telemetry is built in: the web UI logs every call's cost, latency and tokens, and with a Respan key every request is traced in Respan.

Docs →

A request log with status, model, latency and cost, and a trace with four spans

Quickstart

1. Install

pip install respan-gateway
Other ways to install
Shell script curl -fsSL https://raw.githubusercontent.com/respanai/respan-gateway/main/install.sh | sh
Cargo cargo install respan-gateway
Docker docker run -p 8080:8080 -e OPENAI_API_KEY -e RESPAN_CLIENT_KEYS=<your key> ghcr.io/respanai/respan-gateway
Binaries GitHub releases for macOS, Linux and Windows
Inside Python Run it in-process, with no server
Inside Rust Mount it in your own service

2. Run it with a provider key

export OPENAI_API_KEY=sk-...
respan-gateway

No config file needed: every provider whose key is set is ready. No provider keys? One Respan key (RESPAN_API_KEY) reaches every hosted model. The web UI is at localhost:8080/ui/.

3. Call any model from the SDK you already use

from anthropic import Anthropic

client = Anthropic(base_url="http://localhost:8080", api_key="unused")
reply = client.messages.create(
    model="gpt-6-luna",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.content[0].text)

The real provider keys stay in the gateway, so api_key can be anything.

Configuration

No config file is needed to start. When you want more, one gateway.toml sets up keys, providers, routing, tools and tracing (respan-gateway init writes a starter one):

# ── Client keys ───────────────────────────────────────────────────
client_keys = [{ name = "app", key = "env:APP_KEY" }]   # who may call the gateway

# ── Providers ─────────────────────────────────────────────────────
[providers.anthropic]                 # a built-in vendor: just add its key
vendor = "anthropic"
key    = "env:ANTHROPIC_API_KEY"

[providers.openai]
vendor = "openai"
key    = "env:OPENAI_API_KEY"

# ── Routes ────────────────────────────────────────────────────────
[routes.smart]                        # fallback: Claude, then GPT, each tried twice
to    = ["anthropic/claude-haiku-5-5", "openai/gpt-6-luna"]
tries = 2

# ── Tools ─────────────────────────────────────────────────────────
[tools.web]                           # search and browse as MCP tools, for any model
vendor = "tinyfish"
key    = "env:TINYFISH_API_KEY"

# ── Observability ─────────────────────────────────────────────────
[plugins.respan]                      # a trace per request in Respan
key = "env:RESPAN_API_KEY"
Hedge a slow provider
[routes.fast]                         # start GPT if Claude is 200ms late
to    = ["anthropic/claude-haiku-5-5", "openai/gpt-6-luna"]
hedge = "200ms"
Pick the cheapest model
[routes.cheap]                        # the cheapest candidate that can call tools
to    = ["openai/gpt-6-luna", "anthropic/claude-haiku-5-5"]
pick  = "cheapest"                    # or first, fastest, weighted, random
needs = ["tools"]
Any OpenAI-compatible endpoint
[providers.local]                     # vLLM, LM Studio, your own server...
formats  = ["openai-chat"]
base_url = "http://localhost:8000/v1"
An MCP server, with the tool loop
[tools.github]                        # any MCP server over HTTP
url  = "https://api.githubcopilot.com/mcp/"
auth = { bearer = "env:GITHUB_TOKEN" }

[plugins.tool_loop]                   # the gateway runs the tool calls for any model
allow     = ["github__search_*"]
max_steps = 8

Every option: configuration docs and the commented gateway.example.toml.

Works with your SDK

Every SDK, agent framework and coding agent that lets you set a base URL works with the gateway: point it at the gateway and keep your code. How to set it in each one is in one place, so you don't have to dig through each tool's docs.

Client Base URL
OpenAI SDK (Chat Completions, Responses) http://localhost:8080/v1
Anthropic SDK http://localhost:8080
Google GenAI http://localhost:8080

LLM SDKs: OpenAI SDK · Anthropic SDK · Google GenAI · LiteLLM
Agent frameworks: Vercel AI SDK · LangChain · OpenAI Agents · Claude Agent SDK · Pydantic AI
Coding agents: Claude Code · Codex CLI · Cursor · Gemini CLI · OpenCode

All other setup guides →

Guides: Use GPT, Gemini and any other model in Claude Desktop

Providers and tools

Model providers: 31 built in, plus any OpenAI-compatible endpoint. What each supports →

 Respan OpenAI Anthropic Gemini
 OpenRouter Azure Amazon Bedrock xAI
 Mistral Qwen DeepSeek DeepInfra
 Together Fireworks Baseten Perplexity
 MiniMax Z.ai Cloudflare Ollama
 vLLM EmpirioLabs AI StepFun Prime Intellect
 Morph DeepRelay TypeSafe Phonic
 Groq Cerebras Concentrate

Tools: any MCP server, plus 14 built-in tool vendors any model can use. All tools →

 Tavily Exa Linkup Firecrawl
 Browserbase TinyFish Apify E2B
 Daytona Context7 Reducto Zep
 ElevenLabs Cloudinary

Your own: anything missing is a plugin away, on the same Rust API every built-in feature uses. Start from the plugin guide or a recipe: guardrails · PII masking · billing · LLM judge · fallback · MCP proxy · all examples →

Performance

Respan Gateway Bifrost Portkey LiteLLM (1 worker)
Added latency (p50) 0.07 ms 0.16 ms 0.17 ms 4.34 ms
Throughput 56,734/s 18,182/s 4,187/s 268/s
Memory 31 MB 488 MB 350 MB 418 MB
1k streams, success 100% 92–100% — 79%
p99 with 5% slow calls 105 ms 2,002 ms 2,003 ms 2,024 ms

Community

Thank you to everyone who has contributed to Respan Gateway:

Contributors

Respan managed gateway

Respan runs the same gateway for you at gateway.respan.ai.

License

MIT or Apache-2.0, at your option.

About

Open-source LLM gateway in Rust. One endpoint for OpenAI, Anthropic, Gemini and every other vendor. Any SDK, any model, any tool.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1.2k stars

Watchers

90 watching

Forks

Releases

Packages

Contributors

Languages