Abstract artwork of a glowing plug tile on a deep indigo background, with three curved connectors fanning out to model tiles marked with lightbulb, code and eye icons

OpenRouter API Base URL and OpenAI-Compatible APIs: One Endpoint for Claude, GPT and Mistral

Tom
Tom

The OpenRouter API base URL is https://openrouter.ai/api/v1, and the chat completions endpoint is https://openrouter.ai/api/v1/chat/completions. OpenRouter accepts the OpenAI Chat Completions format, so the official OpenAI SDKs work once you set the base URL to that address, send your OpenRouter key as a Bearer token and name a model such as anthropic/claude-sonnet-5.5. Change the model string to openai/gpt-6.1-sol or mistralai/mistral-large-4-0 and the same request goes to OpenAI or Mistral. Vercel AI Gateway, Portkey and the self-hosted LiteLLM Proxy also put Anthropic, OpenAI and Mistral behind one OpenAI-compatible endpoint; they're compared below.

Every URL, model ID and price on this page was checked against the vendors' own documentation and APIs in November 2026.

OpenRouter API base URL and chat completions endpoint

Setting

Value

Base URL

https://openrouter.ai/api/v1

Chat completions endpoint

POST https://openrouter.ai/api/v1/chat/completions

Auth header (required)

Authorization: Bearer <OPENROUTER_API_KEY>

Content type

Content-Type: application/json (the SDKs set it)

Optional headers

HTTP-Referer, X-OpenRouter-Title (X-Title also works), X-OpenRouter-Categories

Model ID format

author/model, e.g. anthropic/claude-sonnet-5.5

API keys

openrouter.ai/settings/keys

The optional headers only attribute your app: HTTP-Referer is your site URL and is required for attribution, X-OpenRouter-Title is the name shown in OpenRouter's rankings and goes together with HTTP-Referer, and X-OpenRouter-Categories assigns marketplace categories. Requests work without them.

curl example

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "messages": [
      {"role": "user", "content": "Explain what an OpenAI-compatible API is in one sentence."}
    ]
  }'

Python example with the official openai SDK

Install the SDK with pip install openai, export OPENROUTER_API_KEY, then run:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key=os.environ["OPENROUTER_API_KEY"],
)

completion = client.chat.completions.create(
    model="anthropic/claude-sonnet-5.5",
    messages=[
        {"role": "user", "content": "Explain what an OpenAI-compatible API is in one sentence."}
    ],
    extra_headers={
        "HTTP-Referer": "https://example.com",  # optional: your site URL
        "X-OpenRouter-Title": "My App",          # optional: your app name
    },
)

print(completion.model)
print(completion.choices[0].message.content)

The base URL stops at /v1. The SDK appends /chat/completions itself, so if you paste the full endpoint as base_url, the request goes to .../chat/completions/chat/completions and OpenRouter answers with a 404.

Model IDs and switching between Claude, GPT and Mistral

OpenRouter model IDs are author/model slugs. Current examples are openai/gpt-6.1-sol, anthropic/claude-sonnet-5.5 and mistralai/mistral-large-4-0 (the Mistral prefix is mistralai/, not mistral/). The endpoint, key and payload stay the same, so switching vendors is a loop over strings, reusing the client from above:

for model in ["openai/gpt-6.1-sol", "anthropic/claude-sonnet-5.5", "mistralai/mistral-large-4-0"]:
    r = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "Name one risk of vendor lock-in."}],
    )
    print(f"{r.model}: {r.choices[0].message.content}")

Two OpenRouter features help once you switch often. Aliases of the form ~author/family-latest, such as ~anthropic/claude-sonnet-latest, resolve to the newest model in that family, and the response's model field names the model that actually ran. A models array lists fallbacks that OpenRouter tries in order when the first model fails with any error, such as a rate limit, downtime, context length or a moderation flag. The OpenAI SDK has no argument for it, so pass it as extra_body={"models": [...]}; you are billed for the model that answered.

The full catalog, with the parameters each model supports, is at GET https://openrouter.ai/api/v1/models, which needs no key. If you're still choosing what to route to, our comparison of frontier AI models covers the main options.

On pricing, OpenRouter bills inference at the provider's list price with no markup, and takes a fee when you buy credits: 5.5% on the Standard plan and 8% on Business.

Services that let you switch between Anthropic, OpenAI and Mistral with one API

As of November 2026, OpenRouter, Vercel AI Gateway, Cloudflare AI Gateway, Portkey and the self-hosted LiteLLM Proxy each put Anthropic, OpenAI and Mistral models behind one OpenAI-compatible endpoint. Cloudflare's Unified Billing pays for OpenAI, Anthropic and Google models from Cloudflare credits, but not for Mistral: for Mistral models you add your own Mistral key. In every case you switch vendors by changing the model string. The vendors also run their own OpenAI-compatible endpoints, which help when you want one client library and don't mind one key per vendor.

Option

Type

OpenAI-compatible base URL

Good for

Pricing model

OpenRouter

Hosted router

https://openrouter.ai/api/v1

