Use Codex CLI with TokenMaster
Codex CLI is OpenAI's terminal coding agent. TokenMaster speaks the Responses API it uses, so you can add TokenMaster as a model provider in config.toml and run Codex with GPT, Claude, Gemini or DeepSeek models.
You will need
- An API key starting with tm- (Console → API keys) — Get an API key
- Base URL:
https://tokenmaster.store/v1 - A model ID, e.g.
openai/gpt-6-sol(see the model list)
Setup
- Create a
tm-…key in the console and export it:export TOKENMASTER_API_KEY=tm-xxxxxxxx(add it to your shell profile to keep it). - Add the provider below to
~/.codex/config.toml.wire_apimust be"responses", and the base URL ends in/v1. - Run
codex. To switch model, changemodelto any TokenMaster model ID, e.g.anthropic/claude-sonnet-5.5.
model = "openai/gpt-6-sol" model_provider = "tokenmaster" [model_providers.tokenmaster] name = "TokenMaster" base_url = "https://tokenmaster.store/v1" env_key = "TOKENMASTER_API_KEY" wire_api = "responses"
Good to know
- TokenMaster does not store conversations: Codex sends the full history each turn, which is how it works with custom providers. OpenAI-hosted tools (Codex's built-in web search) are not available — leave them off.
- Reasoning effort (
model_reasoning_effort) is passed to OpenAI models; other vendors' models ignore it. - Codex may warn that it has no metadata for the model name; this is harmless. Set a spending limit on the key in the console — agents can run many requests in a row.
- Not available through TokenMaster: image generation, speech, rerank, the Assistants API, and OpenAI-hosted tools. Chat Completions, the Responses API (stateless), the Anthropic Messages API and embeddings are available.
Checked against Codex CLI latest on 2026-10-19. Menu names can change between versions.
Troubleshooting
- 401 / invalid API key — check the key was copied in full and has not been deleted in the console.
- 404 — the base URL is wrong. It must end in /v1 unless the guide says otherwise.
- Model not found / not available — use the exact ID from the model list (vendor/model, lowercase). Some vendors are not available in every region.
- Errors mentioning /responses — the tool is using OpenAI's Responses API. TokenMaster accepts it, but statelessly (no previous_response_id) and without OpenAI-hosted tools; if the tool relies on those, switch it to Chat Completions as noted above.
- 402 / insufficient balance — top up in the console; requests are refused rather than run up a debt.