Skip to main content
Codex CLI talks to NagaAI through /v1/responses. File editing with apply_patch and MCP tools both work with any chat model that supports tools. The keys below follow the Codex configuration reference.

Before you start

You need a NagaAI API key and Codex CLI, installed from the official repository.

Connect Codex CLI

1

Add the provider

Codex reads custom providers only from ~/.codex/config.toml, not from a project .codex/config.toml.
model_context_window tells Codex the window of a model it doesn’t know. Take the value from limits.context_window of the model’s chat operation in /v1/models.
2

Export the key and start Codex

3

Check the connection

Send a short prompt. The request appears in Logs in your dashboard.

Tools through NagaAI

Codex sends its own tool formats: apply_patch as a freeform tool, MCP tools grouped by server, and a compact tool list for gpt-6-* and gpt-5.6-*. NagaAI passes all of them to the model and returns the calls in Codex’s item types, so file editing and MCP tools work. Remote compaction is off for custom providers, so Codex compacts the conversation locally.

Troubleshooting

401 invalid_api_key

Codex found no key or a wrong one. Export NAGA_API_KEY in the shell that starts codex, and check that env_key in the config names the same variable.

400 model_not_found

The model value isn’t a NagaAI model id. Pick one from /v1/models that serves the responses endpoint.