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

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 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
2

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
3

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" }
      }
    }
  }
}
4

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

Test results (2026-10-22, OpenCode 2.1.2, asking it to create hello.py): glm-5.3 (20 s), deepseek-v4.1-flash-none (8 s), qwen3.8-max (8 s), deepseek-v4-flash (18 s) and deepseek-v3.2 (22 s) all passed on the first run; kimi-k3 passed 2 out of 3, and in the failed run it said the file was created without actually calling the write tool.
OpenCode 1 format: the top-level key is provider (singular), with "npm": "@ai-sdk/openai-compatible" and the address in options.baseURL; save the key with /connect → Other, or set "apiKey": "{env:XHUOAPI_API_KEY}" in options. We only tested OpenCode 2.
When scripting with opencode run, --auto approves permission requests that aren't explicitly denied; without it, file writes and commands stop and wait for confirmation. --auto is not a sandbox, so only use it in directories you trust.
OpenCode 2 connects to a shared background service by default. If a config change doesn't take effect or the service misbehaves, add --standalone to run with a private server (that's how we ran our tests).
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.