Authentication
Every request is authenticated with a codexkey API key.
API key format
sk_cdx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSupported auth headers
Anthropic-style requests
Use x-api-key:
bash
curl https://api.codexkey.online/v1/messages \
-H "x-api-key: sk_cdx_YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Hi"}]
}'OpenAI-style requests
Use Authorization: Bearer:
bash
curl https://api.codexkey.online/v1/chat/completions \
-H "Authorization: Bearer sk_cdx_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5",
"messages": [{"role": "user", "content": "Hi"}]
}'Either method works. The gateway looks at x-api-key first and then at Authorization: Bearer.
Per-key controls
In the Dashboard > API Keys section you pick Premium, Cheap, or Cheap + Premium fallback. A new key gets Premium by default. The channel is stored in the key itself, so switching the catalog tab does not affect a key that already exists.
| Setting | What it does |
|---|---|
| Name | Identifies the key in your dashboard |
| Premium | channel=premium, fallback_premium=false. This is the default. |
| Cheap | channel=cheap, fallback_premium=false. Requests go through the Cheap channel only. |
| Cheap + Premium fallback | channel=cheap, fallback_premium=true. The provider may send a request to Premium under its own channel rules, and Premium pricing may then apply. |
| Expiry | expires_at sets a future end date; leave it out when creating a key without an expiry |
| Usage | Shows recent requests, tokens and customer cost. Budgets, IP filters, and IDE or model restrictions cannot be set on a key through this API. |
| Streaming | The response streams when the client sends "stream": true; send "stream": false for a regular response |
Security tips
- Create separate keys for personal work, apps and automation
- Delete keys you have stopped using
- If you do not want requests routed through Premium, choose Cheap without fallback
- Give temporary integrations an expiry date
- Watch each key's usage in the dashboard