Skip to main content

Authentication

Every request is authenticated with your Primex API key (prx-…). The gateway accepts both common header styles on all routes, so whichever SDK you use will work:

HeaderStyleTypical client
Authorization: Bearer prx-…OpenAIOpenAI SDK, Cursor, Windsurf, Codex
x-api-key: prx-…AnthropicAnthropic SDK, Claude Code, Cline

Examples

# OpenAI style
curl https://gateway.primex.work/v1/chat/completions \
-H "Authorization: Bearer prx-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.5","messages":[{"role":"user","content":"hi"}]}'
# Anthropic style
curl https://gateway.primex.work/v1/messages \
-H "x-api-key: prx-YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":256,"messages":[{"role":"user","content":"hi"}]}'

Keeping keys safe

  • Never commit keys to source control or ship them in client-side code. Use environment variables (OPENAI_API_KEY, ANTHROPIC_API_KEY).
  • Your key is your wallet — a leaked key can spend your credits.
  • Rotate a key immediately if it may have leaked. See API Keys.

Errors

StatusMeaning
401Missing or invalid key.
402Insufficient credits — top up in the Telegram app.
400Malformed request (bad model name, unsupported params).
429Rate limited — back off and retry.
5xxUpstream/gateway error — you are not charged (see Billing).