Skip to main content

OpenCode

Prepare API Access​

Have the three items below ready before you configure anything:

API Key

The key string you generated when creating your API Key.

Base URL

https://api.watt-cloud.com/v1

The trailing /v1 is required — do not drop it.

Model Name

Take the complete model identifier from the Model Marketplace, for example DeepSeek-V4-Pro.

Installing OpenCode​

Install OpenCode through one of its official channels; the OpenCode documentation covers the details.

Linux / macOS / WSL2​

curl -fsSL https://opencode.ai/install | bash

Prefer npm? Install globally:

npm install -g opencode-ai

Windows​

WSL2 is OpenCode's own recommendation for the smoothest Windows experience; run the Linux install command above from inside your WSL2 environment.

On native Windows, use Chocolatey or Scoop instead:

choco install opencode
# or
scoop install opencode

npm works here as well:

npm install -g opencode-ai

Connect OpenCode to Watt Cloud​

A custom provider entry in ~/.config/opencode/opencode.json is what OpenCode uses to route its requests.

Edit the Configuration File​

Open ~/.config/opencode/opencode.json — create the file first if it doesn't exist — and add:

{
"$schema": "https://opencode.ai/config.json",
"model": "watt/GLM-5.1",
"provider": {
"watt": {
"npm": "@ai-sdk/openai-compatible",
"name": "Watt Cloud",
"options": {
"baseURL": "https://api.watt-cloud.com/v1",
"apiKey": "{env:WATT_API_KEY}"
},
"models": {
"GLM-5.1": {
"name": "GLM-5.1"
},
"DeepSeek-V4-Pro": {
"name": "DeepSeek-V4-Pro"
},
"MiniMax-M2.7": {
"name": "MiniMax-M2.7"
}
}
}
}
}

Field Reference​

FieldDescription
modelModel OpenCode uses by default, written as provider/model (e.g., watt/GLM-5.1)
npmThe AI SDK package to load; pick @ai-sdk/openai-compatible for /v1/chat/completions
nameHuman-readable label shown for this provider
options.baseURLEndpoint of the Watt Cloud API; the trailing /v1 is required
options.apiKeyYour key — pass {env:VAR_NAME} to pull it from the matching environment variable
modelsThe model IDs, exactly as the Model Marketplace lists them

Note: The top-level model entry is mandatory. Every ID you list under models must match a Model Marketplace name exactly.

Set the API Key​

Export the key before launching OpenCode:

export WATT_API_KEY="your-api-key"

To keep the variable across sessions, put that export line into a shell profile such as ~/.bashrc or ~/.zshrc.

Alternatively, opencode providers login handles this interactively: choose Other, type the provider ID watt, then paste in your key.

Change the Model​

Two ways to do it: edit the top-level model entry in the config, or supply -m as a CLI flag:

"model": "watt/DeepSeek-V4-Pro"

Verify the Connection​

Once WATT_API_KEY is exported, run:

opencode run -m watt/GLM-5.1 "Reply with exactly one word: hello"

If everything is wired up correctly, the response comes back as pong.

Launch the TUI​

Start OpenCode's interactive TUI from your project's directory:

opencode

Inside the TUI, /models lets you switch between models.