Configure Codex CLI to use OpenDunes as its model provider, billed in DA.
Codex CLI is OpenAI's terminal-based coding agent. It accepts a custom base URL, so you can point it at OpenDunes and have all usage billed in Algerian Dinars while accessing any model in the catalog.
Codex CLI reads two variables — the API base URL and the key:
export OPENAI_BASE_URL="https://opendunes.com/v1"
export OPENAI_API_KEY="$OPENDUNES_API_KEY"Because Codex CLI uses the OpenAI SDK internally, OPENAI_BASE_URL overrides the default api.openai.com endpoint. Set OPENAI_API_KEY to your OpenDunes key (not an OpenAI key).
Add both lines to your shell profile so they apply automatically:
# ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://opendunes.com/v1"
export OPENAI_API_KEY="sk-0a1b2c3d..." # your OpenDunes keyReload with source ~/.zshrc (or open a new terminal).
Pass the model flag when you invoke Codex:
codex --model openai/gpt-5.4 "Refactor the auth middleware to use middleware chaining"Use the provider/model slug format from the OpenDunes catalog. Models with the tools capability flag work best with Codex's agentic loop (file reads, writes, shell commands).
codex --model openai/gpt-5.4 "Print hello world in Python"You should see the model generate and optionally run a short script. Check Dashboard → Analytics to confirm the request was routed through OpenDunes.
Each Codex session can generate many sequential requests as the agent reads files and iterates on solutions. To avoid unexpected spend:
codex-cli key in Dashboard → Keys.OPENAI_API_KEY in your shell.When the budget is hit, Codex will receive a 402 error (payment_required) and stop. Raise the cap or top up your balance to continue.
| Symptom | Likely cause | Fix |
|---|---|---|
401 authentication | Env var not exported in current shell | Re-run export OPENAI_API_KEY=... |
404 not_found | Wrong slug format | Use provider/model (e.g., openai/gpt-5.4) |
Codex ignores OPENAI_BASE_URL | Older Codex version | Update to the latest release |
402 payment_required | Key cap reached, or balance at zero | Raise the key's cap or top up DA |