Quickstart
Get a key, send your first request to ai.codai.ro, pick a wire format.
The codai gateway lives at https://ai.codai.ro. It speaks three wire formats — OpenAI Chat Completions, Anthropic Messages and the OpenAI Responses API — and one model name, codai. Whatever SDK you already use will work; the gateway translates under the hood.
Get an API key
Sign in to hub.codai.ro and open Keys → Create key. Keys look like codai_xxxxxxxx and are shown once — store yours in an environment variable:
$env:CODAI_API_KEY = 'codai_xxxxxxxx'Send your first request
curl https://ai.codai.ro/v1/chat/completions \
-H "Authorization: Bearer $CODAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "codai",
"messages": [
{ "role": "user", "content": "Write a one-line Python function that returns the nth Fibonacci number." }
]
}'A successful response is a standard chat completion:
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "codai",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "def fib(n): return n if n < 2 else fib(n - 1) + fib(n - 2)" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 27, "completion_tokens": 21, "total_tokens": 48 }
}Read the response headers
Every response tells you what actually happened. The two you will use most:
| Header | Meaning |
|---|---|
x-codai-routed-to | The upstream model that served the request. |
x-codai-cost-micro-usd | The cost of this request in integer micro-USD (when known before the first byte — see limits & pricing). |
The full list is on the request headers page.
To see them, add -i to the curl request above:
HTTP/2 200
x-codai-routed-to: claude-sonnet-5-5
x-codai-upstream: claude-sonnet-5-5
x-codai-cost-micro-usd: 18401840 micro-USD is $0.00184. On native streams the cost is not known when headers are sent, so you get x-codai-cost-estimate: pending and the exact figure later from GET /v1/receipt.
codai or a pinned model?
What `codai` does today
model: "codai" is currently a chain of Anthropic's current Claude models with automatic failover between deployments: when one deployment is unavailable, the next one in the chain answers. It does not switch to other providers on its own. Pin a name when you need one model every time: a workload alias such as codai-fast or codai-max, or a direct upstream name on plans that allow it. Either way x-codai-routed-to tells you which model answered. codai's own model is in opt-in beta as codai-1-beta (ask for it by name; it is not listed). Details on models.
Already using an SDK?
Point it at the gateway and keep your code.
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.CODAI_API_KEY,
baseURL: 'https://ai.codai.ro/v1',
});
const res = await client.chat.completions.create({
model: 'codai',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(res.choices[0].message.content);The OpenAI base URL includes /v1; the Anthropic base URL is the bare host. Getting this wrong produces a 404 not_found that looks like an auth failure.
Next steps
Models
What `codai` resolves to, the other aliases, effort and thinking.
Wire formats
Chat Completions, Messages and Responses — request and response shapes.
Streaming
SSE shapes per format and where usage lands.
Clients
VS Code, Copilot CLI, Cursor, Continue, MCP.
SDKs
The official TypeScript and Python clients.
Limits & pricing
Rate limits, spend caps and the error contract.
Last updated: