Overview
Codex CLI is OpenAI’s terminal coding agent. It talks to the Responses API, which SaveGate serves athttps://api.savegate.ai/v1/responses, so you can run Codex against your
SaveGate account with one config file and one environment variable.
Nothing about your workflow changes: Codex still reads your files, runs
commands, and edits code. Only the endpoint moves.
Prerequisites
-
Codex CLI installed:
Already have it?
codex updatepulls the latest build. -
A SaveGate API key (starts with
sg-)
Setup
1
Add SaveGate as a model provider
Create or edit
~/.codex/config.toml:~/.codex/config.toml
2
Export your key
~/.zshrc, ~/.bashrc) so it survives new
terminals. env_key in the config names the variable — Codex reads the key
from there, so the key itself never goes into the config file.3
Verify
SAVEGATE_OK. If you do, the agent loop, tool calls, and
billing are all working.Available models
Every model below was verified by running a complete Codex session against it — file read, tool call, and answer — not just by checking that the endpoint accepts a request. That distinction matters: several models accept a Responses call but break part-way through Codex’s agent loop.gpt-4o-mini or gpt-5.4-mini
for routine work.
Using a separate profile
To keep SaveGate settings out of your default Codex config, put them in their ownCODEX_HOME:
Known warning
On startup Codex may print:model_context_window and model_max_output_tokens in config.toml
does not silence it; the warning is emitted before those are consulted.
Troubleshooting
400 or MISSING_CONTEXT
400 or MISSING_CONTEXT
Almost always a missing
wire_api = "responses" in the provider block.
Without it Codex sends Chat Completions payloads to a Responses endpoint.Model not found
Model not found
Model IDs are case-sensitive and must match the table above exactly.
gpt-5.3-codex works; gpt-5.3-Codex and codex-5.3 do not.Session appears to hang
Session appears to hang
Codex sends large contexts and reasoning models take time to produce a first
token. A minute of silence on a big repository is normal. If nothing arrives
after several minutes, re-run with a smaller prompt to isolate the problem.
What Codex uses
For reference, a Codex session talks to exactly one SaveGate endpoint:previous_response_id, so no server-side session state
is needed on your side. Codex does not call /v1/models, and does not use the
response retrieve, cancel, or delete endpoints.