Codex: connect a cheap AI API
Codex speaks the /v1/responses protocol, and ours is implemented rather than emulated — context compaction and multi-step sessions keep working. Setup is one provider block in ~/.codex/config.toml.
Codex
OpenAI Codex CLI
Create an API key on the Keys page and copy it.
Install Node.js 18+, then the Codex CLI:
npm install -g @openai/codexAdd the provider to ~/.codex/config.toml (user-level only — Codex ignores project-local configs):
model = "gpt-5.6-sol"
model_provider = "cheapai"
[model_providers.cheapai]
name = "CheapAI"
base_url = "https://cheapai.io/v1"
env_key = "CHEAPAI_API_KEY"
wire_api = "responses"
requires_openai_auth = trueCreate ~/.codex/auth.json so Codex stops treating you as signed in with an OpenAI account:
{
"auth_mode": "apikey",
"OPENAI_API_KEY": "YOUR_API_KEY"
}Export your key — macOS / Linux (add to ~/.zshrc for persistence):
export CHEAPAI_API_KEY="YOUR_API_KEY"Windows PowerShell: $env:CHEAPAI_API_KEY = "YOUR_API_KEY"
Run codex. The model is any slug from our catalog (e.g. gpt-5.6-sol, claude-opus-4-8) without a vendor prefix.
wire_api = "responses" — Codex removed the chat mode in early 2026. The provider id can't be openai / ollama / lmstudio (reserved) — that's why we use cheapai.Replace YOUR_API_KEY with a real key from the Keys section.
Codex — common questions
Why can't the provider be named openai?
The ids openai, ollama and lmstudio are reserved inside Codex — you can't override their base URL. Use your own block under a different name, for example cheapai.
Does wire_api = "chat" work?
No — that mode was removed from Codex back in February 2026. Only "responses" remains, so the old «switch to chat» advice no longer applies.
Codex ignores the project config?
That's expected: only the user-level ~/.codex/config.toml is read; a project-local .codex/config.toml is ignored.
Get a key and plug it into Codex
Claude, GPT, Gemini and Grok on one key · pay in ₽, USDT or by card · no VPN
Get API keyGuides for other tools
See also: model prices · API reference and FAQ