How to Integrate OpenCode Zen Models in Openclaw
Quick Start
OpenCode Zen provides powerful AI models through the OpenCode platform. Integrating these models into Openclaw gives you access to advanced reasoning capabilities. This guide shows you how to set it up in under 5 minutes.
Get an API Key
Sign in to the OpenCode platform at opencode.ai/auth, add your billing details, and copy your API key. Openclaw bills per request using this key.
Openclaw recognizes the key through either the OPENCODE_API_KEY or OPENCODE_ZEN_API_KEY environment variables.
Interactive Setup
The easiest way to configure OpenCode Zen is using the CLI wizard:
Openclaw onboard --auth-choice opencode-zen
Follow the prompts to enter your API key and complete the setup.
Non-Interactive Setup
For scripting or automated deployments, use the non-interactive mode:
Openclaw onboard --non-interactive \
--mode local \
--auth-choice opencode-zen \
--opencode-zen-api-key "$OPENCODE_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
Set Your Default Model
After authentication, set OpenCode Zen as your primary model:
Openclaw models set opencode/claude-opus-4-6
Manual Configuration
Alternatively, you can manually edit your ~/.Openclaw/Openclaw.json file to include your key and set your primary model:
{
"env": { "OPENCODE_API_KEY": "sk-..." },
"agents": {
"defaults": {
"model": { "primary": "opencode/claude-opus-4-6" }
}
}
}
If you are exploring other AI providers, check out our guides on GLM Models Openclaw and LiteLLM Models Openclaw integration.
Troubleshooting
- Authentication failed: Verify your API key is valid and has billing enabled on the OpenCode platform.
- Model not found: Ensure you are using the correct model ID format: opencode/model-name.
- Gateway not starting: Check that the port specified is not already in use by another service.