Run Codex on Stav
Point OpenAI's Codex CLI at Stav with one config file, pick a model that runs on EU compute, and know which Codex features change when you do.
Codex is OpenAI's coding agent for the terminal. It reads your code, edits files and runs commands. It can send its model traffic to any provider that speaks the OpenAI Responses API, so it runs on Stav with configuration only.
Point it at Stav and every turn is billed to your Stav credits, shows up in your request log, and follows your workspace policy. Pick a model that is not an OpenAI model and the work runs where that model's Inference Provider runs — for example in France.
Tested with Codex 0.162.1 on macOS.
Before you start
- A Stav API key. See Authentication.
- Codex installed, for example with
npm install -g @openai/codexorbrew install codex.
Set it up
Add a provider to ~/.codex/config.toml:
model = "zai-org/glm-5-2"
model_provider = "stav"
[model_providers.stav]
name = "Stav"
base_url = "https://api.stav.ai/v1"
env_key = "STAV_API_KEY"
wire_api = "responses"
Then put your key in the environment Codex starts from:
export STAV_API_KEY="sk_stav_live_..."
- Write the base URL with
/v1. Codex adds/responsesitself. wire_apimust beresponses. Current Codex releases refusechat.- Codex sends your key as
Authorization: Bearer. Do not put the key in the config file.
Run codex. The header shows provider: stav and the model you set.
Stav credits pay for it. With this provider, Codex does not use your ChatGPT plan. Every turn is charged to your Stav credits.
Pick a model
Set model to any chat model in the Stav catalogue, by its full slug. To change it for one run, use codex -m <slug>.
| Model value | What happens |
|---|---|
An open-weights model, such as zai-org/glm-5-2 | Stav translates each request for the provider and the answer back. Tested end to end: served in France by Scaleway |
auto | Your workspace's default Router picks a model for each request. It follows the Router's rules, so it can pick a US-served model unless your policy blocks that |
An OpenAI model, such as openai/gpt-5.5 | Forwarded to OpenAI's own Responses API. You get Stav's logging, spend limits and key controls — not EU compute |
A named model can be served by more than one Inference Provider, and they are not all in the EU. To keep every request in Europe, set a sovereignty floor or a compute region for your workspace. See Keep traffic sovereign.
For an agent, name a model. Codex sends a long prompt and many tools on every turn, and the Router picks for value, not for speed. In our test, auto took over five minutes to answer one word.
What works
Tested on zai-org/glm-5-2:
| Feature | Result |
|---|---|
| Streaming | Works |
| Tool calls (read, edit, run commands) | Works |
| A full agent task (fix a bug, run the file) | Works |
Reasoning level (model_reasoning_effort) | Sent to the model when it has levels. GLM-5.2 on Scaleway has none: the X-Stav-Reasoning-Effort response header says fixed |
Reasoning carried between turns (reasoning.encrypted_content) | Not available on a translated model; named in X-Stav-Dropped-Params. The agent still works |
| Codex's built-in web search | Not available on a translated model; named in X-Stav-Dropped-Params. Turn it off — see Tips |
Stored conversations (store: true) | Refused by name. Codex sends store: false, so this does not affect it |
An OpenAI model gets the request as Codex sent it, so Codex's features behave as they do on OpenAI's own API. We tested one turn on openai/gpt-5.5; the reasoning level reached OpenAI.
Tips
-
Turn off web search on a non-OpenAI model. Codex offers the model a hosted web search on every turn. Only OpenAI can run it. Add
web_search = "disabled"at the top ofconfig.tomland the tool is no longer sent. -
The warning about model metadata is harmless. Codex prints
Model metadata for 'zai-org/glm-5-2' not found. It is Codex's own list, not an API error. The run continues. -
Tell Codex the real context window. Without metadata, Codex assumes about 272,000 tokens. For a model with another window, set
model_context_window, for example1000000for GLM-5.2. The model page in the catalogue shows the window. -
Some traffic does not go through Stav. Codex sends usage metrics to OpenAI and checks for updates. To stop both, add
check_for_update_on_startup = falseat the top ofconfig.toml, and this section at the end:[analytics] enabled = false -
Scripts: close standard input.
codex execwaits for more input when standard input is open. Run it ascodex exec "your task" < /dev/nullin scripts and CI. -
Codex does not read Stav's model list. It never calls
/v1/models. Set the model inconfig.tomlor with-m.
Troubleshooting
| What you see | Cause | Fix |
|---|---|---|
Reconnecting... 5/5, then unexpected status 401 Unauthorized: Invalid or revoked API key. | The key is wrong, revoked or expired. Codex retries five times first | Create a new key in Your workspace → Connect → API keys and update STAV_API_KEY |
404 Not Found on every request | The base URL has no /v1 (Codex calls /responses) or has it twice (/v1/v1/responses) | Use https://api.stav.ai/v1 |
Codex will not start: wire_api = "chat" is no longer supported | An old config | Set wire_api = "responses" |
codex exec prints Reading additional input from stdin... and stops | Standard input is open | Add < /dev/null |
For Stav's error codes, see Errors.
Check it worked
Open Your workspace → Monitor → Request log. Each turn is one row, with the model, Inference Provider, country and cost. A short task is usually 3–5 rows. See Request log and prompt capture.