IN ENGLISH · API DOCS

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:

[01]AUTHENTICATION

Three headers, one key

httphttp
Authorization: Bearer 1xai-XXXXXXXXXXXXXXXXXXXXXXXX

x-api-key: 1xai-XXXXXXXXXXXXXXXXXXXXXXXX

x-goog-api-key: 1xai-XXXXXXXXXXXXXXXXXXXXXXXX
Key headers
HeaderWho sends it
Authorization: BearerWho sends it:OpenAI SDKs and every OpenAI-compatible tool
x-api-keyWho sends it:The official Anthropic SDK
x-goog-api-keyWho sends it:The official Google GenAI SDK
  • When Authorization is present it is the one read; the other two are read only when there is no Authorization header.
  • A key in a URL parameter (?key=, as some Google samples use) is not read, and such a request answers 401. Configure Google SDKs with a header.
  • One key works on every route: /v1, /anthropic, /gemini and the account API.
[02]AUTHENTICATION

The 401 answers

Authentication errors
CodeMeaning
missing_api_keyMeaning:No key in Authorization, x-api-key or x-goog-api-key
invalid_api_keyMeaning:A key 1xAi does not know
account_disabledMeaning:The key is known and its account is switched off
key_revokedMeaning:The key was revoked or has expired
key_cappedMeaning:The key reached its own spend cap
workspace_limitMeaning:The monthly limit of the workspace or member is used up

Every code is in the error reference.

[03]AUTHENTICATION

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.