
Codex CLI
OpenAI's open-source coding agent for your terminal
Connect with the TokenMix CLI
The official TokenMix CLI sets this up in one command — no manual environment variables:
npx tokenmix codex
It signs you in and points Codex at TokenMix for you. Prefer to configure it by hand? The full steps are below.
Introduction
Codex CLI is OpenAI's open-source terminal coding agent. It reads your files, writes code, runs sandboxed shell commands, and iterates until the task is done. Unlike browser-based tools, Codex runs entirely on your machine. By configuring it with TokenMix, you can use powerful models like gpt-5.5 and gpt-5.4 at TokenMix pricing.
Prerequisites
- macOS, Linux, or Windows (WSL recommended)
- Node.js 22 or later — run
node -vto confirm - A TokenMix account with an API key starting with
sk-tm-→ Register at tokenmix.ai → Dashboard → API Keys
Setup Steps
1. Install Codex CLI
npm install -g @openai/codex
Verify:
codex --version
2. Create the config file
Codex reads its provider configuration from ~/.codex/config.toml. Create the directory and file:
mkdir -p ~/.codex
Open ~/.codex/config.toml in your editor and add:
model = "gpt-5.5"
model_provider = "tokenmix"
[model_providers.tokenmix]
name = "TokenMix"
base_url = "https://api.tokenmix.ai/v1"
env_key = "TOKENMIX_API_KEY"
wire_api = "responses"
3. Set your API key
Add the environment variable to your shell profile (~/.zshrc or ~/.bashrc):
export TOKENMIX_API_KEY="sk-tm-your-key-here"
Reload:
source ~/.zshrc
4. Launch Codex
cd ~/your-project
codex
To use a different model:
codex --model gpt-5.4
Available TokenMix models: gpt-5.5, gpt-5.4
Verify
codex -q "What files are in the current directory?"
Codex should list the directory contents. If you see an authentication error, double-check that TOKENMIX_API_KEY is exported in your current shell.
FAQ
Q: What does wire_api = "responses" mean?
It tells Codex to use the OpenAI Responses API wire format, which is the only format Codex supports. TokenMix is fully compatible with this format.
Q: Can I use Claude models with Codex? Codex is designed around the Responses API which is optimized for GPT models. For Claude models, use Claude Code or Cline instead.
Q: The model name isn't recognized — what should I do?
Make sure the model field in config.toml matches a short_id available in your TokenMix account. You can list available models at tokenmix.ai/models.