API keys
Create a task API key, choose read or write, keep it out of your code and rotate it.
The Evals API and CLI authenticate with a task API key, the app’s general-purpose API key. A key belongs to the person who created it and to their organization, and it can never do more than its owner can do in the app.
Read and write
| Capability | Label in the app | What it allows |
|---|---|---|
evals:read | Read evals | Every HTTP endpoint, and every CLI command that only reads, except listing workflows (evals targets workflow, and --workflow on evals monitors list), which needs evals:write. |
evals:write | Change evals | Create, edit and delete datasets, tasks, criteria, evaluations and scorecards, and start and stop runs. |
A key for a dashboard or a report needs only evals:read. Give evals:write only to a key that builds or runs evaluations, such as a CI job. Only the key’s owner can grant evals:write, because the model calls its runs make are charged to them; an admin creating a key for someone else can’t include it.
Create a key
- In the app, open Settings > API > Task keys and choose New key.
- Name the key after where it will be used, for example
ci-nightly-evals. - Leave Agent scope set to Any allowed agent. A key scoped to one agent can’t read Evals data, except traces, which it reads for its own agents only.
- Check the capabilities it needs. New keys start with most capabilities checked; for a read-only key, clear everything except Read evals.
- Optionally set Expires. A key with no expiry works until it is revoked.
- Choose Create key and copy the key. It is shown only once, and it starts with
tsk_.
Send the key
Over HTTP, send it in either header. The CLI reads it from CONTEXT_API_KEY.
Authorization: Bearer <task-api-key>X-API-Key: <task-api-key>Keep it secret
- Store the key in an environment variable or your secret manager, never in source code or a repository.
- Use one key per system, so you can revoke one without breaking the others.
- If a key leaks, revoke it at once.
Rotate a key
The app has no rotate button. Rotate in three steps, which keep the old key working until the new one is in place:
- Create a new key with the same capabilities.
- Deploy the new key to every system that uses the old one, and check that requests succeed.
- Revoke the old key: open it in Settings > API > Task keys and choose Revoke key.
After you revoke a key, requests with it get 401. For up to 60 seconds after you revoke it, a request that is also over the rate limit may get 429 rather than 401.
A key can’t read another organization’s data: the organization comes from the key, never from the request. If the owner loses Evals access, so does the key.