Run Codex CLI on apiToken.sale
Codex CLI runs entirely on API-key authentication when you give it a custom model provider. One TOML profile points it at apiToken.sale, and your prepaid balance covers every session — no ChatGPT login, at up to 70% below official spend.
·
Create the profile
Save this as ~/.codex/apitoken.config.toml. A named profile leaves your default Codex configuration and any ChatGPT login untouched — you opt in per run.
# ~/.codex/apitoken.config.toml model = "gpt-5.6-sol" model_provider = "apitoken" [model_providers.apitoken] name = "apiToken.sale" base_url = "https://openai.api.apitoken.sale/v1" wire_api = "responses" env_key = "APITOKEN_API_KEY"
env_key names the environment variable Codex reads the key from — the secret stays in your shell, never in the TOML file.
See also: OpenAI-compatible API quickstart: Responses and Chat Completions
Run and verify
export APITOKEN_API_KEY=sk-pool-••• codex --profile apitoken
- Always pass --profile apitoken explicitly so there is no ambiguity about which provider — and which env var — is active.
- Switch models per project by editing the model line: gpt-5.6-sol for the hardest work, gpt-5.6-terra for the daily driver, gpt-5.6-luna for fast cheap steps.
- GET https://openai.api.apitoken.sale/v1/models with the same Bearer key lists the currently enabled set.
wire_api = "responses" is the right value for this gateway — it serves both Responses and Chat Completions, and Codex streams over Responses. Set it only to "chat" if a specific client requires the classic shape.
Errors you might hit
- Missing APITOKEN_API_KEY — the variable named by env_key is not exported in the shell that runs codex. Export it in that same shell, or in your shell profile.
- stream error: unexpected status 401 — the key is wrong, revoked, or the base_url lost its /v1 suffix. Reproduce with curl outside Codex to isolate which half is broken.
- stream error: unexpected status 404 — the model ID is not enabled; check GET /v1/models instead of assuming.
- 402 — the shared prepaid balance needs a top-up; backoff will not fix it.
The full Codex error playbook — config.toml, auth.json, stream errors →
Frequently asked questions
Do I need a ChatGPT account or subscription?
No. With a custom model_providers profile and the provider's API key in the environment, Codex runs entirely on API-key authentication — the ChatGPT login in auth.json is irrelevant.
Does this change my default Codex setup?
No. The profile lives in its own file and activates only when you pass --profile apitoken. Your default configuration and login stay as they were.
Is the discount the same as for Claude?
Yes. GPT-5.6 usage is metered at official OpenAI token rates and your active B2C discount — 60% up to 70% — applies to the same prepaid balance.
Responses or Chat Completions for wire_api?
Use wire_api = "responses" — the gateway serves both, and Codex is built around the Responses stream. The Chat Completions shape exists for clients that require it.
Create an account with Google or GitHub and test the gateway with $10 of included API usage.