Skip to content

Codex CLI Configuration Guide ​

Last updated: October 17, 2026 (Asia/Shanghai)

Related: Help Center · LLM API · VS Code

Applies to: using OpenAI Codex CLI with requests pointed at the TokenExplore gateway.

Key settings

ItemValue
Node.js≥ 18 (20/22 LTS recommended)
Base URLhttps://ai.afp.net/v1 (must include /v1, unlike Claude Code)
ProtocolUsually wire_api = "responses"; if incompatible, switch to the Chat Completions-related setting (depending on the Codex version)

INFO

Codex targets the OpenAI Responses / Chat Completions ecosystem. The TokenExplore model list is mainly Claude, Gemini, Kimi, DeepSeek, GLM, Qwen, Seedance, and so on — first use GET /v1/models to confirm which models your token can access, then set model in config.toml. If a model does not support Responses, run a minimal test before integrating, or switch to Claude Code / OpenCode.


1. Environment and token ​

bash
node --version

Create a dedicated token in the console (e.g. named codex) and copy the sk- key.


2. Install ​

bash
npm install -g @openai/codex
codex --version

3. Configuration files ​

~/.codex/config.toml ​

toml
model_provider = "ciyuan"
model = "claude-sonnet-4-6"
model_reasoning_effort = "high"
disable_response_storage = true

[model_providers.ciyuan]
name = "TokenExplore"
base_url = "https://ai.afp.net/v1"
wire_api = "responses"
requires_openai_auth = true

Replace model with a model ID that your token can actually use and that has been tested to support the current wire_api. If Responses returns an error, consult the current Codex documentation and try changing wire_api to the Chat Completions mode it supports (field names may differ slightly between versions).

~/.codex/auth.json ​

json
{
  "OPENAI_API_KEY": "sk-xxxxxxxx"
}

On Windows, the path is usually %USERPROFILE%\.codex\.


4. Verify ​

bash
codex "write a hello world"
# or specify a model (example)
codex --model claude-sonnet-4-6 "implement quicksort with tests"

5. Troubleshooting ​

SymptomFix
404 / can't connectMake sure base_url includes /v1; restart the terminal
Model not foundCheck against /v1/models; verify the token group and the available-model whitelist
Responses 4xxThe model may not support Responses → switch models, change wire_api, or use another CLI
Node too oldUpgrade to 18+ and reinstall
Insufficient quotaTop up in the console or raise the token quota

Back to: Help Center