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:
| Header | Style | Typical client |
|---|---|---|
Authorization: Bearer prx-… | OpenAI | OpenAI SDK, Cursor, Windsurf, Codex |
x-api-key: prx-… | Anthropic | Anthropic 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
| Status | Meaning |
|---|---|
401 | Missing or invalid key. |
402 | Insufficient credits — top up in the Telegram app. |
400 | Malformed request (bad model name, unsupported params). |
429 | Rate limited — back off and retry. |
5xx | Upstream/gateway error — you are not charged (see Billing). |