# OpenRouter API key: how to get one, cap it and rotate it

> The key is free and shown only once; free models allow 20 requests a minute and 50 a day, or 1,000 a day after $10 in credits.

URL: https://claudegpt.si/news/openrouter-api-key  
Published: 2026-11-21T23:00:45.970Z  
Author: ClaudeGPT Si Newsroom  
Section: Guides  
Topics: OpenRouter, API keys, How to, Security  
Publisher: ClaudeGPT Si

## Key takeaways

- You create an OpenRouter API key on openrouter.ai/keys with a name, a credit limit and an expiry, and the full key can't be retrieved after it is created.
- Creating a key is free, and free models allow 20 requests a minute and 50 a day, or 1,000 a day once you have bought $10 of credits.
- If a key leaks, OpenRouter says to delete it in key settings and create a new one, and its rotation guide adds the new key before removing the old.

To get an OpenRouter API key, sign in at openrouter.ai, open the [API keys page](https://openrouter.ai/keys), give the key a name and pick a credit limit. The key is free to create, and with it you can call free models at 20 requests a minute and 50 a day. Paid models need credits.

Below are the steps in order: creating the key, copying it safely, capping what it can spend, making a first request with curl, what's free, and what to do if the key leaks. Everything comes from [OpenRouter's documentation](https://openrouter.ai/docs/api-reference/authentication) as of November 21, 2026. No request was sent to the API while writing this.

## What you need first

- An OpenRouter account. The [FAQ](https://openrouter.ai/docs/faq) says you start by creating an account and adding credits on the [Credits page](https://openrouter.ai/settings/credits). Credits are prepaid dollars that OpenRouter spends as you make requests.
- For free models only, you can skip the credits. New users get "a small free allowance" to test with, according to the FAQ.
- A terminal with `curl` for the first request.

## How to create an OpenRouter API key

1. Sign in and go to [openrouter.ai/keys](https://openrouter.ai/keys).
2. Create a new key and give it a name you will recognize later, such as the app or machine that will use it.
3. Choose a credit limit, or no limit. OpenRouter recommends a limit on every key (see below).
4. Choose an expiration date. You cannot change it later.
5. Create the key and copy it right away.

An OpenRouter API key starts with `sk-or-v1-`, followed by 64 lowercase hexadecimal characters: 73 characters in all. If the key you copied looks different, it is not an OpenRouter API key.

Organization admins can also create a key owned by a workspace instead of a person, by picking **Workspace** under **Owner** in the same dialog. OpenRouter suggests this for keys that agents and CI jobs share, because a key with no person behind it is not covered by member budgets ([capping shared agent keys](https://openrouter.ai/docs/guides/best-practices/capping-shared-agent-keys)).

## How to copy your OpenRouter API key (it is shown once)

Copy the key the moment it appears and put it straight into a password manager or secrets store. OpenRouter's API reference says the full key is returned "only in this response" when it is created and "cannot be retrieved later". The dashboard steps for management keys say the same thing: "You will not be able to see it again." Afterwards, OpenRouter only shows a shortened label for the key.

If you lose a key, you can't recover it. Create a new one and delete the old one.

Two copy mistakes cause most login errors, according to the [authentication docs](https://openrouter.ai/docs/api-reference/authentication):

- Invisible characters picked up while pasting give the error `Malformed authentication credential`.
- Extra spaces or quotes in the header give `Missing Authentication header`. Send exactly `Authorization: Bearer <key>`, with one space and no quotes.

Keep the key out of your code. Store it in an environment variable:

```bash
export OPENROUTER_API_KEY="sk-or-v1-..."
```

## How to set a credit limit and expiry on the key

A credit limit caps what the key can spend. OpenRouter's warning is direct: a key with no limit lets "a leaked key or a runaway agent spend your entire balance, including any auto top-ups."

A key's limit has three settings, shown under **Key limit** in the key dialog:

| Setting | What it does |
| --- | --- |
| Credit limit | The cap in US dollars |
| Reset interval | Daily, weekly or monthly, resetting at midnight UTC (weeks run Monday to Sunday). Leave it unset for a lifetime cap |
| Include BYOK usage in limit | Counts spend on your own provider keys toward the cap. Off by default, and only shown once you have added provider keys |

When a key reaches its limit, requests fail with `403 Forbidden` and `Key limit exceeded` until the limit resets or you raise it on the key's page. You can add a limit to an existing key from the [Security settings](https://openrouter.ai/settings/security) page with **Set limit**.

Expiry works differently. The [security settings docs](https://openrouter.ai/docs/guides/overview/auth/security-settings) say you can't change the expiration of an existing key. To add one, create a new key with an expiration, move your apps to it, and disable or archive the old key. After the date passes, every request with the key fails with `401` and `API key expired`.

Account owners and organization admins can also set a maximum key lifetime in [privacy settings](https://openrouter.ai/settings/privacy). OpenRouter then rejects requests from keys that never expire or that expire later than the maximum, including keys that already exist. The Security settings page flags keys with no limit, no expiry, a limit of $1,000 or more, or an expiry more than 365 days out.

Keys that OpenRouter creates for you during onboarding already come with a $100 credit limit and expire after 180 days.

## How to make a first request with your OpenRouter API key

OpenRouter's API is compatible with OpenAI's. The base URL is `https://openrouter.ai/api/v1`, and the [compatibility page](https://openrouter.ai/docs/guides/features/compatibility) lists the Chat Completions endpoint at `/chat/completions`. This request uses `openrouter/free`, the [Free Models Router](https://openrouter.ai/docs/guides/routing/routers/free-router), which picks a free model at random, so it costs nothing:

```bash
curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openrouter/free",
    "messages": [{ "role": "user", "content": "Say this is a test" }]
  }'
```

The answer comes back in `choices[0].message.content`. To pick a model yourself, use its full ID with the maker's prefix, such as `openai/gpt-5.2`. A bare name like `gpt-5.2` doesn't work. The [quickstart](https://openrouter.ai/docs/quickstart) uses OpenAI's newer Responses format at `/api/v1/responses` instead, and both endpoints take the same key.

To check the key itself, including its limit, what it has left and its free-model count for the day, call:

```bash
curl https://openrouter.ai/api/v1/key \
  -H "Authorization: Bearer $OPENROUTER_API_KEY"
```

With the OpenAI Python or TypeScript SDK, set the base URL to `https://openrouter.ai/api/v1` and pass the key explicitly. OpenRouter warns about a trap here: if the variable you pass is empty, both SDKs quietly fall back to `OPENAI_API_KEY`, send your OpenAI key to OpenRouter, and get `401 Invalid API key: this is not an OpenRouter API key`.

## Is an OpenRouter API key free?

Creating a key costs nothing. What you pay for is what the key does.

Free models, the ones whose ID ends in `:free`, cost nothing. The [limits page](https://openrouter.ai/docs/api-reference/limits) caps them by how many credits you have ever bought:

| Credits purchased (all time) | Free requests per minute | Free requests per day |
| --- | --- | --- |
| Less than $10 | 20 | 50 |
| $10 or more | 20 | 1,000 |

Some details that catch people out:

- More keys or more accounts don't raise these limits, because OpenRouter counts capacity globally.
- A negative credit balance can block free models too, until you top up.
- If you list a `:free` model in a fallback list with paid models and the free one is busy, the paid fallback is billed. `openrouter/free` falls back only to other free models.
- The FAQ calls free models "usually not suitable for production use."

Paid models are billed at the provider's price with no markup, according to the FAQ. OpenRouter makes its money on a 5.5% fee when you buy credits, with a $0.80 minimum, and 5% for crypto. Refunds of unused credits are possible within 24 hours of buying them, and OpenRouter's terms let it expire unused credits a year after purchase. For how that compares with running your own gateway, see [OpenRouter vs LiteLLM](https://claudegpt.si/news/openrouter-vs-litellm).

## How to rotate or delete an OpenRouter API key if it leaked

OpenRouter is a GitHub secret scanning partner and has other ways to spot exposed keys. If it finds yours, it emails you. Whether you get that email or only suspect a leak, the docs say to go to [your key settings](https://openrouter.ai/settings/keys) straight away, delete the key and create a new one.

To swap a key without downtime, the [rotation guide](https://openrouter.ai/docs/cookbook/administration/api-key-rotation) gives three steps:

1. Create a new key, with a credit limit and an expiry.
2. Put it everywhere the old one was used: environment variables, your secrets manager, CI variables. Both keys work during the switch.
3. Check the new key works in production, then delete the old one.

On the Security settings page, **Disable** stops a key and can be undone. **Archive** is permanent and asks you to type `archive` to confirm. For a leaked key, delete or archive it.

Teams that rotate often can script it with a [management key](https://openrouter.ai/docs/guides/overview/auth/management-api-keys), a separate kind of key that manages other keys but can't call models. `POST /api/v1/keys` creates a key and `DELETE /api/v1/keys/{hash}` deletes one. Management keys can do a lot of damage if they leak, so OpenRouter recommends an expiry on each of them too.

A leaked key is not the only thing to rotate. On November 21, 2026, OpenRouter told customers that requests they sent to MiniMax models may have been read, Ars Technica reported. The background is in [the AI router canary test story](https://claudegpt.si/news/ai-router-canary-credentials-leak). If your prompts held other secrets, such as cloud credentials or tokens, rotate those as well.

## Common problems

- **401 `Invalid API key` or `User not found.`** The key was deleted, disabled or never existed. Check it on the API keys page or make a new one.
- **401 `No API key in the Authorization header`.** The environment variable is empty. Set it and restart the shell or app.
- **401 `API key expired`.** Create a new key. Expiry can't be extended.
- **403 `Key limit exceeded`.** Raise the key's limit or wait for its reset.
- **429 on free models.** You hit the 20-a-minute or daily cap. Buying $10 of credits raises the daily cap to 1,000.

## Frequently asked questions

### How do I get an OpenRouter API key?

Sign in at openrouter.ai, open openrouter.ai/keys, create a key with a name and a credit limit, and copy it. It starts with sk-or-v1- and is 73 characters long.

### Can I see my OpenRouter API key again after creating it?

No. OpenRouter's docs say the full key is returned only when it is created and can't be retrieved later. If you lose it, create a new key and delete the old one.

### Is an OpenRouter API key free?

Yes, creating one costs nothing. Free models are capped at 20 requests a minute and 50 a day, or 1,000 a day after buying $10 of credits; paid models are billed from prepaid credits, with a 5.5% fee on credit purchases.

### Can I change the expiration of an OpenRouter API key?

No. The expiration is fixed when the key is created. To change it, create a new key with the expiry you want, move your apps to it and remove the old key.

## Sources

- [Authentication](https://openrouter.ai/docs/api-reference/authentication), OpenRouter
- [Quickstart](https://openrouter.ai/docs/quickstart), OpenRouter
- [Limits](https://openrouter.ai/docs/api-reference/limits), OpenRouter
- [FAQ](https://openrouter.ai/docs/faq), OpenRouter
- [Create a new API key](https://openrouter.ai/docs/api/api-reference/api-keys/create-a-new-api-key), OpenRouter
- [Management API keys](https://openrouter.ai/docs/guides/overview/auth/management-api-keys), OpenRouter
- [Security settings](https://openrouter.ai/docs/guides/overview/auth/security-settings), OpenRouter
- [Capping shared agent keys](https://openrouter.ai/docs/guides/best-practices/capping-shared-agent-keys), OpenRouter
- [API key rotation](https://openrouter.ai/docs/cookbook/administration/api-key-rotation), OpenRouter
- [OpenAI compatibility](https://openrouter.ai/docs/guides/features/compatibility), OpenRouter
- [Free Models Router](https://openrouter.ai/docs/guides/routing/routers/free-router), OpenRouter
- [Free variant](https://openrouter.ai/docs/guides/routing/model-variants/free), OpenRouter
