Codex CLI
Set Codex CLI up on OpenDunes once, with a profile for each kind of work.
Codex sends every request to POST /v1/responses, in the Responses shape: it speaks no other. Coding agents shows its provider block; this recipe adds the key it reads, a second profile, and a run from a script.
- Install Codex CLI.
- Add OpenDunes as a provider.
- Add a profile for harder work.
- Check the connection.
- Run it from a script.
1. Install Codex CLI
| With | Install line |
|---|---|
| npm | npm install -g @openai/codex |
| Homebrew | brew install --cask codex |
Run codex --version to see it answer.
2. Add OpenDunes as a provider
Create an API keyAPI keyThe key you create and send with every request that calls a model.More on API keys → for Codex alone, and cap it on API Keys: an agent sends many requests for one task, and the cap stops this key alone (API keys shows how). Put it in your shell profile, ~/.zshrc or ~/.bashrc:
export OPENDUNES_API_KEY="…"Then write the provider into ~/.codex/config.toml:
model = "anthropic/claude-sonnet-4.5"
model_provider = "opendunes"
[model_providers.opendunes]
name = "OpenDunes"
base_url = "https://opendunes.com/v1"
env_key = "OPENDUNES_API_KEY"
wire_api = "responses"
supports_websockets = false
request_max_retries = 4| Key | Holds |
|---|---|
model | the model IDModel IDThe name a request calls a model by, lab/model, copied from Models.More on Models → Codex starts on |
model_provider | the provider it sends to: the name of the block below it |
base_url | the address, with /v1 |
env_key | the variable Codex reads the key from: no codex login is needed |
wire_api | responses, the one shape Codex speaks |
supports_websockets | false: Codex sends each request over HTTPS |
request_max_retries | how often Codex tries a request again after a failure |
The provider goes in ~/.codex/config.toml, in your home folder. Codex ignores model_provider and model_providers in a project's .codex/config.toml.
3. Add a profile for harder work
A profile is a file of its own, ~/.codex/‹name›.config.toml, whose keys win over config.toml when you start Codex with it. This one keeps the OpenDunes provider and changes the model and how long it thinks. Save it as ~/.codex/deep.config.toml:
model = "openai/gpt-5.5"
model_reasoning_effort = "high"Start Codex with it for a hard change, and without it for the day's work:
codex --profile deepEach model is charged at its own rate, shown on its page in Models. Thinking longer writes more tokens, and each one is charged.
4. Check the connection
Start codex in your project and run /status: it shows the provider and the model of the session. /model switches the model for the session.
The request is on Activity, in the app, with its charge in DADAThe Algerian dinar, the one currency the docs show.More on Balance and charges →.
5. Run it from a script
codex exec runs one task without the interface, prints the result and exits: a script, a git hook or a CI job can call it.
codex exec "List the functions in src/ that have no test."It reads the same config.toml, so it runs on OpenDunes with the same key. In CI, set OPENDUNES_API_KEY from the CI's secrets, and give that job a key and a cap of its own.
Errors
| Status | Means | Do |
|---|---|---|
| 401 | the key is missing, wrong, paused, revoked or expired | check OPENDUNES_API_KEY is set in the terminal Codex starts from |
| 402 | the balanceBalanceWhat you can spend, in DA.More on Balance and charges → is at zero or below, cannot pay the request's hold, or the key's cap is spent | make a depositDepositMoney entering your balance, by CIB or Edahabia card.More on Balance and charges →, or raise the cap |
| 404 | the model ID is not on sale | copy the ID from Models |
Every other status: Errors and retries.
Next: Codex Desktop · Automatic code review
Last modified on