TokenFlux Docs

Codex

Set up Codex with a TokenFlux API key, endpoint and model. Verify the connection and resolve common errors.

OpenAI Codex CLI connects to TokenFlux through the Responses API. Requests are charged to your TokenFlux balance.

This guide was tested with Codex CLI 0.163.0 and gpt-6-luna for streaming replies.

Before you start

  1. Start with Codex installed. Configuration details are in the official Codex configuration reference.
  2. Create and copy a key on the web app’s API keys page. The full key is shown only once.
  3. Check that your balance is above zero on Billing.
  4. Copy a model ID from Models and pricing and check its supported protocols.

Add a Responses API provider

Set the key in Bash or Zsh:

export TOKENFLUX_API_KEY="YOUR_TOKENFLUX_KEY"

Merge these settings into ~/.codex/config.toml. Replace YOUR_MODEL_ID with your model ID:

model = "YOUR_MODEL_ID"
model_provider = "tokenflux"

[model_providers.tokenflux]
name = "TokenFlux"
base_url = "https://tokenflux.ai/v1"
env_key = "TOKENFLUX_API_KEY"
wire_api = "responses"
supports_websockets = false

Replace YOUR_TOKENFLUX_KEY with the key you copied. Keep the key out of Git.

Codex sends HTTP streaming requests to /v1/responses. The custom provider reads the key from TOKENFLUX_API_KEY; it does not need a ChatGPT login. Keep any unrelated settings when you update the file.

Choose a model

Set model to a full TokenFlux model ID that supports Responses and tool calls. Override it for one run with codex exec --model YOUR_MODEL_ID "Hello".

Verify the connection

Run these commands in a scratch directory. If the client asks for file access, check the path before you approve it.

printf 'TOKENFLUX_GUIDE_OK\n' > marker.txt
codex exec --skip-git-repo-check \
  "Read marker.txt with a shell tool and return its contents"

The reply should contain TOKENFLUX_GUIDE_OK. Check the model, key, token count and cost on Usage. Delete marker.txt after the test.

Troubleshooting

Codex asks for an OpenAI login. Check that model_provider = "tokenflux" is a top-level setting and that env_key names the exported variable. A ChatGPT subscription does not pay for TokenFlux calls.

404 or a protocol error. Use wire_api = "responses" and the base URL ending in /v1. Do not configure Chat Completions for Codex.

The wrong provider is used. Check active profiles and project settings for overrides of model_provider or model.

401, 429 or a model error. Check that the key is enabled, the full model ID is correct, and your account has balance and available rate limits. Do not switch models automatically.

API reference

See Responses, Models and API overview.

On this page