Skip to content

🛠️ Opencode & OpenClaw Integration Guide

For power users who want maximum customization, Opencode and OpenClaw provide strong routing and gateway capabilities. This guide walks you through configuring both tools to access top models via Old Dog AI.


🟢 Part 1: Opencode configuration

Opencode is an efficient CLI tool based on AI SDK. It does not read environment variables directly; instead, it relies on a dedicated JSON config file.

1. Create the config file

Create a file named opencode.json in your home directory:

  • Windows: C:\Users\<YourUsername>\opencode.json
  • macOS / Linux: ~/.opencode.json

2. Fill in the config

Open the file and paste the following (replace sk-xxxx with your Old Dog AI key):

json
{
  "models": {
    "claude-sonnet-4-6": {
      "name": "Sonnet 4.6"
    },
    "claude-opus-4-6": {
      "name": "Opus 4.6"
    },
    "gpt-5.2": {
      "name": "GPT-5.2"
    }
  },
  "npm": "@ai-sdk/anthropic",
  "options": {
    "apiKey": "sk-您的专属API_KEY",
    "baseURL": "[https://api.olddog.shop/v1](https://api.olddog.shop/v1)"
  }
}

3. Set a system environment variable (key step)

OpenCode must know where the config file is, otherwise it cannot load it:

  1. Variable name: OPENCODE_CONFIG
  2. Variable value: the full path to the file you created (for example C:\Users\Administrator\opencode.json)
  3. Apply: after setting it, restart your terminal (PowerShell or CMD).

4. Auth & verification

Run the following commands in order:

  1. Login: opencode auth login
  2. Provider ID: enter olddog (or any custom name)
  3. Type: choose Other
  4. Verify models: in the opencode UI, run /models. If you can see Sonnet 4.6 etc., the setup is successful.

🔵 Part 2: OpenClaw configuration

OpenClaw lets you customize routing via Web UI or CLI. Update its config to point your local gateway to Old Dog AI.

1. Open the configuration

Use either method:

  • Option A (recommended Web UI): run openclaw dashboard, then in the left menu go to Config > Raw.
  • Option B (edit in terminal): run nano ~/.openclaw/openclaw.json.

2. Update the JSON config

Paste the following JSON (replace sk-xxxx with your own key):

JSON
{
    "gateway": {
        "mode": "local"
    },
    "agents": {
        "defaults": {
            "model": {
                "primary": "olddog/claude-sonnet-4-6"
            },
            "models": {
                "olddog/claude-sonnet-4-6": {},
                "olddog/claude-opus-4-6": {},
                "olddog/gpt-5.2": {}
            }
        }
    },
    "models": {
        "mode": "merge",
        "providers": {
            "olddog": {
                "baseUrl": "https://api.olddog.shop",
                "apiKey": "sk-您的专属API_KEY",
                "api": "anthropic-messages",
                "models": [
                    {
                        "id": "claude-sonnet-4-6",
                        "name": "claude-sonnet-4-6",
                        "reasoning": false,
                        "contextWindow": 200000,
                        "maxTokens": 64000
                    },
                    {
                        "id": "claude-opus-4-6",
                        "name": "claude-opus-4-6",
                        "reasoning": true,
                        "contextWindow": 200000,
                        "maxTokens": 128000
                    }
                ]
            }
        }
    }
}

3. Save and apply

  • Web UI: click Save, then Update to apply immediately.

  • Terminal: save and exit, then restart the gateway:

    Bash
    openclaw gateway restart

📚 Further references