Skip to main content
All integrationsLLM Provider

OpenRouter Integration

Route to 100+ models through one OpenAI-compatible key.

OpenRouter proxies dozens of providers behind a single OpenAI-compatible API. Useful when you want per-request model selection without managing separate API keys for every provider.

Setup in 4 steps

  1. 1Add OPENROUTER_API_KEY to your .env file
  2. 2Set LLM_PROVIDER=openai and LLM_BASE_URL=https://openrouter.ai/api/v1
  3. 3Set LLM_MODEL to any OpenRouter model slug (e.g. anthropic/claude-3.5-sonnet)
  4. 4Optionally pass model per-request to let callers choose the provider

What's included

  • One API key for OpenAI, Anthropic, Mistral, Llama, and dozens more
  • Per-request model override without changing environment config
  • Useful for internal tools that need model choice without extra billing setup
  • Same streaming/token-tracking flow as the built-in OpenAI provider
  • Good fallback layer if a single upstream provider has an outage

Code example

example.py
# .env — OpenRouter via OpenAI-compatible endpoint
OPENROUTER_API_KEY=sk-or-...
LLM_PROVIDER=openai
LLM_BASE_URL=https://openrouter.ai/api/v1
LLM_MODEL=anthropic/claude-3.5-sonnet

# Override model per request if needed
response = await llm.chat(
    messages=[{"role": "user", "content": prompt}],
    model="mistralai/mixtral-8x7b-instruct",
)

Full documentation: /docs/llm-providers

OpenRouter integration pre-wired and ready.

FastAPI AI Kit ships with OpenRouter configured out of the box. No manual setup required.

Ready to ship your AI backend this weekend?

Join developers who skipped weeks of boilerplate and went straight to building.

Read the docs
No subscriptions · One-time payment · Lifetime updates