Authentication
Create, restrict, and rotate AnyRouter API keys, and use your own provider keys.
Send Authorization: Bearer <key> on every request. One AnyRouter key (prefix sk-ar-v1-) reaches every model; you never send an upstream provider key.
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer sk-ar-your-key" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-5.4-mini", "messages": [{"role": "user", "content": "hi"}]}'The Anthropic passthrough at /api/v1/messages accepts x-api-key instead. See the Messages API reference.
Create a key
In the API Keys dashboard, click Create key. The full key is shown once; store it in a secret manager. Never commit it to git.
| Setting | Purpose |
|---|---|
allowed_models | Limit the key to listed model ids. anyrouter/auto and anyrouter/free then route only within the listed models. |
allowed_endpoints | Limit the key to specific API paths. Dashboard keys grant inference endpoints; management endpoints (keys, credits, logs, usage) are off until you enable them in Permissions. Chat Completions, Messages, and Responses are one grant. |
rate_limit | Requests per minute for the key. |
limit + limit_reset | Credit cap per daily, weekly, or monthly cycle. |
expires_at | Hard expiry, ISO 8601. |
Unset fields inherit the account defaults. Use a separate key per environment.
Rotate a key
Rotation has no downtime and needs nothing from upstream providers.
- Create a replacement key with the same restrictions.
- Deploy it.
- Confirm traffic moved in the usage dashboard.
- Delete the old key.
BYOK (bring your own key)
Attach provider credentials under Dashboard → BYOK to pay providers directly. BYOK requests bill to your upstream account and are reported separately from AnyRouter credits.
Some providers show a Base URL field for a custom endpoint, such as a private OpenAI-compatible gateway. Microsoft Foundry has its own resource-endpoint field (see Azure). Preconfigured Gateway routes (OpenRouter, DeepSeek, xAI, Z.ai Standard/Coding Plan) use their listed route and ignore a base URL override.
Troubleshooting
| Symptom | Fix |
|---|---|
401 Unauthorized | Check the key starts with sk-ar- and is sent as Authorization: Bearer <key> (x-api-key on /messages). If it was deleted or expired, create a new one. |
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer