API keys · Guide
How to get an OpenRouter API key
An OpenRouter API key gives you one key for hundreds of models from many providers, including free models you can use without buying credits. Here’s how to create one, what the free allowance really is, and how to keep the key safe.
- Free requests
- 50 a day
- After $10 of credits
- 1,000 a day
- Card fee
- 5.5%, $0.80 min
- Key starts with
- sk-or-v1-
Steps
Get your key
- Create an account at openrouter.ai.
- Open the API keys page in your settings and create a key.
- Give the key a name and choose a credit limit (or no limit). OpenRouter recommends a limit on every key, so a leaked key or a runaway agent can’t spend your whole balance. You can also set an expiry date, which can’t be changed later.
- Copy the key. It starts with
sk-or-v1-; store it somewhere safe, such as a password manager. - Paste it into the box on this page to check it works and see its credit limit and today’s free-model requests.
- To use paid models, add credits on the Credits page. Free models work without them.
Source: OpenRouter’s API authentication documentation.
Test your key
Your key goes from your browser straight to OpenRouter, never to this site, and isn’t saved. Checking several keys or providers? Use the API key checker.
Free models
Free models, credits and limits
Models whose IDs end in :free cost nothing. You can browse them with the free filter on OpenRouter’s models page, or send requests to openrouter/free, which picks a free model for you. OpenRouter’s FAQ says free models have low rate limits and are “usually not suitable for production use”.
- Rate limits on free models: 20 requests a minute. Accounts that have bought less than 10 credits get 50 requests a day; at least 10 credits raises that to 1,000 a day (OpenRouter starts the higher limit at 9 credits to absorb rounding and fees). Extra accounts or keys don’t raise the limits.
- Credits are US dollars. Buying them with a card costs a 5.5% fee ($0.80 minimum); crypto costs 5%. OpenRouter says it adds no markup to model prices, and may expire unused credits a year after purchase.
- A negative balance blocks everything. OpenRouter can return a 402 error when your balance is below zero, including for free models.
- Your data: OpenRouter has separate training settings for paid and free models in its privacy settings. If you opt out of training, it won’t route your requests to providers that train on data. Check this before sending anything private.
Use it
Call the API with your key
Save the key as an environment variable called OPENROUTER_API_KEY, the name OpenRouter’s own examples use. The API follows OpenAI’s chat completions format, so most OpenAI-compatible tools work with OpenRouter’s base URL, https://openrouter.ai/api/v1, and your key in the Authorization header:
curl https://openrouter.ai/api/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-d '{
"model": "openrouter/free",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}'This is OpenRouter’s quickstart request with the model set to openrouter/free, its free models router, so it costs nothing. Swap in any model ID from the models page, and compare paid models’ prices in our AI model comparison.
Security
Keep your key safe
- Set a credit limit and an expiry date on every key; OpenRouter’s security settings flag keys that lack either.
- Keep keys in environment variables, never in code you commit or publish.
- Don’t put a key inside a website or app you ship to users; call OpenRouter from your own backend.
- OpenRouter is a GitHub secret scanning partner and emails you if it finds your key exposed. If that happens, delete the key in your key settings and create a new one.
FAQ
Frequently asked questions
Is an OpenRouter API key free?
Yes. Creating a key costs nothing, and models whose IDs end in :free can be used within a free allowance of 20 requests a minute and 50 a day. Paid models need credits, which are US dollars bought with a 5.5% fee ($0.80 minimum) on card payments. OpenRouter says it adds no markup to model prices.
How many free requests does OpenRouter give you?
Free models are limited to 20 requests a minute. Accounts that have bought less than 10 credits get 50 requests a day; buying at least 10 credits raises the daily limit to 1,000. Creating more accounts or keys doesn’t change the limits. The API key checker shows how many free-model requests your key has used today.
Do I need to add credits to use OpenRouter?
Not for free models: OpenRouter’s limits table covers accounts that have bought fewer than 10 credits, including none, at 50 free requests a day. You need credits for any paid model, and buying at least 10 credits also raises your free-model limit to 1,000 requests a day.
Why does OpenRouter return a 402 error?
A 402 means your account or this key doesn’t have enough credits for the request. That happens when the key has reached its credit limit, your balance has run out, or your balance is negative, which OpenRouter says can block even free models. Raise the key’s limit in its settings or add credits. A 402 with the reason in_flight_budget_exhausted is different: it’s temporary, and you retry after the Retry-After header.
Do OpenRouter’s free models train on my data?
It depends on the provider behind each model. OpenRouter has separate training settings for free and paid models in its privacy settings, and if you opt out, it won’t route your requests to providers that train on data. Check those settings, and don’t send confidential data to a model whose provider policy you haven’t read.
What does an OpenRouter API key look like?
OpenRouter documents its key format as sk-or-v1- followed by 64 lowercase hexadecimal characters. If your key starts with something else, it probably came from another provider. The checker on this page warns you before sending a key that looks like another company’s.
What should I do if my OpenRouter key leaks?
Delete it on the API keys page in your settings straight away and create a new one. OpenRouter is a GitHub secret scanning partner and emails you if it finds your key exposed, but don’t rely on that. A credit limit on every key caps how much a leaked key can spend.
Related