OpenRouter API keys

How to get an OpenRouter API key

To get an OpenRouter API key, log in at openrouter.ai, open the API Keys page at openrouter.ai/settings/keys, click Create API Key, name it, pick a credit limit and copy the key, which starts with sk-or-v1-. A key OpenRouter created for you during onboarding has a $100 credit limit and expires after 180 days.

The key spends credits from your account balance, and buying credits carries a 5.5% fee ($0.80 minimum). OpenRouter recommends a credit limit on every key, because a key without one can spend your entire balance, auto top-ups included.

Create an OpenRouter API key, step by step

  1. Sign up or log in at OpenRouter.
  2. Open the API Keys page and click Create API Key.
  3. Give the key a name and choose a credit limit, or no limit. A limit can reset daily, weekly or monthly.
  4. Copy the key into a secrets manager.

Send the key as a Bearer token in the Authorization header. OpenRouter's SDK examples read it from OPENROUTER_API_KEY, and the OpenAI SDK works too once you set its base URL to https://openrouter.ai/api/v1. To test the key, ask OpenRouter about it:

export OPENROUTER_API_KEY="your-key-here"
curl https://openrouter.ai/api/v1/key -H "Authorization: Bearer $OPENROUTER_API_KEY"

GET /api/v1/key returns the key's credit limit, limit_remaining and its usage, so you can see what it has left before requests start failing.

API keys, workspace-owned keys and management keys

OpenRouter API keys do more than a key at a single model provider: each one can carry its own credit limit. OpenRouter has three kinds of key.

KeyWhat it doesCalls modelsWho creates it
API keyPays for model calls from your credits. Can have its own credit limit and an expirationYesYou. In an organization, any member
Workspace-owned API keyAn API key no person owns, for agents, CI jobs and services. Also called a system keyYesAn organization admin, with Owner set to Workspace
Management keyCreates, edits and deletes API keys, and manages budgets and workspace members. Can be read-onlyNoYou. In an organization, only Organization Admins

In an organization, members only see and manage the API keys they created, and usage from any organization key is billed to the organization's credit pool.

A workspace-owned key has no creator, so the guardrail budgets that cap members never apply to it. Give it a credit limit of its own.

You only need a management key to manage keys from code, for example to create and rotate them automatically. Create it on the Management API Keys page and copy it right away: you won't be able to see it again. A leaked one can create, edit and delete your API keys, so set an expiration when you create it. You can't change that date later.

Where your key lives

Your API keys are listed on the API Keys page at openrouter.ai/settings/keys. That's where you raise a key's limit or delete it, and the Activity page breaks usage down by model, provider and key.

Copy a new key the moment it's shown. If you no longer have it, create a new key, switch your app over and delete the old one.

Key not working? A 402 or 403 usually means a spending limit: your account balance, the key's own credit limit, or a budget an org admin set. error.metadata in the response says which one. A negative account balance can cause 402 errors even on free models.

Credits, fees and the free tier

Creating a key is free. Model calls spend credits from your balance, priced in US dollars. OpenRouter passes through the model providers' prices without markup and charges a 5.5% fee ($0.80 minimum) when you buy credits. Crypto payments carry a 5% fee. You can top up by hand or turn on auto top-up, which refills the balance when it drops below a threshold you set.

Under its terms, OpenRouter may expire unused credits one year after purchase. You can ask for a refund of unused credits within 24 hours of buying them, but the platform fee isn't refunded.

New users get a small free allowance. Free models are limited to 50 requests per day, or 1000 per day once you've bought at least 10 credits. Fees and prices in more detail are in OpenRouter pricing.

Cap what the key can spend

A key's credit limit is its own hard cap. Once the key has used it, requests with it are rejected until you raise the limit on the key's page, or, for a daily, weekly or monthly limit, until it resets. Reset windows run on UTC, and weeks start on Monday.

Set one on every key. Without it, a leaked key or a runaway agent can spend your whole balance, including auto top-ups. For a team, put its keys in one workspace and add a workspace budget: every key in the workspace then draws from the same pooled limit.

The steps and API fields are in How to set a credit limit on an OpenRouter API key.

Keep the key out of code, git and browsers

  • Keep the key in an environment variable or a secrets manager, not in your codebase.
  • Never commit it to a repository.
  • Keep it out of client-side code, such as web pages and mobile apps. Call OpenRouter from your server.
  • Give each app and agent its own key with its own credit limit, so one leak doesn't drain everything.
  • Short-lived keys for single jobs? Set expires_at when you create them through the API.

OpenRouter is a GitHub secret scanning partner and has other ways to detect exposed keys. If it decides your key is compromised, you get an email. Then, or whenever you suspect a leak, delete the key on the API Keys page and create a new one. The first hour after a key leaks covers what else to check.

Watch what the key spends

A credit limit stops spend at a ceiling. Costbrake reads OpenRouter key usage and activity and alerts on a spike: an hour that costs more than 3x your usual hour and at least $5 more.

Connect a read-only management key to watch every key in the account, or one API key to watch only its own spend. Spend comes from the dollar counters OpenRouter keeps per key. If you connect an API key with no credit limit, Costbrake tells you to set one. On Pro and Team it checks every 5 minutes, and every minute during a spike. Free checks hourly. Setup steps are on the OpenRouter integration page.

Pro and Team can add brakes, which use a second management key with write access. One disables an API key, so every request with it fails right away. The other sets the key's credit limit to $0: paid requests fail, free models keep working. Undo restores the key or its previous limit. A brake never fires on its own: an admin clicks it and confirms. Plans are on the pricing page, and new workspaces get a 14-day Pro trial with no card.

Questions and answers

Is an OpenRouter API key free?

Creating a key is free. Paid models spend credits from your balance, and OpenRouter charges a 5.5% fee ($0.80 minimum) when you buy them. Free models cost nothing but are limited to 50 requests per day, or 1000 per day once you've bought at least 10 credits.

Where do I find my OpenRouter API key again?

Your keys are listed on the API Keys page at openrouter.ai/settings/keys. Copy a new key into a secrets manager as soon as it's shown. If you no longer have it, create a new key, switch your app over and delete the old one.

Why is my OpenRouter API key not working?

Check that you send it as a Bearer token in the Authorization header. A 402 or 403 usually means a spending limit: your account balance, the key's own credit limit, or a budget an org admin set, and error.metadata says which. GET /api/v1/key shows what the key has left in limit_remaining.

How do I limit what an OpenRouter API key can spend?

Give the key a credit limit on the API Keys page, either a one-off cap or one that resets daily, weekly or monthly. Once the key has used it, requests with it are rejected until you raise the limit or it resets. OpenRouter recommends a limit on every key.

What should I do if my OpenRouter API key leaks?

Delete the key on the API Keys page at openrouter.ai/settings/keys and create a new one. OpenRouter is a GitHub secret scanning partner and emails you when it finds a compromised key. A credit limit on every key keeps what a leaked key can spend small.

Sources

Updated