All guides / Coding assistants
Use XHuoAPI in OpenCode
OpenCode is an open-source coding agent with a terminal UI, a desktop app and IDE extensions, and it can connect to any OpenAI Chat Completions–compatible endpoint. XHuoAPI provides that endpoint, so one provider in the config file is enough. We had OpenCode 2.1.2 create a file for real, and the config below is the one we tested.
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 OpenCode 2. OpenCode 1 and 2 both use the opencode command and can't be installed side by side; version 1 uses a different config format, see the tips below.
npm install -g @opencode/cli opencode --version
Put your API key in an environment variable. Pick any name; use the same name in env in the next step.
export XHUOAPI_API_KEY=YOUR_XHUOAPI_KEY
Create opencode.jsonc in your project directory with the provider below. Use the OpenAI-compatible package, end baseURL at /v1, and use model IDs as keys under models, exactly as written on the pricing page.
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"xhuoapi": {
"name": "XHuoAPI",
"env": ["XHUOAPI_API_KEY"],
"package": "@opencode/ai/providers/openai-compatible",
"settings": { "baseURL": "https://api.xhuoapi.ai/v1" },
"models": {
"glm-5.3": { "name": "GLM-5.3" },
"deepseek-v4.1-flash-none": { "name": "DeepSeek V4.1 Flash" },
"qwen3.8-max": { "name": "Qwen3.8-Max" }
}
}
}
}
Refer to models as provider/model-ID. Run opencode in the project directory for the interactive UI, or opencode run for a one-off task.
opencode run -m xhuoapi/glm-5.3 "Create hello.py that prints hello" opencode
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.