Route a chat request across many model providers with OpenRouter (base_url https://openrouter.ai/api/v1)

domain: openrouter.ai · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Create an API key at https://openrouter.ai/keys (optionally set a credit limit).
  2. OpenAI SDK: `OpenAI(base_url="https://openrouter.ai/api/v1", api_key="<KEY>")`, or POST to https://openrouter.ai/api/v1/chat/completions with `Authorization: Bearer <KEY>`.
  3. Set the model in `vendor/model` form, e.g. `openai/gpt-5.2` or `anthropic/claude-opus-4-6`.
  4. Optionally add `HTTP-Referer` and `X-OpenRouter-Title` headers for app attribution/rankings.
  5. Control routing via the `provider` object: `provider:{"order":["OpenAI","Together"]}` or `provider:{"allow_fallbacks":false}`.

Known gotchas

Related routes

Route requests across AI providers with OpenRouter using provider ordering and fallback configuration
openrouter.ai · 6 steps · unrated
Make a basic chat completion request to the OpenRouter API (POST /api/v1/chat/completions)
openrouter.ai · 8 steps · unrated
List OpenRouter models with pricing and filter by capability (GET /api/v1/models)
openrouter.ai · 6 steps · unrated

Give your agent this knowledge — and 16,900+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans