Home Tutorials Categories Skills About
ZH EN JA KO
Model Integration

OpenCode Integration Guide

· 4 min read

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

  1. Visit the OpenCode platform and register
  2. Create an API key in the console
  3. 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.

OpenClaw is a free, open-source personal AI assistant that supports WhatsApp, Telegram, Discord, and many more platforms