01
Quickstart
Get a key on the Get a key page, then point any OpenAI SDK at MuxKey:
1from openai import OpenAI23client = OpenAI(base_url="https://www.muxkey.xyz/v1", api_key="mk-live-...")45reply = client.chat.completions.create(6 model="meta-llama/llama-3.3-70b-instruct",7 messages=[{"role": "user", "content": "ping"}],8)9print(reply.choices[0].message.content)That is the entire integration. Every endpoint below follows the OpenAI shape.
02
Authentication
Send your key as a bearer token. Keys start with mk-live-. There are no accounts, so the key is the identity — keep it secret.
1Authorization: Bearer mk-live-...Lost a key? Open your permanent dashboard link to rotate it. Without the dashboard link, there is no recovery.
03
Model IDs
Model IDs are provider/model, e.g. deepseek/deepseek-chat. Browse the full list with prices on the Models page, or list them programmatically:
1curl https://www.muxkey.xyz/v1/models -H "Authorization: Bearer mk-live-..."04
Streaming
Need the Anthropic format instead? POST /v1/messagesaccepts Anthropic Messages requests (that's how Claude Code connects) with the same key and billing.
Pass stream: true and read server-sent events, exactly as with OpenAI. Tokens arrive as they are generated.
1const stream = await client.chat.completions.create({2 model: "deepseek/deepseek-chat",3 messages: [{ role: "user", content: "Write a haiku" }],4 stream: true,5});6for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");05
Failover
If an upstream provider errors or times out, MuxKey retries the same model on another provider. Where an equivalent model is configured it can fail over to it — the response's model field always tells you what actually answered.
06
Rate limits
| Limit | Value | Notes |
|---|---|---|
| requests / min | fair use | upstream provider limits apply per model |
| max output tokens | fits your balance | capped so one request can't exceed your credit |
| request duration | ~60s | very long generations can be cut off; stream and keep max_tokens sensible |
Before a request runs, its worst-case cost is held from your balance; the unused part is returned the moment it finishes.
07
Errors
| Status | Meaning | What to do |
|---|---|---|
| 400 | Bad request | Check the model ID and body shape |
| 401 | Invalid key | Check the bearer token |
| 402 | Out of credit | Top up from your dashboard |
| 403 | Key disabled | Rotate the key from your dashboard |
| 429 | Rate limited | Back off and honour retry-after |
| 502 | Upstream failed | Retried automatically; retry once more |
08
Billing
Credit is prepaid in crypto from $0.50 and never expires. You pay the provider's per-token price with a 0% routing fee. See Pricing.
09
Data handling
Prompt and completion content is not stored by default. We keep token counts and timestamps per key for billing. Upstream providers apply their own data policies.