Skip to main content
All OpenPAI APIs require authentication. Auth information is carried in the request headers, not in the URL query.

OpenAI-compatible protocol

Authorization: Bearer sk-XXXXXXXXXXXXXXXX
curl https://openp.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.5","messages":[{"role":"user","content":"hi"}]}'

Claude Messages protocol

x-api-key: sk-XXXXXXXXXXXXXXXX
anthropic-version: 2023-06-01
curl https://openp.ai/v1/messages \
  -H "x-api-key: $OPENPAI_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model":"claude-opus-4-8",
    "max_tokens":1024,
    "messages":[{"role":"user","content":"hi"}]
  }'
SDKs usually add anthropic-version automatically, so you don’t need to set it manually when using an SDK.

Gemini native protocol

x-goog-api-key: sk-XXXXXXXXXXXXXXXX
curl "https://openp.ai/v1beta/models/gemini-3.1-pro-preview:generateContent" \
  -H "x-goog-api-key: $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents":[{"role":"user","parts":[{"text":"hi"}]}]
  }'
Gemini also supports query-parameter auth (?key=sk-...), but this is not recommended — the URL gets logged by proxies.

Failure examples

StatusCause
401 invalid_api_keyKey doesn’t exist / disabled / wrong format / trailing newline
401 expired_api_keyThe token has expired
403 insufficient_quotaAccount or token quota insufficient
403 ip_not_allowedThe source IP isn’t in the token’s allowlist
403 model_not_allowedThe token lacks permission to call this model
How to troubleshoot:
  1. Copy the X-OpenPAI-Request-Id header.
  2. Console → Logs → search for that Request ID to see the detailed failure reason.

Key safekeeping

  • Do not commit keys to Git or paste them into chats / issues.
  • Inject them via environment variables / a secret manager.
  • If you suspect a leak, disable and regenerate immediately in the console.
  • Create separate tokens per app / environment for fine-grained tracking.