Authentication
primerouter uses Bearer token authentication, fully compatible with OpenAI / Anthropic API.
Bearer token
http
Authorization: Bearer sk-your-keyUsed by: all /v1/... endpoints.
Anthropic style
http
x-api-key: sk-your-key
anthropic-version: 2023-06-01Used by: /v1/messages. The Claude SDK uses this by default.
Get a key
- Log in at primerouter.ai
- Console → Tokens (details)
- After saving, copy the
sk-...string — shown only once
Token attributes
Each key supports:
| Attribute | Default | Description |
|---|---|---|
| Expiry | Never | After expiry, calls return 401 |
| Quota cap | Use account balance | Set explicit cap to isolate cost |
| Model restriction | All | Only allowlisted models can be called |
| IP allowlist | Open | CIDR supported |
| Group | Default group | Affects pricing multiplier |
Error states
| HTTP | Meaning |
|---|---|
401 | Key invalid, deleted, or expired |
403 | Key valid but disabled / model not allowed / IP not in allowlist |
402 | Key valid but quota exhausted |
Security recommendations
- Never commit keys to a repo — use env vars or a secret manager
- Set IP allowlist for production keys
- One key per project — easier cost attribution
- Use expiry + rotate periodically
- On suspected leak — delete and recreate immediately
