Documentation
Build with OneModelKey
One OpenAI-compatible API for models from OpenAI, Anthropic and Google. Your users bring their own OneModelKey key and pay from their own prepaid balance.
Make your first request
Create an API key, add credits, and point the client you already use at our base URL. Switch models by changing one string. Save your key as the ONEMODELKEY_API_KEY environment variable before running these examples.
https://onemodelkey.com/v1curl https://onemodelkey.com/v1/chat/completions \
-H "Authorization: Bearer $ONEMODELKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5-1",
"messages": [
{"role": "user", "content": "Hello"}
]
}'
curl https://onemodelkey.com/v1/chat/completions \
-H "Authorization: Bearer $ONEMODELKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5-1",
"messages": [
{"role": "user", "content": "Hello"}
]
}'
from openai import OpenAI
client = OpenAI(
api_key="mq_live_...",
base_url="https://onemodelkey.com/v1",
)
response = client.chat.completions.create(
model="claude-fable-5-1",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ONEMODELKEY_API_KEY,
baseURL: "https://onemodelkey.com/v1",
});
const response = await client.chat.completions.create({
model: "claude-fable-5-1",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);
Let your users bring their key
Add a setting in your app where people paste a OneModelKey key, and send their requests with that key. They create the key, add credits and watch their spending here, so you never handle their billing.
- Add a key field. Store each user’s key as a secret. Keep keys out of shared logs, analytics and client-side code.
- Offer the models you support. Fetch
/v1/modelsand show the IDs your app can handle. - Link to the setup guide. Send users who don’t have a key yet to https://onemodelkey.com/connect. It explains the steps without any code.
Authentication
Every request requires an API key in the Authorization header. Treat keys like passwords and never embed them in public client-side code.
Authorization: Bearer mq_live_...Models
/v1/models/v1/models/{id}Returns the public aliases currently enabled for your account.
claude-fable-5-1Claude Fable 5.1
Anthropicclaude-haiku-5-5Claude Haiku 5.5
Anthropicclaude-opus-5-5Claude Opus 5.5
Anthropicclaude-sonnet-5-5Claude Sonnet 5.5
Anthropicgemini-3.1-flash-liteGemini 3.1 Flash-Lite
Googlegemini-3.1-pro-previewGemini 3.1 Pro (Preview)
Googlegemini-3.5-flash-liteGemini 3.5 Flash-Lite
Googlegemini-3.8-flashGemini 3.8 Flash
Googlegpt-5-nanoGPT-5 Nano
OpenAIgpt-6-astraGPT-6 Astra
OpenAIgpt-6-lunaGPT-6 Luna
OpenAIgpt-6.1-solGPT-6.1 Sol
OpenAIChat completions
/v1/chat/completionsThe required model field selects an ID returned by /v1/models. Send messages in the same format for every provider; the gateway routes and translates the request. There is no default model. Tool definitions, tool choice, JSON response formats, and common sampling parameters are forwarded where supported. The optional n parameter must be 1; multiple candidates are not supported.
Omitting an output limit allows up to 4,096 tokens. Send either max_tokens or max_completion_tokens. Unsupported settings and malformed tool history are rejected before credits are reserved.
Tool conversations
Append the complete returned assistant message before sending tool results, preserving LiteLLM continuation fields such as reasoning_items, thinking_blocks, provider_specific_fields and tool-call extensions. This carries the signed reasoning state needed for subsequent requests. For streaming, merge tool-call and thinking-block deltas by index and retain reasoning items, signatures and provider metadata in the assembled assistant message. The old OpenAI response-items and Anthropic content envelopes are no longer supported. Return one string result for every tool call using its tool_call_id.
Streaming
Set "stream": true to receive text/event-stream chunks in the OpenAI chat.completion.chunk shape, ending with data: [DONE]. Add "stream_options": {"include_usage": true} to receive a final usage-only chunk. Streamed requests are billed from provider-reported usage exactly like non-streamed ones; if you disconnect, generation is still billed until the provider finishes. A completed usable response without valid usage is charged using a LiteLLM token estimate, marked by usage.estimated: true and an estimated status in request history. Non-streaming responses also include X-Usage-Source: estimated. These estimates treat unknown cache activity as uncached input and cannot reconstruct hidden reasoning. Lost output and unpriced usage remain pending for review.
curl -N https://onemodelkey.com/v1/chat/completions \
-H "Authorization: Bearer $ONEMODELKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5-1",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true,
"stream_options": {"include_usage": true}
}'Errors
Errors use an OpenAI-shaped error object.
| Status | Meaning |
|---|---|
| 400 | Invalid request or unsupported parameter |
| 401 | Missing or invalid API key |
| 402 | Insufficient API credits |
| 429 | Rate or API-key spend limit reached |
| 5xx | Gateway or upstream provider failure |
Every gateway response carries an X-Request-ID header. Quote it when contacting support.
Data retention
The gateway records token counts, model alias, charge, latency, API-key identifier, and request identifier. It does not persist prompt or response bodies. Selected upstream providers may retain content under their own terms.
Read the privacy notice