All guides / Coding assistants

Use XHuoAPI in Claude Code

Claude Code sends requests in the Anthropic Messages format, which XHuoAPI accepts, so no proxy or converter is needed: two environment variables are enough. We ran real file-writing tasks with Claude Code 2.1.284, and the steps and notes below come from that test.

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 Claude Code (requires Node.js 18 or later).

npm install -g @anthropic-ai/claude-code
2

Set the environment variables. Leave /v1 off the base URL; Claude Code appends /v1/messages itself. Add these lines to ~/.zshrc or ~/.bashrc to keep them.

export ANTHROPIC_BASE_URL=https://api.xhuoapi.ai
export ANTHROPIC_AUTH_TOKEN=YOUR_XHUOAPI_KEY
export ANTHROPIC_MODEL=claude-sonnet-4-6
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-sonnet-4-6
3

Alternatively, leave your shell config alone and put the same values in the env block of ~/.claude/settings.json.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.xhuoapi.ai",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_XHUOAPI_KEY",
    "ANTHROPIC_MODEL": "claude-sonnet-4-6",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-sonnet-4-6"
  }
}
4

Run claude in your project directory for interactive mode, or use -p for a one-off task to confirm the connection first.

claude -p "Reply with the single word: ok"
5

To use a non-Claude model, change ANTHROPIC_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL to that model's ID, for example deepseek-v3.2.

export ANTHROPIC_MODEL=deepseek-v3.2
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v3.2

Notes

Test results (2026-10-06, asking Claude Code to create and write a file): claude-sonnet-4-6, deepseek-v3.2, glm-5.3 and qwen3.8-max all succeeded on the first try; kimi-k3 failed once and succeeded on retry. Speed varies a lot by model: the same task took about 9 s with DeepSeek and about 45 s with GLM.
Claude Code hands some background tasks to a Haiku-class model by default. Set ANTHROPIC_DEFAULT_HAIKU_MODEL to the model you are already using and know works, so background requests don't land on a model you haven't tested.
Claude Code sends a long system prompt with every request. In our test the first request wrote about 36K tokens to the prompt cache and later requests read about 64K tokens from it. Cache reads are billed at the cache price, which is lower than normal input; see the pricing page for each model.
ANTHROPIC_AUTH_TOKEN is sent as an Authorization: Bearer header and ANTHROPIC_API_KEY as x-api-key; XHuoAPI accepts both. With ANTHROPIC_API_KEY, interactive Claude Code asks for confirmation the first time it sees the key.
Qwen models and image/video models are only available in the Standard and Official tiers. A token created in the Saver or Spot tier will get a 'model not available' error for them.
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.