Chat completions
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.
Request
http
POST https://api-ai.app/v1/chat/completions
Authorization: Bearer mdf-...
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.
json
{
"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)
python
from openai import OpenAI
client = OpenAI(
api_key="<OPENAI_API_KEY>",
base_url="https://api-ai.app/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)
ts
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: "https://api-ai.app/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 API-AI |
|---|---|
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 — upstream does not expose them. |
seed | Ignored — not supported upstream. |
n > 1 | Returns one choice. Call the endpoint N times if you need N samples. |
Pick a wire format and stick with it
Both
/v1/chat/completions and /v1/messages hit the same models at the same price. The chat-completions shim adds a translation layer; the native Messages endpoint does not. For greenfield projects we recommend /v1/messages. For migration from OpenAI, the shim is the fast path.Last updated: October 2, 2026Found a bug? admin@minedom-france.fr