Claude Code
Point Claude Code at the codai root URL, pin every model alias to codai and add the MCP server.
Claude Code needs ANTHROPIC_BASE_URL=https://ai.codai.ro, your codai key in ANTHROPIC_AUTH_TOKEN, and every model alias pinned to codai.
Before you start
- A codai key from hub.codai.ro → Keys → Create key (details in the quickstart).
- Claude Code installed. No Anthropic account is needed.
Configure
Put the variables in your user settings file: ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json).
{
"env": {
"ANTHROPIC_BASE_URL": "https://ai.codai.ro",
"ANTHROPIC_AUTH_TOKEN": "codai_xxxxxxxx",
"ANTHROPIC_MODEL": "codai",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "codai",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "codai",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "codai",
"CLAUDE_CODE_SUBAGENT_MODEL": "codai"
}
}ANTHROPIC_BASE_URLis the root. Claude Code appends/v1/messagesitself.ANTHROPIC_AUTH_TOKENis sent asAuthorization: Bearerand needs no approval prompt.ANTHROPIC_API_KEYalso works (sent asx-api-key), but interactive mode asks you to approve it once.- Pin all four model variables. Otherwise background work and sub-agents ask for built-in
claude-*ids instead ofcodai. - Never put the token in a project's
.claude/settings.json— that file is meant to be committed. - A value in a settings file beats a shell
export. Run/statusto see what Claude Code actually uses.
In the VS Code extension, set the same pairs in claudeCode.environmentVariables as an array of { "name": …, "value": … }.
MCP
With a key:
claude mcp add --transport http codai https://ai.codai.ro/mcp --header "Authorization: Bearer codai_xxxxxxxx"Or in a project .mcp.json, reading the key from your environment:
{
"mcpServers": {
"codai": {
"type": "http",
"url": "https://ai.codai.ro/mcp",
"headers": { "Authorization": "Bearer ${CODAI_API_KEY}" }
}
}
}typeis required whenurlis set.- Do not write
${ANTHROPIC_AUTH_TOKEN}in the header; it expands to an empty value.
Without a key (OAuth): add the server with no header, then run /mcp or claude mcp login codai and sign in in the browser. codai supports Dynamic Client Registration and PKCE, so nothing else is needed. A server added with a static header that the gateway rejects does not fall back to OAuth — remove the header first.
What works and what does not
| Feature | With codai |
|---|---|
| Chat, agent loop, tools, sub-agents | Work, all on codai |
/v1/messages/count_tokens | Not served; Claude Code treats it as optional |
Client anthropic-beta headers | Ignored — the gateway sets its own betas |
output_config.effort in the request | Ignored — set effort with X-Codai-Effort instead (see headers) |
Troubleshooting
404—ANTHROPIC_BASE_URLends in/v1. Use the roothttps://ai.codai.ro.- Login prompt on first run — project
envblocks only load after the first-run wizard. Put the token in user settings or export it in your shell. Extra inputs are not permitted— setCLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1in the sameenvblock.- A
claude-*model shows up in usage — one of the four model variables is missing.
Sources
Checked 2026-10-02.
Last updated: