Codex CLI setup
No ChatGPT subscription needed. Add one custom provider to Codex’s config and run it on GPT-6 models for about a tenth of the official price.
Updated 2026-11-16
1. Before you start
Sign up at api.tokenmilo.com, top up and create a key. The OpenAI-compatible base URL is https://api.tokenmilo.com/v1 (with /v1).
2. Install Codex CLI
npm install -g @openai/codex
# or on macOS
brew install codex3. Add the TokenMilo provider
Edit ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml):
# ~/.codex/config.toml
model = "gpt-6.1-sol"
model_provider = "tokenmilo"
[model_providers.tokenmilo]
name = "TokenMilo"
base_url = "https://api.tokenmilo.com/v1"
env_key = "TOKENMILO_API_KEY"
wire_api = "responses"4. Set your API key
export TOKENMILO_API_KEY=sk-your-tokenmilo-key # add to ~/.zshrc or ~/.bashrc
codexWindows:
setx TOKENMILO_API_KEY "sk-your-tokenmilo-key" # then reopen the terminal
codex5. Use it
codex # interactive
codex -m gpt-6-astra # choose a model
codex exec "add unit tests for this project" # non-interactive6. Available GPT models
| Model ID | Input / output per 1M | Saving |
|---|---|---|
| gpt-6-astra | $0.855 / $4.28 | −91% |
| gpt-6.1-sol | $0.171 / $0.855 | −91% |
| gpt-6.1-terra | $0.086 / $0.432 | −91% |
| gpt-6-sol | $0.171 / $0.855 | −91% |
| gpt-6-luna | $0.0081 / $0.043 | −91% |
| gpt-5.6-sol | $0.342 / $2.05 | −90% |
| gpt-5.6-terra | $0.171 / $1.03 | −91% |
| gpt-5.6-luna | $0.017 / $0.099 | −92% |
7. Troubleshooting
- 401 — the environment variable isn’t set in this shell (after
setxyou must open a new terminal). - 404 / model not found — base_url is missing
/v1or the model ID is wrong. - Still asks for ChatGPT login — check that
model_provider = "tokenmilo"matches the[model_providers.tokenmilo]table name.
FAQ
Do I need a ChatGPT subscription for Codex CLI?
No. With a custom provider, Codex bills your TokenMilo API key per token.
Why wire_api = "responses"?
Codex is built on the OpenAI Responses API, which TokenMilo’s GPT models support.
Does the Codex VS Code extension use the same config?
Yes — the extension and the CLI both read ~/.codex/config.toml.
Related guides
- Claude Code setup — Run Claude Code with a TokenMilo key on macOS, Linux and Windows.
- Cursor setup — Add Claude and GPT models to Cursor with your own key.
- Cline setup (VS Code) — Configure the Cline coding agent with Claude via TokenMilo.
- Cherry Studio setup — Chat with Claude and GPT in the Cherry Studio desktop app.
- Quickstart — Get a key and make your first request in minutes.
Need an API key?
Sign up at TokenMilo, top up, and create a key in the console in under a minute.