Codex.
Codex CLI is OpenAI’s terminal agent. It speaks the OpenAI format, which is the same one NaN speaks, so it connects directly: all you have to do is declare a new provider.
You can skip all of this The NaN CLI writes this configuration for you: Setup tab,
eto paste your key,spaceto mark Codex,cto apply.
What you need
- Codex CLI installed.
- Your NaN API key in an environment variable.
export NAN_API_KEY="sk-your-key"
Codex reads the key from the environment variable you point it at, not from the configuration file. That way it does not end up written in a file you might push to a repository by accident.
Configuration
Edit ~/.codex/config.toml:
model_provider = "nan"
model = "glm5.3-flash"
model_context_window = 1048576
[model_providers.nan]
name = "NaN"
base_url = "https://api.nan.builders/v1"
env_key = "NAN_API_KEY"
wire_api = "responses"
Four details that matter:
wire_api = "responses"is the only value Codex still takes. Since 0.154,"chat"does not just work worse: the file does not load and Codex does not open. This page used to recommend"chat"because/responsesanswered in one go; it streams the answer now, except onqwen3.6andgemma4(see below).model_context_windowis needed because Codex has no metadata for the cluster’s models: without it, it guesses a window and compacts the conversation long before it has to. Use the one for the model you run; they are in Models.- The provider identifier cannot be
openai,ollamaorlmstudio, which are reserved. That is why it is callednan. base_urlends at/v1and nothing more. Do not add the endpoint path.
Check that it works
codex
Ask it for something short, for example to list the files in the directory and summarize what the project does. If it answers, it is already working against the cluster.
If you see an authentication error, the usual cause is that NAN_API_KEY is not exported in the terminal you are launching codex from.
Switching models
You can change it without touching the file:
codex --model deepseek-v4-flash
With one catch: the model_context_window in the file does not follow the model, so a 262,144-token model keeps the window of whichever one you declared, and Codex compacts against a window that is not there.
To keep the cluster’s models at hand, each with its own window, write one file per model in ~/.codex/. Codex calls it a profile: your config.toml with that file layered on top.
# ~/.codex/nan-qwen36.config.toml
model = "qwen3.6"
model_provider = "nan"
model_context_window = 262144
codex --profile nan-qwen36
Mind the name: Codex wants “a plain name” and rejects dots, so qwen3.6 is not usable as a profile even though it is fine as a model.
The rest of your config.toml - your provider, your MCP servers, your permissions - still applies; the profile only overrides what it names. The NaN CLI writes them for you, one per chat model on the cluster, prefixed nan- and with the dots dropped: nan-glm53-flash, nan-deepseek-v4-flash, nan-mimo-v26-flash, nan-qwen36… Disconnecting Codex takes them away again.
Recommended model
glm5.3-flash for coding work. If you have the premium tier, glm5.3. For one-off questions that do not touch files, deepseek-v4-flash is more than enough.
Known issues
- Codex’s cloud features do not apply. Once you declare a provider of your own, everything goes to NaN from your machine.
- Reasoning looks different depending on the model. The cluster’s models emit their reasoning trace their own way, and Codex does not always present it the way it does with OpenAI’s models.
wire_api = "chat"in an older file. Codex 0.154 dropped it: if you have it, neither the CLI nor the desktop app opens. Change it to"responses", or go through the NaN CLI’s Setup, which repairs it for you.- A repeated
model_context_window. NaN CLI versions before 0.1.20 appended one at the end of the file on every setup run. Two of them is a duplicate key and Codex will not load the file: the CLI saysduplicate keyand the desktop app opens an error dialog and nothing else. 0.1.20 leaves one and puts it where it is read from. 401 This API key does not have access to the requested model. Despite the wording, the key is usually fine: the model is one the cluster does not serve. Eithermodel_providerpoints at the cluster butmodelis still an OpenAI one, or the model has been retired -mimo-v2.5is nowmimo-v2.6-flash. Check the id against Models. NaN CLI 0.1.30 swaps thenan-mimo-v25profile fornan-mimo-v26-flashthe next time you run its Setup.- On
qwen3.6andgemma4the answer still arrives all at once at the end of the turn. It is not a hang: on those two the cluster’s/responsesholds the answer until it is complete. Every other model streams it as it is written. Model metadata for ... not found. Defaulting to fallback metadataon every turn. It is noise: Codex prints it before it reads yourmodel_context_window, and the window it ends up using is yours.