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-5.5"
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 (2026-10-06, asking Codex to create and write a file): gpt-5.5, gpt-5.4 and gpt-4.1 all completed the task. 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.
In the same test, gpt-5.3-codex replied that the file had been created but no file appeared, and Codex warned that it had no metadata for the model. Prefer gpt-5.5 or gpt-5.4.
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.

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