Codex CLI
Point OpenAI Codex CLI at codai through a custom model provider on the Responses API, plus the codai MCP server.
Codex CLI talks to codai through a custom model provider in ~/.codex/config.toml: base URL https://ai.codai.ro/v1, wire API responses, your key from an environment variable and the model codai.
Not yet verified end to end
This setup follows Codex's configuration schema and codai's Responses API support, but we have not yet run a full Codex agent session against codai. Codex edits files with a freeform apply_patch tool; codai's Responses layer forwards only function tools, so file edits may fail or fall back to shell commands. If something breaks, tell us at hub.codai.ro support and use a tested tool in the meantime.
Before you start
- A codai key from hub.codai.ro → Keys → Create key (details in the quickstart).
- Codex CLI installed. Recent versions accept only
wire_api = "responses"for custom providers;"chat"is rejected.
Set the key in the shell that starts Codex:
$env:CODAI_API_KEY = 'codai_xxxxxxxx'Configure the provider
model = "codai"
model_provider = "codai"
[model_providers.codai]
name = "codai"
base_url = "https://ai.codai.ro/v1"
env_key = "CODAI_API_KEY"
wire_api = "responses"env_keynames the variable Codex reads; the key itself never goes into the file.- Codex appends
/responsestobase_url, so keep/v1and nothing after it. - To keep your OpenAI setup as the default, put
modelandmodel_providerin a profile ([profiles.codai]) and start withcodex --profile codai. - Codex has no built-in metadata for the name
codaiand prints a "fallback metadata" warning. It is harmless.
MCP
[mcp_servers.codai]
url = "https://ai.codai.ro/mcp"
bearer_token_env_var = "CODAI_API_KEY"The same key authenticates the codai MCP server; tools are listed on clients.
What works and what does not
| Feature | With codai |
|---|---|
| Chat, function tools, streaming | Expected to work — Responses requests are translated to Chat Completions inside the gateway |
reasoning.effort | Mapped onto codai effort tiers (xhigh → max) |
apply_patch (freeform tool) | Not forwarded — see the warning above |
previous_response_id, background mode, built-in web_search | Rejected with 400 bad_request |
| Reasoning summaries | Not returned |
Troubleshooting
404—base_urllacks/v1or has/responseson it.401 invalid_api_key—CODAI_API_KEYis not set in the environment Codex started from.400 bad_requestmentioningprevious_response_id— this Codex build chains responses; codai needs the full input on every request.429— readerror.code; see limits and pricing.
Sources
Checked 2026-10-18 against the Codex source (codex-rs config and provider types).