Hundreds of models, one key and bill, fallbacks

Provider price, no markup; 5.5% fee on credit purchases

Vercel AI Gateway

Hosted gateway

https://ai-gateway.vercel.sh/v1

Apps on Vercel; budgets per team, project, key or user

Provider list price, no markup; prepaid credits

Cloudflare AI Gateway

Hosted gateway

https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1

Caching, rate limits and analytics for OpenAI, Anthropic, Google, Mistral

Core features free; 5% fee on credits

Portkey

Hosted gateway, open-source core

https://api.portkey.ai/v1

Guardrails, retries, load balancing over your own keys

Free to 10k logs/month; $49/month tier

LiteLLM Proxy

Self-hosted proxy

http://localhost:4000 (your server)

No third-party gateway in the path; per-key budgets

Open source; you pay providers

Hugging Face Inference Providers

Hosted router, open-weight models

https://router.huggingface.co/v1

Open models served by Groq, Cerebras, Together and others

No markup on provider rates; PRO includes $2/month in credits

Together AI

Model host, open-weight models

https://api.together.ai/v1

Open models with tools, vision, structured output

Per 1M tokens

OpenAI

Vendor

https://api.openai.com/v1

The reference implementation

Per token

Anthropic

Vendor compatibility layer

https://api.anthropic.com/v1/

Testing Claude with existing OpenAI code

Per token

Google Gemini

Vendor compatibility layer (beta)

https://generativelanguage.googleapis.com/v1beta/openai/

Gemini from the OpenAI SDK

Per token

Mistral

Vendor

https://api.mistral.ai/v1

Mistral models; change only base URL and model

Per 1M tokens

How to choose

If you don't want an account with every vendor, OpenRouter, Vercel AI Gateway and Cloudflare's Unified Billing sell tokens at provider prices from one prepaid balance. When we checked (November 2026), OpenRouter's models API listed 349 distinct models, not counting aliases and :free or :batch variants, against 324 language models on Vercel's, so it is the pick when you want breadth. Vercel and Cloudflare make more sense when your app already runs on them.

If you already hold vendor keys, Portkey and LiteLLM sit in front of them. Portkey adds retries, fallbacks, load balancing and guardrails, and its free tier covers 10,000 recorded logs a month. LiteLLM tracks spend and sets budgets per virtual key, and it is the option when no third-party gateway may see your traffic.

Model IDs don't carry over between gateways. OpenRouter writes mistralai/mistral-large-4-0, Vercel writes mistral/mistral-large-4, Portkey uses @your-provider-slug/model, and LiteLLM uses whatever model_name you define. The Anthropic and Gemini compatibility layers are the weakest options for production: Anthropic describes its layer as a way to test and compare models, not a long-term or production-ready solution, and Google still labels its layer beta.

Self-hosted: one endpoint with LiteLLM

A LiteLLM config that exposes Claude, GPT and Mistral under short names:

model_list:
  - model_name: claude
    litellm_params:
      model: anthropic/claude-sonnet-5-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: gpt
    litellm_params:
      model: openai/gpt-6.1-sol
      api_key: os.environ/OPENAI_API_KEY
  - model_name: mistral
    litellm_params:
      model: mistral/mistral-large-latest
      api_key: os.environ/MISTRAL_API_KEY
docker run -v $(pwd)/litellm_config.yaml:/app/config.yaml \
  -e ANTHROPIC_API_KEY -e OPENAI_API_KEY -e MISTRAL_API_KEY \
  -e LITELLM_MASTER_KEY=sk-change-me \
  -p 4000:4000 docker.litellm.ai/berriai/litellm:latest --config /app/config.yaml

Clients then use base URL http://localhost:4000, API key sk-change-me and model claude, gpt or mistral. Without a database, LiteLLM does not enforce budgets.

What "OpenAI-compatible" means, and where it breaks

An OpenAI-compatible API accepts POST {base_url}/chat/completions with OpenAI's JSON body (model, messages with roles, optional tools and stream), authenticates with a Bearer token and returns the same choices[].message shape, or server-sent events when streaming. Plain chat requests work across every endpoint in the table once you change the base URL, key and model name. The differences sit at the edges:

  • Tool calling: Anthropic's layer ignores strict, so tool arguments aren't guaranteed to match your schema, and on recent models such as Claude Sonnet 5.5 a tool_choice of "required" or a named function returns a 400, so use "auto". On OpenRouter, 64 of the 349 distinct models didn't list tools in supported_parameters when we checked (November 2026), so check before pointing an agent at one.
  • Structured output: Anthropic's layer accepts response_format only as json_schema with strict: true; json_object and text return a 400. Together AI and Vercel AI Gateway document it as supported.

  • Streaming: OpenRouter sends keep-alive comment lines (: OPENROUTER PROCESSING). The SDKs skip them, but a hand-written SSE parser has to drop lines starting with : before parsing JSON. An error after the stream starts arrives as a chunk with finish_reason: "error" inside an HTTP 200.

  • Reasoning controls: there is no shared parameter. Anthropic's layer ignores reasoning_effort and takes a thinking object through extra_body; on Claude 5 models thinking is on by default. Gemini accepts reasoning_effort or its own thinking_level/thinking_budget, not both. OpenRouter uses a reasoning object with either effort or max_tokens.

  • Vision and files: Anthropic's layer reads image_url parts but rejects file and input_audio parts with a 400.

  • System prompts and sampling: Anthropic merges every system and developer message into one system prompt at the start, caps temperature at 1 (on Claude 4.7 and later models any value below 1 returns a 400, so leave it out) and requires n to be 1.

