codai docs
Integrations

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

~/.codex/config.toml
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_key names the variable Codex reads; the key itself never goes into the file.
  • Codex appends /responses to base_url, so keep /v1 and nothing after it.
  • To keep your OpenAI setup as the default, put model and model_provider in a profile ([profiles.codai]) and start with codex --profile codai.
  • Codex has no built-in metadata for the name codai and prints a "fallback metadata" warning. It is harmless.

MCP

~/.codex/config.toml
[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

FeatureWith codai
Chat, function tools, streamingExpected to work — Responses requests are translated to Chat Completions inside the gateway
reasoning.effortMapped onto codai effort tiers (xhigh → max)
apply_patch (freeform tool)Not forwarded — see the warning above
previous_response_id, background mode, built-in web_searchRejected with 400 bad_request
Reasoning summariesNot returned

Troubleshooting

  • 404 — base_url lacks /v1 or has /responses on it.
  • 401 invalid_api_key — CODAI_API_KEY is not set in the environment Codex started from.
  • 400 bad_request mentioning previous_response_id — this Codex build chains responses; codai needs the full input on every request.
  • 429 — read error.code; see limits and pricing.

Sources

Checked 2026-10-18 against the Codex source (codex-rs config and provider types).

On this page