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 codex

3. 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
codex

Windows:

setx TOKENMILO_API_KEY "sk-your-tokenmilo-key"   # then reopen the terminal
codex

5. Use it

codex                      # interactive
codex -m gpt-6-astra       # choose a model
codex exec "add unit tests for this project"   # non-interactive

6. Available GPT models

Model IDInput / output per 1MSaving
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 setx you must open a new terminal).
  • 404 / model not found — base_url is missing /v1 or 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

Need an API key?

Sign up at TokenMilo, top up, and create a key in the console in under a minute.

Get API key See all models