Write against the common subset (messages, streaming, tools without strict or a forced tool_choice) and keep vendor-specific parameters in extra_body, set per provider.

Using any OpenAI-compatible model in BrowseWiz

BrowseWiz is an AI side-panel assistant, a Chrome extension, and its custom models accept any model behind an OpenAI API-compatible chat completions endpoint. The form asks for the same values as the SDK:

  1. In the side panel, open the model menu and choose Add model at the bottom. It opens Options → Models.

  2. In the Custom OpenAI API-compatible Model Endpoints form, enter the Model Name exactly as the provider expects it in the request, for example anthropic/claude-sonnet-5.5 for OpenRouter.

  3. Enter the Endpoint Base URL, for example https://openrouter.ai/api/v1. BrowseWiz appends /chat/completions, so stop at /v1 here too.

  4. Paste the API Key (optional, for endpoints that need none). It's sent as the Bearer token and stored encrypted in the extension's local storage.

  5. Under Headers (optional), add any extra request headers, such as OpenRouter's HTTP-Referer and X-OpenRouter-Title: type a name and a value, then click +. A header added with the lock on is stored encrypted; with the lock off, in plain text.

  6. Click Add Endpoint. The model is then listed under Custom models in the model menu, where you pick it for a chat.

The Custom Models form in BrowseWiz's Options → Models, filled in for OpenRouter: Model Name anthropic/claude-sonnet-5.5, Endpoint Base URL https://openrouter.ai/api/v1, a masked API key and one added header, X-OpenRouter-Title

Each entry is one model. To use Claude, Mistral and Gemini models through OpenRouter, add one entry per model with the same base URL and key and a different model name. Direct vendor endpoints work the same way:

Provider

Base URL

Model name example

OpenRouter

https://openrouter.ai/api/v1

mistralai/mistral-large-4-0

Google Gemini

https://generativelanguage.googleapis.com/v1beta/openai/

gemini-3.8-flash

Mistral

https://api.mistral.ai/v1

mistral-large-latest

Anthropic

https://api.anthropic.com/v1/

claude-sonnet-5-5

Custom models answer chat only. The browser agent and its safety check, scheduled tasks and monitors run on BrowseWiz's own models and use your BrowseWiz credits, whatever model the chat uses. Every tool you have turned on is sent to the model, so for a model without tool calling, turn tools off in the Tools menu. The Models settings docs cover the form in full.

If you only need OpenAI models, the Bring Your Own Key field on the same page takes an OpenAI key directly. Without any key, the built-in BrowseWiz Chat model works on the free plan with limited usage. The settings page also takes custom API and webhook tools; our n8n invoice and receipt workflow walks through one.

FAQ

What is the OpenRouter API base URL?

https://openrouter.ai/api/v1. The chat completions endpoint is https://openrouter.ai/api/v1/chat/completions, authenticated with Authorization: Bearer <OPENROUTER_API_KEY>.

Is OpenRouter OpenAI compatible?

Yes. OpenRouter calls itself a drop-in replacement for OpenAI, and any SDK that lets you set a base URL works with it. OpenRouter-only options such as models, provider and reasoning go in extra_body when you use the OpenAI Python SDK.

Can I switch between Anthropic, OpenAI and Mistral with one API key?

Yes. OpenRouter and Vercel AI Gateway bill Claude, GPT and Mistral models against one key and one prepaid balance. Cloudflare AI Gateway routes all three, but its Unified Billing covers Claude and GPT, not Mistral, so Mistral needs your own Mistral key. Portkey and LiteLLM also give you one gateway key, but you store your own vendor keys behind it.

Should the base URL include /chat/completions?

No. The OpenAI SDKs and BrowseWiz both append /chat/completions to the base URL. Including it yourself doubles the path, and OpenRouter answers with a 404.

Is the Anthropic API OpenAI compatible?

Partly. Anthropic offers an OpenAI SDK compatibility layer at https://api.anthropic.com/v1/. It ignores reasoning_effort and the strict flag on tool schemas, accepts response_format only as json_schema with strict: true, and returns a 400 for other response formats and for file and input_audio parts. Anthropic describes the layer as meant for testing and comparing models, not as a long-term or production-ready solution. OpenRouter lists response_format, structured_outputs and reasoning as supported parameters for Claude 4.5 and later models, so it is the simpler path if you need those through the OpenAI format.

Tom's avatar

About Tom

I'm a software engineer and solutions architect specializing in AI-driven tools and productivity software, passionate about helping users reclaim their valuable time through intelligent automation.