Connect OpenClaw to ModelGo: Setup & Troubleshooting

OpenClaw is an open-source, self-hosted personal AI assistant. A custom provider lets it call models through ModelGo's OpenAI-compatible API. You need an API key from the ModelGo Console and a logical model name from the Model Catalog.

1. Install

bash
curl -fsSL https://openclaw.ai/install.sh | bash
openclaw --version

In Windows PowerShell, run iwr -useb https://openclaw.ai/install.ps1 | iex.

2. Configure the ModelGo provider

OpenClaw reads the API key from an environment variable:

bash
echo 'export MODELGO_API_KEY="mgk_your_api_key"' >> ~/.zshrc
source ~/.zshrc

For Bash use ~/.bashrc; on Windows, [Environment]::SetEnvironmentVariable("MODELGO_API_KEY", "mgk_your_api_key", "User") stores it as a user variable.

Edit ~/.openclaw/openclaw.json (Windows: %USERPROFILE%\.openclaw\openclaw.json) and replace YOUR_MODELGO_MODEL with a logical model name from the Model Catalog:

json
{
  "models": {
    "mode": "merge",
    "providers": {
      "modelgo": {
        "baseUrl": "https://api.modelgo.ai/v1",
        "apiKey": "${MODELGO_API_KEY}",
        "api": "openai-completions",
        "models": [
          {
            "id": "YOUR_MODELGO_MODEL",
            "name": "YOUR_MODELGO_MODEL",
            "reasoning": false,
            "input": ["text"],
            "contextWindow": 128000,
            "maxTokens": 8192
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "modelgo/YOUR_MODELGO_MODEL"
      }
    }
  }
}
  • Use https://api.modelgo.ai/v1 as baseUrl; do not append /chat/completions.
  • contextWindow and maxTokens are generic examples; adjust them to the selected model's limits. Set reasoning to true when the model supports reasoning.

3. Start and verify

bash
openclaw onboard --install-daemon
openclaw models status
openclaw gateway start

Send a message in OpenClaw; a normal response confirms the connection. After editing the config, run openclaw gateway restart to reload it.

Troubleshooting

  • Model not found: make sure models[].id matches the model in agents.defaults.model.primary, which uses the modelgo/<model-name> format.
  • 401: check that MODELGO_API_KEY exists in the current terminal and apiKey is ${MODELGO_API_KEY}.
  • 403: confirm the model ID is a logical model allowed by the policy attached to the API key.
  • 404: set baseUrl to https://api.modelgo.ai/v1, not a full /chat/completions URL.

Related docs