Authentication & API keys
Send your key as a bearer token, limit keys with a budget, a model list and an expiry date, and revoke a key that leaked.
La documentación está en inglés.
Every request needs an API key, except GET /v1/models. Keys belong to your organization: all of its keys spend from the same balance.
Send the key
Send the key as a bearer token in the Authorization header:
Authorization: Bearer nr-v1-…The gateway also accepts the key in the x-api-key header, which is what the Anthropic SDK sends. Both work on every endpoint. When a request has both, the Authorization header wins.
A key is nr-v1- followed by 48 hexadecimal characters. A request without a key fails with 401 missing_api_key; an unknown or revoked key with 401 invalid_api_key.
Create a key
Owners, admins and developers of an organization can create keys on API keys. The full key is shown once. We store only a SHA-256 hash of it, so nobody can show it to you again, not even us. Lost a key? Revoke it and create a new one.
Each key has optional limits:
| Setting | What it does |
|---|---|
| Name | A label for you, up to 80 characters. It appears in Usage and in GET /v1/key. |
| Budget | A spending cap in US dollars, from $0.01. It counts everything the key has spent since it was created and does not reset each month. Once spend reaches the budget, requests fail with 402 key_budget_exceeded. You can raise or remove it at any time. |
| Models | Limit the key to a list of model IDs. A base ID such as openai/gpt-6-astra allows both lanes; openai/gpt-6-astra:eco allows only the Eco lane. Other models fail with 403 model_not_allowed. No list means every model. |
| Expires | The key works until the end of that day (UTC), then fails with 401 api_key_expired. Up to five years ahead. |
The budget is checked before each request. The cost is only known once the answer is complete, so the last request can take a key slightly past its budget.
Check a key from code
GET /v1/key returns the name, budget, spend, rate limit, allowed models and expiry date of the key you call it with. It is a quick way to test a key.
curl https://api.nexrouting.com/v1/key \ -H "Authorization: Bearer $NEXROUTING_API_KEY"Revoke a key
Revoke a key on API keys. The gateway looks up the key on every request, so a revoked key fails with 401 invalid_api_key from the next request on. Revoking can't be undone. It also works while your account is suspended.
If a key leaks
Anyone who has your key can spend your balance, within that key's budget and model list, until you revoke it. If a key may be exposed (pushed to a public repository, pasted in a chat, written to a log):
- Revoke it on API keys.
- Create a new key and update the apps that used the old one.
- Open Usage, filter on the old key and look for requests you don't recognise.
- Spend that wasn't yours? Contact support with the times or request IDs.
Limit the damage before it happens: give each app its own key with a budget and only the models it needs, and put an expiry date on keys for tests and demos. The fixed nr-v1- prefix makes keys easy to catch with a secret scanner in your own repositories and CI.
Keys in the browser
The API sends CORS headers (access-control-allow-origin: *), so it can be called from a web page. Only do that with a key that belongs to the person using the page. Never put your own key in front-end code: anyone can read it there.