Wire formats
The three request shapes the gateway accepts — OpenAI Chat Completions, Anthropic Messages and the OpenAI Responses API.
Pick the format your client already speaks. All three take the same bearer key, resolve the same aliases, apply the same limits and write the same usage records. Nothing in your account depends on which one you choose.
| Format | Endpoint | Best for |
|---|---|---|
| OpenAI Chat Completions | POST /v1/chat/completions | OpenAI SDKs, LangChain, LlamaIndex, Cursor, Continue, most agent frameworks. |
| Anthropic Messages | POST /v1/messages | Anthropic SDKs, Claude Code, anything Anthropic-native. |
| OpenAI Responses | POST /v1/responses | Newer OpenAI SDKs and Copilot's apiType: "responses" mode. |
OpenAI Chat Completions
The gateway's native shape. Accepts model, messages, stream, max_tokens (or max_completion_tokens), temperature, top_p, stop, tools, tool_choice, response_format, reasoning_effort and user. Unknown fields pass through to the upstream.
curl https://ai.codai.ro/v1/chat/completions \
-H "Authorization: Bearer $CODAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "codai",
"messages": [
{ "role": "system", "content": "You are a terse senior engineer." },
{ "role": "user", "content": "Explain Promise.all in three sentences." }
],
"max_tokens": 300
}'Tool calling
Standard OpenAI function tools. When you pass tools, the gateway treats you as the owner of the tool loop: it streams the model's tool_calls back untouched and never runs a second agent loop behind you.
{
"model": "codai",
"messages": [{ "role": "user", "content": "What is the weather in Cluj?" }],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
}
]
}The reply carries choices[0].message.tool_calls and finish_reason: "tool_calls". Send the result back as a { "role": "tool", "tool_call_id": "…", "content": "…" } message.
Images
Send image_url content parts on a user message, exactly as with OpenAI. codai advertises vision: true.
Anthropic Messages
Accepts the public Anthropic Messages shape: model, messages with block content, system, max_tokens (required), temperature, top_p, top_k, stop_sequences, stream, tools, tool_choice, metadata. Auth is Authorization: Bearer or x-api-key — both work. Send anthropic-version: 2023-06-01 as you would upstream.
curl https://ai.codai.ro/v1/messages \
-H "Authorization: Bearer $CODAI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "codai",
"max_tokens": 1024,
"system": "You are a terse senior engineer.",
"messages": [{ "role": "user", "content": "Explain Promise.all in three sentences." }]
}'When the resolved upstream is Anthropic-native, bytes are forwarded 1:1 — lowest possible time to first token. When it is OpenAI-shaped (Gemini, for instance) the gateway translates on the fly; the response shape you see is always Anthropic.
OpenAI Responses API
A translation layer over Chat Completions: the request is mapped to a chat request, re-enters the same route in-process (so auth, limits, routing, caching and usage apply unchanged), and the result is mapped back. Supported: input as a string or array of { role, content } items, function_call / function_call_output items for agent loops, instructions, tools (function type), tool_choice, max_output_tokens, temperature, top_p, stream and reasoning.effort.
curl https://ai.codai.ro/v1/responses \
-H "Authorization: Bearer $CODAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "codai",
"instructions": "You are a terse senior engineer.",
"input": "Explain Promise.all in three sentences.",
"reasoning": { "effort": "high" }
}'reasoning.effort follows OpenAI's vocabulary and maps onto codai tiers: xhigh → max, none → minimal; unknown values are dropped. An X-Codai-Effort header wins over the body.
Not supported, and rejected with 400 bad_request and a clear message: previous_response_id chaining (send the full input each time), background: true, built-in tools such as web_search, and response retrieval.
Choosing between them
- Already have code? Keep its format. There is no capability difference for chat.
- Starting fresh? Chat Completions has the widest tool support and is the gateway's native shape.
- Need Claude-style block content or
x-api-keyauth? Messages. - Copilot in Responses mode? Responses — see clients.
All three stream — see streaming for the per-format SSE shapes.