All guides / Coding assistants

Use XHuoAPI in Codex CLI

Codex CLI lets you add a custom model provider in its config file. It only talks to OpenAI's Responses endpoint (/v1/responses), so through XHuoAPI the models that work are GPT models. We ran real file-writing tasks with codex-cli 0.156.1, and the config below is the one we tested.

Before you start

Verify first

Before touching the tool, confirm the key and model work with curl. This rules out half of the 'I configured it and nothing happens' cases.

curl https://api.xhuoapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v3.2","messages":[{"role":"user","content":"ping"}]}'

Steps

1

Install Codex CLI.

npm install -g @openai/codex
2

Edit ~/.codex/config.toml (create it if it doesn't exist) and add the following. wire_api must be responses.

model = "gpt-6-sol"
model_provider = "xhuoapi"

[model_providers.xhuoapi]
name = "XHuoAPI"
base_url = "https://api.xhuoapi.ai/v1"
env_key = "XHUO_API_KEY"
wire_api = "responses"
3

Put your API key in the environment variable named by env_key.

export XHUO_API_KEY=YOUR_XHUOAPI_KEY
4

Run codex in your project directory for interactive mode, or codex exec for a one-off task. Use -m to switch models for a single run.

codex exec -m gpt-5.4 "Explain what this repository does"

Notes

Setting wire_api to chat fails immediately with: wire_api = "chat" is no longer supported. Current Codex versions only support responses.
Test results (asking Codex to create and write a file): on 2026-11-16 with codex-cli 0.169.0, gpt-6-sol and gpt-6.1-sol each completed all 3 runs; gpt-5.5 and gpt-5.4 have been unreliable recently (sometimes skipping the task or hitting rate limits), so we don't recommend them for now. deepseek-v3.2 and claude-sonnet-4-6 kept showing Reconnecting in Codex and then failed; for those models use Claude Code, Cline or a similar tool.
The model ID must match the pricing page exactly (deepseek-v4-pro, not DeepSeek V4 Pro). Case and hyphens matter.

Commonly used models

These are common choices for this kind of tool; click a model to see its price in each tier. The full list is on the pricing page.

Which Chinese models work in Claude Code, Codex CLI, fx and OpenCode (tested) →

Steps follow the tool's current official documentation; the UI may change after updates. Tell us if something no longer matches.