Skip to content

OpenCode Setup Guide ​

Compatibility

Third-party clients may have protocol differences. This guide covers the basic OpenAI-compatible setup.

1. Open the configuration directory ​

The configuration file is ~/.config/opencode/opencode.json. On Windows, use %userprofile%\\.config\\opencode.

2. Edit opencode.json ​

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "yuan-api": {
      "npm": "@ai-sdk/openai",
      "options": {
        "apiKey": "your-api-key",
        "baseURL": "https://api.apixhm.com/v1"
      },
      "models": {
        "your-model-id": { "name": "your-model-id" }
      }
    }
  }
}

Use a current model ID from the Yuan API pricing page.