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
curl -fsSL https://openclaw.ai/install.sh | bash
openclaw --versionIn 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:
echo 'export MODELGO_API_KEY="mgk_your_api_key"' >> ~/.zshrc
source ~/.zshrcFor 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:
{
"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/v1asbaseUrl; do not append/chat/completions. contextWindowandmaxTokensare generic examples; adjust them to the selected model's limits. Setreasoningtotruewhen the model supports reasoning.
3. Start and verify
openclaw onboard --install-daemon
openclaw models status
openclaw gateway startSend 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[].idmatches the model inagents.defaults.model.primary, which uses themodelgo/<model-name>format. - 401: check that
MODELGO_API_KEYexists in the current terminal andapiKeyis${MODELGO_API_KEY}. - 403: confirm the model ID is a logical model allowed by the policy attached to the API key.
- 404: set
baseUrltohttps://api.modelgo.ai/v1, not a full/chat/completionsURL.