Skip to content
OneAPIDocs
ModelsOpen console

Start here

Authentication

Every request carries one API key. The gateway reads it from either of two headers, on every endpoint.

Which header carries the key

Send the key in Authorization with the Bearer prefix, or in x-api-key. The gateway checks Authorization first and falls back to x-api-key. Both work on all paths, so an OpenAI client and an Anthropic client can share the same key without changes.

either header
Authorization: Bearer sk-oneapi-...
x-api-key: sk-oneapi-...
ClientSendsSet the key with
OpenAI SDKAuthorization: Bearerapi_key
Anthropic SDKx-api-keyapi_key
cURLWhichever you write-H

/v1/messages also expects anthropic-version: 2023-06-01, as the Anthropic API does. The Anthropic SDK sends it for you.

Key format

Keys look like sk-oneapi- followed by 32 letters and digits. Keys created before the rename start with sk-orid- and keep working. The console lists keys by name and prefix; from there you can show a key again, rotate it, or revoke it.

Key controls

Each key can be narrowed when you create it in API keys. A key with no controls set can spend the whole account balance on any model.

Spend capUSD amount

The most this key may spend in one period. When it is reached, requests with this key get 429 quota_exceeded and a Retry-After header until the period resets. The cap limits this key only; the account balance still applies on top.

Reset perioddaily | monthly

When the spend cap starts again. Monthly if you set a cap and do not choose. Periods follow UTC.

Allowed modelslist of model IDs

If set, the key can call only these models. Any other model gets 403 unknown_model with a message naming the model.

Expirydays from creation

After this the key stops authenticating. Leave empty for a key that does not expire.

When authentication fails

A missing, wrong, disabled, revoked or expired key returns 401 with code unauthorized and the message Invalid API key. The response does not say which of these it was, on purpose: it would tell a guesser which keys exist.

Handling keys

Keep keys on the server

A key in browser JavaScript or a mobile app bundle can be read by anyone who has the app. Call the gateway from your backend and pass results to the client.

One key per project or environment

Separate keys give each project its own spend cap and its own line in usage, and let you revoke one without touching the others.