OpenClaw + MegaBrain Gateway
OpenClaw is an open-source AI agent platform that brings conversational AI to messaging channels. Connect it to MegaBrain to access 500+ models across Telegram, Discord, Slack, WhatsApp, Signal, and iMessage — all with one API key.
Supported channels
Prerequisites
- Node.js 18 or later — nodejs.org
- A MegaBrain API key from your profile
- A bot token for the messaging channel you want to connect (Telegram, Discord, etc.)
Quick setup (one line)
Install OpenClaw, then run a single non-interactive onboard command:
Install OpenClaw
npm install -g openclawOnboard with MegaBrain
One command — no prompts:
openclaw onboard --non-interactive \
--auth-choice custom-api-key \
--custom-base-url "https://getmegabrain.com/api/gateway/v1" \
--custom-model-id "anthropic/claude-sonnet-4-6" \
--custom-api-key "$MEGABRAIN_API_KEY" \
--custom-compatibility openaiReplace $MEGABRAIN_API_KEY with your key from your profile.
Start the gateway
openclaw gateway runOpenClaw connects to your messaging channel and routes requests through MegaBrain.
Native MegaBrain provider
We've submitted a PR to OpenClaw to add MegaBrain as a first-class provider. Once merged, onboarding will be a single flag:
openclaw onboard --auth-choice megabrain-api-key --megabrain-api-key "$MEGABRAIN_API_KEY"Manual configuration
Prefer editing config directly? Use ~/.openclaw/openclaw.json:
{
"provider": "megabrain",
"apiKey": "mb-your-key-here",
"baseURL": "https://getmegabrain.com/api/gateway/v1",
"model": "anthropic/claude-sonnet-4-6",
"channels": {
"telegram": {
"botToken": "your-telegram-bot-token"
}
}
}Or set via environment variables:
export OPENCLAW_API_KEY="mb-your-key-here"
export OPENCLAW_BASE_URL="https://getmegabrain.com/api/gateway/v1"
export OPENCLAW_MODEL="anthropic/claude-sonnet-4-6"Recommended models
Pass any MegaBrain model ID as the model value:
# Fast and capable — best for most chats
anthropic/claude-sonnet-4-6
# Most capable — complex analysis and reasoning
anthropic/claude-opus-4-8
# Cost-effective — high volume, simple queries
google/gemini-2.5-flash
# Auto-select the best model per message
auto-balancedauto-balanced routes each message to the most cost-effective model that can handle it — recommended for bots with mixed query complexity. Browse all models on the models page.
Different models per channel
You can assign a different model to each messaging channel. Useful for running a cheaper model on a high-volume public bot and a flagship model on a private workspace:
{
"channels": {
"telegram": {
"botToken": "...",
"model": "google/gemini-2.5-flash"
},
"slack": {
"botToken": "...",
"model": "anthropic/claude-opus-4-8"
}
}
}Fallback model
Configure a fallback model to keep the bot running if the primary model is unavailable:
{
"model": "anthropic/claude-sonnet-4-6",
"fallbackModel": "google/gemini-2.5-flash"
}Troubleshooting
Authentication error / 401
Verify your API key starts with mb- and that baseURL is exactly https://getmegabrain.com/api/gateway/v1 — no trailing slash.
Model not found / 404
Model IDs are case-sensitive and follow the format provider/model-name. Check the models page for the exact ID.
Bot not responding on Telegram
Make sure the bot token is correct and the bot has been started via /start in the Telegram chat. Run openclaw gateway status to check the connection state.