> The full index of these docs is at [llms.txt](https://u22a8.ai/llms.txt).

# API keys

Create an API key, grant its permissions, authenticate requests with it and revoke it.

An **API key** authenticates requests to A8 as your organization. Everything a key judges, teaches or retracts belongs to the organization that created it, and the key carries exactly the permissions you grant it.

## 1 Create a key

Keys are created in the console. Creating one takes the `keys:write` role permission, which owners and admins hold.

1. In **Console → API keys**, create a key.
2. Name it after the system that will use it.
3. Choose its permissions from Table 1.
4. Copy the secret. It is a token that starts with `sk_`, and the console shows it once.

Afterwards the list shows the key in an obfuscated form. To replace a lost secret, revoke the key and create a new one.

## 2 Authenticate requests

Send the key on every request as a bearer token, `Authorization: Bearer <key>`. The OpenAI SDKs send it this way from their `api_key` option. The Anthropic SDKs send it as an `x-api-key` header, which A8 accepts the same way.

The samples on these pages read the key from the `U22A8_API_KEY` environment variable:

**curl**

```bash
curl https://api.u22a8.ai/v1/models \
  -H "Authorization: Bearer $U22A8_API_KEY"
```

**Python**

```python
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.u22a8.ai/v1",
    api_key=os.environ["U22A8_API_KEY"],
)

for model in client.models.list():
    print(model.id)  # every version your key can call
```

**TypeScript**

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.u22a8.ai/v1",
  apiKey: process.env.U22A8_API_KEY,
});

for await (const model of client.models.list()) {
  console.log(model.id); // every version your key can call
}
```

The models list answers any key of an organization with access to A8:

```json
{
  "object": "list",
  "data": [
    {
      "id": "a8",
      "object": "model",
      "owned_by": "u22a8",
      "lifecycle": "preview",
      "shutdown_date": null
    },
    {
      "id": "a8-1-1@20260715t140322z",
      "object": "model",
      "owned_by": "organization",
      "status": "ready",
      "active": true,
      "lifecycle": "preview",
      "shutdown_date": null
    },
    {
      "id": "a8-1-1@reference",
      "object": "model",
      "owned_by": "organization",
      "status": "ready",
      "active": false,
      "lifecycle": "preview",
      "shutdown_date": null
    }
  ]
}
```

Recorded from `a8-1-1@20260715t140322z` on 2026-10-22.

The `status` and `active` fields say which versions are in service, and `lifecycle` and `shutdown_date` when each retires. See [Horizons](https://u22a8.ai/docs/a8-horizons.md) and [Deprecations](https://u22a8.ai/docs/deprecations.md).

## 3 Permissions

A permission names a capability. Each is independent of the others, and a key holds any set of them.

| Permission       | Grants                                                                                                                                          |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `models:infer`   | Judging: verdicts from any version, through every interface                                                                                     |
| `models:train`   | Teaching and retracting through MCP, which changes what your organization's model learns. See [Teaching](https://u22a8.ai/docs/a8-teaching.md). |
| `models:explain` | Precedents and recall: the examples your organization taught, quoted word for word. See [Precedents](https://u22a8.ai/docs/a8-precedents.md).   |

*Table 1.* The three permissions. A key with `models:infer` alone judges and leaves your model as it is, so it suits systems that only need verdicts.

A request needs the permission for what it does:

- A judgment needs `models:infer`.
- A judgment that asks for precedents needs `models:infer` and `models:explain`.
- A question about what you taught needs `models:explain`.
- A teach or a retract needs `models:train`.
- The models list accepts any key of an organization with access to A8.

A request from a key that lacks a permission it needs returns `403`, and the error names the permission. A key whose organization lacks access to A8 returns `403` with code `model_not_enabled`. See [Errors](https://u22a8.ai/docs/errors.md#model_not_enabled).

## 4 Revoke a key

Revoking a key expires it. Requests that use it return `401` within about a minute, the time verification results are cached. The key stays in the list, marked revoked, as a record.

To rotate a key, create the replacement first, move the system over to it, then revoke the old key.

## 5 Errors

| Status | Condition                                                   |
| ------ | ----------------------------------------------------------- |
| `401`  | The key is missing, invalid or revoked                      |
| `403`  | The key is valid and lacks the permission the request needs |
| `503`  | Key verification is briefly unavailable; retry with backoff |

*Table 2.* The errors a key produces. Each status, with its body and fix, is on [Errors](https://u22a8.ai/docs/errors.md).

## Next steps

- [API overview](https://u22a8.ai/docs/api-overview.md): What every request to A8 shares, from the base URL and authentication to the request parts and the response fields.
- [Errors](https://u22a8.ai/docs/errors.md): Every status A8 returns for a failed request, with its body, its cause and its fix, and how each SDK raises it.
- [Teaching](https://u22a8.ai/docs/a8-teaching.md): How to teach and retract through MCP, when a teach lands in your organization’s model and what it changes.
