API authentication: the key and its headers
Every request must carry a 1xai-* key in a header: Authorization: Bearer, x-api-key or x-goog-api-key. All three are accepted on every route, so the official OpenAI, Anthropic and Google SDKs work unmodified. A key in the URL (?key=) is not read. A wrong, revoked or expired key answers 401.
Last updated:
Three headers, one key
Authorization: Bearer 1xai-XXXXXXXXXXXXXXXXXXXXXXXX x-api-key: 1xai-XXXXXXXXXXXXXXXXXXXXXXXX x-goog-api-key: 1xai-XXXXXXXXXXXXXXXXXXXXXXXX
| Header | Who sends it |
|---|---|
Authorization: Bearer | Who sends it:OpenAI SDKs and every OpenAI-compatible tool |
x-api-key | Who sends it:The official Anthropic SDK |
x-goog-api-key | Who sends it:The official Google GenAI SDK |
- When
Authorizationis present it is the one read; the other two are read only when there is noAuthorizationheader. - A key in a URL parameter (
?key=, as some Google samples use) is not read, and such a request answers401. Configure Google SDKs with a header. - One key works on every route:
/v1,/anthropic,/geminiand the account API.
The 401 answers
| Code | Meaning |
|---|---|
missing_api_key | Meaning:No key in Authorization, x-api-key or x-goog-api-key |
invalid_api_key | Meaning:A key 1xAi does not know |
account_disabled | Meaning:The key is known and its account is switched off |
key_revoked | Meaning:The key was revoked or has expired |
key_capped | Meaning:The key reached its own spend cap |
workspace_limit | Meaning:The monthly limit of the workspace or member is used up |
Every code is in the error reference.
Browsers and mobile apps
Keep a 1xai-* key on a server only. For a realtime voice call from a browser or an app, your server mints a short-lived secret and hands only that to the user (realtime voice). For every other route, send the request from your own server.
1xAi is an independent gateway. It is not affiliated with, endorsed by, or a reseller for OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot AI, Z.ai, Alibaba Qwen, MiniMax or Tencent Hunyuan. Requests are relayed upstream rather than answered by models of our own, so each provider's own usage policies apply to what their models will and will not do, and their model availability is theirs to change. Current reachability is published on the status page.