Chat Completions
Use POST /v1/chat/completions in the OpenAI request format and get OpenAI-style replies from Claude models. Python and Node examples included.
POST /v1/chat/completions accepts the OpenAI request shape and returns the OpenAI response shape. The model id is the only required swap from your current OpenAI code.
All models, capabilities, and prices Documentation index for AI agents:https://oneprovider.dev/docs/llms.txt Request
httpPOST https://api.oneprovider.dev/v1/chat/completions
Authorization: Bearer sk-...
content-type: application/json
{
"model": "claude-sonnet-5-5",
"messages": [
{ "role": "system", "content": "You are concise." },
{ "role": "user", "content": "Why is the sky blue?" }
],
"max_tokens": 256,
"stream": false
} Response
Shape matches OpenAI 1:1 — id, choices[].message, usage.
{
"id": "chatcmpl_01...",
"object": "chat.completion",
"created": 1715472000,
"model": "claude-sonnet-5-5",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Rayleigh scattering..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 48,
"completion_tokens": 92,
"total_tokens": 140
}
} OpenAI SDK (Python)
pythonfrom openai import OpenAI
client = OpenAI(
api_key="<OPENAI_API_KEY>",
base_url="https://api.oneprovider.dev/v1",
)
r = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[{"role": "user", "content": "Say hi."}],
)
print(r.choices[0].message.content) OpenAI SDK (Node)
tsimport OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: "https://api.oneprovider.dev/v1",
});
const r = await client.chat.completions.create({
model: "claude-sonnet-5-5",
messages: [{ role: "user", content: "Say hi." }],
});
console.log(r.choices[0].message?.content); Field mapping
| OpenAI field | Behavior on OneProvider |
|---|---|
messages | Forwarded; system role hoisted into Anthropic system. |
max_tokens | Forwarded. |
temperature, top_p | Forwarded. |
tools, tool_choice | Translated to Anthropic tools / tool_choice — same normalization as Tool use . |
stream | Forwarded; emits OpenAI SSE chunks (not Anthropic events). |
response_format | json_object is honored via system hint. Strict json_schema mode is currently ignored. |
logprobs, top_logprobs | Ignored: the models do not expose them. |
seed | Ignored: not supported. |
n > 1 | Returns one choice. Call the endpoint N times if you need N samples. |
/v1/chat/completions and /v1/messages hit the same models at the same price. Chat Completions maps the OpenAI format onto the model; the native Messages endpoint skips that step. For greenfield projects we recommend /v1/messages . For migration from OpenAI, Chat Completions is the fast path. Quick answers
Which base URL do I use?
Claude Code and Anthropic SDKs use https://api.oneprovider.dev. OpenAI SDKs and OpenAI-compatible clients use https://api.oneprovider.dev/v1. One key works behind both; the model list is on the models page ; rates are on the pricing page .
How do I authenticate?
Send the raw sk-… key in x-api-key or Authorization: Bearer: one of them, never both. Keep the key in an environment variable, not in a file that gets committed. More on authentication .
Where do I get a key?
Open your cabinet in the Telegram bot @oneprovider_robot or at app.oneprovider.dev, top up the balance and press “Issue a key”. Each key can carry its own spend limit. Cabinet & API keys .
What do 401, 404 and 429 mean?
401: the key is missing, mistyped or sent in the wrong header; paste the whole key without quotes or spaces. 404: usually a wrong base URL, for example a missing or doubled /v1. 429 with “Insufficient balance”: the cabinet balance or the key’s spend limit is used up, so top up instead of retrying; any other 429 is a rate limit, so wait for Retry-After. Details: error codes and troubleshooting .
Why do streams cut off or reset?
VPN and VLESS proxies often buffer SSE or break HTTP/2 negotiation. OneProvider has no regional restrictions and does not buffer streams, so turn the proxy off and retry.
Where do I ask if this is not enough?
Message @Oneproviderhelpbot on Telegram or open “Support” in the web cabinet, with the HTTP status code and the exact error message. How support works .
Last updated: 2026-10-05 Found a bug? @Oneproviderhelpbot