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
- Sign up in the console and create an API token. Registration needs an email address only, no phone number.
- You pick a tier when creating the token; new accounts default to Standard. The tier sets price and stability and also which models are available — see the pricing page.
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
Install Claude Code (requires Node.js 18 or later).
npm install -g @anthropic-ai/claude-code
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
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"
}
}
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"
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
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.