Skip to main content
Use in AI Tools

Codex

Use Token Plan with Codex

Codex is a coding agent from OpenAI.

Applicability

This topic applies to earlier versions of Codex (such as 0.80.0) that support the Chat/Completions API. Newer versions of Codex use the Responses API, which Token Plan currently supports only for the qwen3.6-plus model.

Install Codex

  1. Install or update Node.js (v18.0 or later).
  2. Install Codex 0.80.0 or earlier (required for Chat and Completions APIs support):
The latest version of Codex no longer supports the Chat/Completions API. To use all models in Token Plan, run the following command to install an earlier version of Codex.
npm install -g @openai/codex@0.80.0
Verify installation:
codex --version

Set up Token Plan

  1. Modify the config file
Copy this into ~/.codex/config.toml (for model, choose a supported model):
Text models, such as qwen3.6-plus and glm-5, can be used directly. Image generation models use a separate API and must be integrated through extension mechanisms. See Integrate multimodal generation models.
model_provider = "Qwen_Cloud_Token_Plan"
model = "qwen3.6-plus"
[model_providers.Qwen_Cloud_Token_Plan]
name = "Qwen_Cloud_Token_Plan"
base_url = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
env_key = "OPENAI_API_KEY"
wire_api = "chat"
[sandbox_workspace_write]
network_access = true
  1. Set the environment variable Set OPENAI_API_KEY to your Token Plan API key. Replace YOUR_API_KEY with your actual key.
  • macOS/Linux
  • Windows
# Zsh (default on macOS)
echo 'export OPENAI_API_KEY="YOUR_API_KEY"' >> ~/.zshrc && source ~/.zshrc

# Bash
echo 'export OPENAI_API_KEY="YOUR_API_KEY"' >> ~/.bash_profile && source ~/.bash_profile

Use Codex

codex
Skip the update prompt if it appears.

FAQ

Error: 'wire_api = chat' is no longer supported

Cause: Newer versions of Codex use the Responses API and do not support the wire_api = "chat" configuration. Solution: Change the wire_api parameter to responses and ensure that the base_url is configured correctly:
Currently, only the qwen3.6-plus model in Token Plan supports the Responses API. To use other models, you must install an earlier version of Codex.
base_url = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
wire_api = "responses"

Error: unexpected status 401 Unauthorized

Causes:
  • This error can occur if the API Key is from a different plan, such as a Coding Plan or a pay-as-you-go plan.
  • Your Token Plan subscription has expired.
  • The API Key is incomplete, contains spaces, or has a typo.
Solutions:
  • Ensure you use the API Key for Token Plan. The API Keys for Token Plan, Coding Plan, and the pay-as-you-go plan are not interchangeable.
  • Go to the Token Plan page to check if your subscription has expired.
  • Copy the API Key again and make sure it is complete and contains no spaces.
  • If the issue persists, reset your API Key and configure Codex with the new key.

Error: unexpected status 404 Not Found

Cause: The base_url value in your configuration file is incorrect. Solution: Ensure that your base_url and wire_api are configured correctly:
base_url = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
wire_api = "responses"