How to use OpenRouter, from chat to code
Use OpenRouter on its chat page, inside apps like Cursor and Claude Code, or from your own code, plus the routing settings that keep requests cheap and running.

On this page
Once you have a key, there are three ways to use OpenRouter. You can chat with models on its website, plug the key into an app you already use, or call it from your own code. The routing settings on top are where it starts to pay for itself.
You’ll need an account and a key first. Our API key guide covers that in two minutes, and the OpenRouter explainer covers what it costs.
Chat with models on the website
The quickest start is openrouter.ai/chat. Add one model or several, send the same message to each, and read the answers side by side. Press Cmd+K (Ctrl+K on Windows) to add a model.
Chat draws on the same credits as the API. Free models work too. Search for “free” when you add a model, or pick the Free Models Router. OpenRouter stores your chats locally on your device, so they don’t follow you to another computer, though you can export them from the chat settings.
This is the best place to choose a model before you commit to it. Send your real prompt to three candidates and keep the one whose answer you’d actually use.
Use it inside apps you already have
Most AI tools that accept an OpenAI-style endpoint can use OpenRouter. The pattern is always the same. Set the base URL to https://openrouter.ai/api/v1, paste your sk-or- key, and pick a model ID in provider/model form, like anthropic/claude-sonnet-5.5.
OpenRouter publishes setup guides for Cursor, Claude Code, Codex CLI, OpenCode, Xcode and Zapier, and for frameworks like LangChain, Mastra and PydanticAI. A few of those break the pattern, so check them before you start.
- Cursor needs
https://openrouter.ai/api/v1/cursoras its base URL, not the usual one. - Claude Code points at
https://openrouter.ai/api, and OpenRouter says it’s only guaranteed to work when the request goes to Anthropic itself as the provider. - Xcode also uses
https://openrouter.ai/api, without the/v1.
Call it from your own code
If you’ve used OpenAI’s SDK, you already know OpenRouter’s API. Change the base URL and the key, and keep the rest.
from openai import OpenAI
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="<OPENROUTER_API_KEY>",
)
reply = client.chat.completions.create(
model="anthropic/claude-sonnet-5.5",
messages=[{"role": "user", "content": "Summarize this in two lines"}],
)
print(reply.choices[0].message.content)
OpenRouter also has its own SDKs, @openrouter/sdk for TypeScript and openrouter for Python, and a provider for Vercel’s AI SDK, @openrouter/ai-sdk-provider. That last one is what our extension uses.
Two details save time. Model IDs follow author/slug, and copying the slug from the model’s page is the easy way to get it right. There are also “latest” aliases like ~openai/gpt-sol-latest, which always resolve to the newest model in that family. Every response carries a usage block, including cost, the amount OpenRouter charged for that request.
Pick a routing setting
This is the part most guides skip. The same model is often served by several providers at different prices and speeds, and you get to choose how OpenRouter picks between them.
Suffixes
Suffixes are the simplest switch. Add one to the end of a model ID.
:nitrosorts providers by speed. It can also use a provider’s priority tier, billed at that tier’s higher rate.:floorsorts by price, and can use cheaper flex tiers.:exactofavors providers with reliable tool calling.:freepicks the free variant, if there is one, with its daily caps.
Two older suffixes, :online and :thinking, are deprecated. Web search is now a separate server tool, and reasoning has its own parameter.
Fallbacks
Fallbacks keep a request alive when a model fails. Pass a models list in priority order and OpenRouter tries the next one on errors, rate limits or downtime. You pay for whichever model answered, and the response tells you which.
Provider preferences
Provider preferences go in a provider object. Sort by price, throughput or latency, set data_collection to "deny" to skip providers that keep your data, or turn on zdr for zero-data-retention endpoints only. A max_price cap is there too.
{
"models": ["anthropic/claude-sonnet-5.5", "openai/gpt-6.1-sol"],
"provider": { "sort": "throughput", "data_collection": "deny" },
"messages": [{ "role": "user", "content": "Summarize this page" }]
}
Auto Router and presets
openrouter/auto picks a model for you, steered by what OpenRouter’s users spend on each kind of task over the past week, at no extra fee. Presets save a model, routing rules and a system prompt under a name, so your code can just ask for @preset/your-name.
Using OpenRouter in your browser
UtilEngine, our extension for Chrome, Brave and Edge, is one more place for the key. Open AI Settings and paste it. Add credits first, because UtilEngine checks the key with one tiny request to a paid model. After that, Ask AI and Chat work on any page, with 85 models to pick per conversation and a different one per AI command.
Routing is already set. UtilEngine requests most models with :nitro for speed, which can bill a faster endpoint’s higher rate. The default model, GLM 5.3 Flash, skips it and uses OpenRouter’s default routing. UtilEngine is $49 once, and OpenRouter bills the tokens. The bring-your-own-key page has the details.
Common questions
Do I need to write code to use OpenRouter?
No. The chat page works in a browser, and many apps take an OpenRouter key in their settings. Code is only one of the three routes.
Is the OpenRouter chat page free?
It uses your credits like the API does. Free models work there too, within their daily request caps.
Why did my request use a different model than I asked for?
You probably used fallbacks, the Auto Router or a “latest” alias. The model field in the response names the model that actually answered, and that’s the one you’re billed for.
Can I stop providers from keeping my prompts?
Partly. Set data_collection to "deny" or turn on zdr in the provider object, and check the privacy settings in your OpenRouter account. Both narrow which providers can serve your requests.
What’s the cheapest way to try several models?
The chat page. Send one prompt to a few models side by side, compare the answers, and check each model’s price per million tokens on its page before you pick a default.