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
| Item | Value |
|---|---|
| Node.js | ≥ 18 (20/22 LTS recommended) |
| Base URL | https://ai.afp.net/v1 (must include /v1, unlike Claude Code) |
| Protocol | Usually 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
node --versionCreate a dedicated token in the console (e.g. named codex) and copy the sk- key.
2. Install
npm install -g @openai/codex
codex --version3. Configuration files
~/.codex/config.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 = trueReplace 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
{
"OPENAI_API_KEY": "sk-xxxxxxxx"
}On Windows, the path is usually %USERPROFILE%\.codex\.
4. Verify
codex "write a hello world"
# or specify a model (example)
codex --model claude-sonnet-4-6 "implement quicksort with tests"5. Troubleshooting
| Symptom | Fix |
|---|---|
| 404 / can't connect | Make sure base_url includes /v1; restart the terminal |
| Model not found | Check against /v1/models; verify the token group and the available-model whitelist |
| Responses 4xx | The model may not support Responses → switch models, change wire_api, or use another CLI |
| Node too old | Upgrade to 18+ and reinstall |
| Insufficient quota | Top up in the console or raise the token quota |
Back to: Help Center