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. Change the model string to openai/gpt-6-sol or mistralai/mistral-medium-3-5 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 September 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

API keys

openrouter.ai/settings/keys

The optional headers only attribute your app: HTTP-Referer is your site URL, X-OpenRouter-Title is the name shown in OpenRouter's rankings, 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",
    "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",
    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-sol, anthropic/claude-sonnet-5 and mistralai/mistral-medium-3-5 (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-sol", "anthropic/claude-sonnet-5", "mistralai/mistral-medium-3-5"]:
    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 on rate limits, 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 passes provider prices through with no markup on inference and takes a 5.5% fee (minimum $0.80) when you buy credits by card, or 5% for crypto.

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

As of September 2026, OpenRouter, Vercel AI Gateway, Portkey and the self-hosted LiteLLM Proxy each put Anthropic, OpenAI and Mistral models behind one OpenAI-compatible endpoint. Cloudflare AI Gateway's current endpoint does the same for Anthropic, OpenAI and Google. For Mistral it offers only open-weight models on Workers AI; Mistral's own API needs the older /compat endpoint, which Cloudflare now deprecates for single-model calls. 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% card top-up fee

Vercel AI Gateway

Hosted gateway

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

Apps on Vercel; budgets per project, key or member

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

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; free tier

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

Free tier, then 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 (September 2026), OpenRouter's models API listed 356 distinct models, not counting aliases and :free or :batch variants, against 265 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-medium-3-5, Vercel writes mistral/mistral-medium-3.5, 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 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
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: gpt
    litellm_params:
      model: openai/gpt-6-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. On OpenRouter, 67 of the 356 distinct models didn't list tools in supported_parameters when we checked (September 2026), so check before pointing an agent at one.

  • Structured output: Anthropic's layer ignores response_format. 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. 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 drops file and input_audio parts.

  • System prompts and sampling: Anthropic merges every system and developer message into one system prompt at the start, caps temperature at 1 and requires n to be 1.

Write against the common subset (messages, streaming, tools without strict) 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 for Chrome and Edge, and its Custom Models setting accepts any model that exposes an OpenAI API-compatible chat completions endpoint. It asks for the same three values as the SDK:

  1. Open the BrowseWiz settings page (the account icon in the bottom-right corner of the side panel opens it) and go to Models.

  2. In the OpenAI API-compatible endpoints section, enter the model name exactly as the provider expects it in the request, for example anthropic/claude-sonnet-5 for OpenRouter.

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

  4. Paste the API key. BrowseWiz encrypts it and keeps it in the extension's local storage.

Each entry is one model. To use Claude, GPT and Mistral through OpenRouter, add three entries with the same base URL and key and different model names. Direct vendor endpoints work the same way:

Provider

Base URL

Model name example

OpenRouter

https://openrouter.ai/api/v1

mistralai/mistral-medium-3-5

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

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 does the same for Claude and GPT, but not for Mistral's API. 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/, but ignores parameters such as response_format, reasoning_effort and strict tool schemas, and describes the layer as meant for testing and comparing models. 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.