OpenCode Introduction
OpenCode is an open AI model access platform providing unified API interfaces for multiple models. It supports the OpenAI-compatible protocol and can be used directly as a model provider in OpenClaw.
Get Credentials
- Visit the OpenCode platform and register
- Create an API key in the console
- Review available models and pricing
Basic Configuration
{
"providers": {
"opencode": {
"type": "openai",
"baseUrl": "https://api.opencode.ai/v1",
"apiKey": "{{OPENCODE_API_KEY}}",
"models": ["opencode-gpt4", "opencode-claude", "opencode-llama"]
}
}
}
openclaw secrets set OPENCODE_API_KEY "oc-your-api-key"
Proxy and Retry Configuration
{
"providers": {
"opencode": {
"type": "openai",
"baseUrl": "https://api.opencode.ai/v1",
"apiKey": "{{OPENCODE_API_KEY}}",
"proxy": "http://your-proxy:8080",
"timeout": 30000,
"retries": 3
}
}
}
Using as a Fallback Provider
{
"models": {
"primary-model": {
"provider": "openai",
"model": "gpt-4o",
"fallback": "oc-smart"
},
"oc-smart": {
"provider": "opencode",
"model": "opencode-gpt4"
}
}
}
Summary
OpenCode provides a flexible model access solution for OpenClaw. With OpenAI protocol compatibility and simple configuration, it works well as either a primary or backup provider.