Codex (CLI and Desktop)
Codex uses gateway mode: the local daemon masks requests and restores responses. It works whether you sign in with ChatGPT or use an OpenAI API key.
Route it through Latet
Section titled “Route it through Latet”Codex CLI and Codex Desktop read the same configuration file, ~/.codex/config.toml (or
$CODEX_HOME/config.toml if you set CODEX_HOME). One line there routes Codex through Latet.
latet global-install, or latet agents apply codex, writes it for you. It asks Codex how you sign in
(codex login status) and picks the matching address:
# Signed in with ChatGPT:openai_base_url = "http://127.0.0.1:5283/backend-api/codex"
# With an OpenAI API key instead:# openai_base_url = "http://127.0.0.1:5283/openai/v1"The rest of the file, comments included, stays as it was, and a backup is taken first. Restart Codex (or the Codex Desktop app) afterwards.
- Codex older than 0.115 ignores
openai_base_url.latet doctorwarns about it: update Codex (npm i -g @openai/codex).latet global-installandlatet agents apply codexleave such a Codex as it is and say why, since that line would not route it. Until you update it,latet codexhands Codex the address inOPENAI_BASE_URL, the only variable that Codex reads, in place of the one your shell sets.latet codexdoes not start a Codex that has a provider of its own (see below): that Codex would go round Latet. - If you switch between ChatGPT sign-in and an API key later, run
latet agents apply codexagain, so the address matches.
Without touching config.toml, run one session through Latet with the wrapper. It starts the
daemon if needed and passes every argument to codex:
latet codexlatet codex exec "add the payments key from .env to config/local.toml"latet run codex is the same as latet codex, which picks the address for your sign-in.
On a computer connected to a Latet server, latet codex starts the interactive session and
codex exec, resume and fork; it refuses Codex’s other subcommands, such as review or mcp,
which it cannot send through the server.
A provider of your own (Azure OpenAI, your company’s gateway, Mistral…) goes through Latet
too. Only its base_url moves to Latet; its key and everything else stay as you wrote them.
- For a session,
latet codexmoves the providers ofconfig.tomland of the profile you name (--profile work), with-c model_providers.<id>.base_url=.... Codex reads no other file, and it refuses to start on an option for a provider it does not load. A Codex older than 0.115 cannot take those options: with a provider of its own,latet codexdoes not start it and says to update Codex. - For good,
latet global-installchanges each address in the file that writes it, every profile’s file included, since a profile can switch Codex to any of those addresses.
A profile’s own openai_base_url (a company’s address in place of OpenAI’s) goes through Latet the
same way. See Company endpoints.
How it behaves
Section titled “How it behaves”- With a ChatGPT sign-in, Codex talks to the provider over a WebSocket. The daemon masks every request Codex sends on it and restores the events that stream back. With an API key the same happens over HTTP.
- The provider sees surrogates. Codex sees originals, in the answer text and in tool-call
arguments, so the commands it runs and the patches it applies use the real values.
How it works follows a key from
.envthrough a Codex turn, step by step. - Compressed request bodies are decoded, masked and compressed again. A body Latet cannot decode is refused, not sent unchecked.
- Your sign-in token or API key is forwarded unchanged; its value is never written to logs or to the dashboard.
- If the daemon is not running, Codex cannot reach the provider. That is deliberate: nothing goes out unmasked.
- Codex reads files with shell commands, so strict data mode
covers the files it reads too. Name its database tool in
data_toolsto cover only that.
Tested live: the Codex CLI signed in with ChatGPT. Codex Desktop reads the same config.toml; if
something does not work there, please open an issue.
To stop using Latet, run latet agents revert codex, or latet global-uninstall for every agent. See
Uninstall.
© 2026 Emanuele Casabona · VAT IT02293040990 · Privacy policy · Legal notice · latet.ai