Authentication

Authenticate each supported API protocol safely with an AnyInt API key.

Every Developer API request requires an active AnyInt API key. Use the header expected by your client protocol so existing OpenAI, Anthropic, and Gemini SDKs continue to work.

ProtocolRecommended inputCanonical API base
OpenAI compatibleAuthorization: Bearer <AnyInt API Key>https://api.anyint.ai/openai/v1
Anthropic Messagesx-api-key: <AnyInt API Key>https://api.anyint.ai/anthropic/v1
Gemini Developer APIx-goog-api-key: <AnyInt API Key>https://api.anyint.ai/gemini/v1beta
Async mediaAuthorization: Bearer <AnyInt API Key>https://api.anyint.ai/v1/async-tasks

For client compatibility, the gateway also accepts the supported AnyInt key headers across protocol families and accepts Gemini's key query parameter on Gemini routes. Prefer headers so credentials do not appear in URLs or intermediary logs.

The gateway consumes the AnyInt credential before provider routing. It never forwards that credential as an upstream provider key. Invalid, expired, or revoked keys fail closed.

Create a Key

Create an API key in Console, then store it in a server-side secret manager or environment variable.

Newly issued AnyInt keys use the sk- prefix followed by 52 Base64URL characters (55 characters total). Existing ak_ keys remain valid until you rotate or disable them. Always copy the complete value shown by Console; do not add or remove a prefix yourself.

bash
export ANYINT_API_KEY="your_api_key"

Security Guidelines

  • Store keys in a server-side secret manager or environment variable.
  • Never place a key in frontend JavaScript, source control, logs, or URLs.
  • Use a separate key for each application and environment.
  • Rotate a key immediately if it may have been exposed.
  • Do not forward AnyInt keys to upstream providers.

Test Authentication

List models to verify the key before sending an inference request.

bash
curl "https://api.anyint.ai/openai/v1/models" \
  --header "Authorization: Bearer $ANYINT_API_KEY"

An authentication failure returns HTTP 401 with a protocol-shaped error. A valid key can still receive 402 for insufficient balance or 503 when no eligible provider is available.

常見錯誤排查與處理

當 API 調用遇到異常時,請參考下表快速定位原因與解決方案:

HTTP 狀態碼典型原因排查步驟與解決方案
401 UnauthorizedAPI Key 無效、已過期或請求頭缺失檢查請求頭中的 Bearer Token 或 x-api-key 是否完整複製;在控制台 API 金鑰頁確認金鑰是否處於啟用狀態。
402 Payment Required帳戶餘額不足或月度預算耗盡前往控制台完成帳戶儲值,或在金鑰詳情中調高月度消費額度限制。
403 ForbiddenIP 白名單攔截、環境隔離或權限不足檢查 API Key 的工作區權限範圍,確認請求 IP 是否在允許的白名單內。
404 Not Found請求路徑錯誤或請求的模型 ID 不存在確認 Base URL 路徑是否正確;調用 GET /v1/models 驗證模型標識符是否正確。
429 Too Many Requests達到速率限制 (RPM/TPM) 或並發上限降低客戶端請求並發;在控制台申請提升限額或配置階梯重試 (Exponential Backoff)。
502 Bad Gateway上游模型服務商網路異常或響應格式損壞AnyInt 閘道會自動嘗試多通道故障轉移;若持續異常,請在控制台查看請求日誌或提交工單。
503 Service Unavailable當前模型所有可用通道均處於排隊或熔斷狀態稍後重試,或在應用中配置同能力備選模型實現高可用容災。
504 Gateway Timeout上游推理超時(多見於超長思考模型未及時吐出首字)優化 Prompt 長度與最大 Token 上限;客戶端配置更長的請求超時;對推理模型建議使用串流輸出 (Stream)。