# API Key Permissions

Source: https://docs.aiand.com/organizations/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](/billing/spend-limits/#api-key-spend-caps).

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](/organizations/members/).

## Create a restricted key

<Steps>

1. On [API Keys](https://console.aiand.com/api-keys), select **Create API Key** and enter a **Name**.
2. Under **Access**, select **Restricted**.
3. Under **APIs this key can call**, select the APIs it needs.
4. Under **Models this key can use**, keep **All models** your organization allows, or select **Only these models** and add each with **Add model**.
5. Select **Create key**.

</Steps>

The **Access** column on **API Keys** summarizes each key's access.

## APIs

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](/analytics/spend/)                           |
| Balance           | `balance`          | [`GET /billing/balance`](/billing/balance/)                                                                  |
| CLI account       | `cli_account`      | `GET /api/user`, `GET /api/orgs` and `GET /api/config`, which the [ai& CLI](/cli/) reads for account details |

[`GET /v1/models`](/api/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`](/errors/#access-and-spending-limits).

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

**All models** your organization allows covers every model the [model allowlist](/organizations/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`](/errors/#access-and-spending-limits).

## 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](/organizations/api-keys/#managing-keys) for who can edit a key.

## 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.
