curl or the OpenAI SDK directly with OpenRouter.
Accepted credentials
Send one credential per request in theAuthorization header as Bearer <credential>. For clients built on the Anthropic SDK, you can also send an API key (not an access token) in the x-api-key header. OpenRouter accepts the following credential types:
Send the credential exactly as issued, with no extra whitespace or quotes. OpenRouter treats a bearer that starts with
sk-or-v1- as an API key. It treats a JWT as an access token only when its issuer is https://openrouter.ai or https://clerk.openrouter.ai, and rejects any other bearer. OpenRouter also rejects an expired JWT and a JWT without the scope the endpoint requires. Some endpoints accept only an API key, so an access token with the inference scope doesn’t replace an API key everywhere. To use a token from your own identity provider, exchange it for an OpenRouter access token first; OpenRouter doesn’t accept third-party JWTs directly.
Using an API key
To use an API key, first create your key. Give it a name and choose a credit limit (or no limit). Once a key has used its credit limit, requests with it are rejected until you raise the limit on the key’s page, or, for a daily, weekly, or monthly limit, until the limit resets. Keys created for you during onboarding get a $100 credit limit and expire after 180 days. If you’re calling the OpenRouter API directly, set theAuthorization header to a Bearer token with your API key.
If you’re using the OpenAI Typescript SDK, set the api_base to https://openrouter.ai/api/v1 and the apiKey to your API key.