API Key Permissions
A key has Full access by default: it can call every API and use every model your organization allows. A Restricted key can call only the APIs you choose, and can be limited to the models you choose. Restrict a key that runs somewhere you trust less, such as a dashboard or a third-party tool, so that a leaked key can do less. To limit what a key can spend, give it a monthly spend cap.
Restricting a key narrows what its creator’s role allows. It never adds to it: a key created by a Member can’t read the balance, whatever its access. See Members & Roles.
Create a restricted key
Section titled “Create a restricted key”- On API Keys, select Create API Key and enter a Name.
- Under Access, select Restricted.
- Under APIs this key can call, select the APIs it needs.
- Under Models this key can use, keep All models your organization allows, or select Only these models and add each with Add model.
- Select Create key.
The Access column on API Keys summarizes each key’s access.
A restricted key can call only the APIs selected for it. Each covers these endpoints:
| API | Value | Endpoints |
|---|---|---|
| Chat completions | chat_completions | POST /v1/chat/completions |
| Messages | messages | POST /v1/messages, POST /v1/messages/count_tokens |
| Responses | responses | POST /v1/responses |
| Video | video | Every /v1/videos endpoint: create, list, retrieve, download, delete, and GET /v1/videos/models |
| Files and uploads | files | Every /v1/files and /v1/uploads endpoint |
| Request logs | request_logs | GET /logs and every endpoint under /logs, including content export and deletion |
| Analytics | analytics | Every endpoint under /analytics: metrics, summary and spend |
| Balance | balance | GET /billing/balance |
| CLI account | cli_account | GET /api/user, GET /api/orgs and GET /api/config, which the ai& CLI reads for account details |
GET /v1/models needs none of them. Every key can call it, and it lists only the models the organization and the key allow, whichever APIs the key can call.
A key restricted from an API gets 403 api_not_allowed_by_api_key.
Keys that aiand login creates start with full access, and keep any restriction set on them later when the CLI refreshes them. A restricted key you paste into the CLI needs CLI account for the CLI’s account details, plus the APIs of the commands you run.
Models
Section titled “Models”All models your organization allows covers every model the model allowlist allows, including models it allows later. Only these models limits the key to the models you list, chat and video alike. You can list only models your organization allows.
The organization’s allowlist is checked first, so a key never gets a model the organization has turned off, even one listed for the key. A key making videos needs the Video API as well as the video models. If your organization has connected its own Anthropic key, Add model also offers Claude (your Anthropic key). A key limited to chosen models reaches Claude through that key only when it is chosen; otherwise such a request returns the error below.
A request for a model the key is not allowed to use returns 403 model_not_allowed_by_api_key.
Change a key’s access
Section titled “Change a key’s access”Select Edit on the key’s row, change its access, and select Save changes. Changes apply within a minute. The key’s secret stays the same, so nothing needs redeploying. See Organization API Keys for who can edit a key.
Recommended patterns
Section titled “Recommended patterns”| Key for | APIs | Models |
|---|---|---|
| A dashboard or reporting job | Analytics, and Request logs if it reads them | Any: it calls no model |
| An application backend | Only the inference APIs it calls, such as Messages | Only these models: the ones it uses |
| A video pipeline | Video, and Files and uploads for input images | Only these models: its video models |
Give each service its own key, so that one can be revoked or capped without touching the others.