Authentication
You create an API key in the dashboard; it starts with gk_sk_. Both text protocols accept a Bearer token; Anthropic Messages also accepts x-api-key.
OpenAI-compatible header
Authorization: Bearer YOUR_API_KEY
Anthropic-compatible headers
x-api-key: YOUR_API_KEY
anthropic-version: 2023-06-01
Model access
- A key works only while it is active, not expired and within its quota.
- If a key is restricted to a list of models, every other model returns HTTP 403.
- One key can be used with several allowed models.
- Use separate keys with separate quotas for production, development and CI.
Security
Keep the key on your server or in a secrets manager. Never put it into client-side JavaScript, a mobile app, a repository, a screenshot or a support message. Delete the key in the dashboard if it may have leaked.
| HTTP | Reason |
|---|---|
| 401 | the key is missing or unknown |
| 403 | the key is disabled, expired, or restricted by IP or model |
| 429 | the key quota or a gateway limit is exhausted |