MegaBrain University · guide

OpenClaw Custom Provider Setup: Claude, GPT-6, Gemini and Kimi on One API Key

Updated · 15 min setup

Short answer

To use OpenClaw with MegaBrain, add a provider to ~/.openclaw/openclaw.json with baseUrl https://getmegabrain.com/api/gateway/v1, api: "openai-completions", your key and the models you want, then set the default model to megabrain/anthropic/claude-sonnet-5.5. OpenClaw then answers in WhatsApp, Telegram, Slack and its other channels with Claude, GPT-6, Gemini or Kimi on one key.

Connection settings
Base URL (OpenAI-compatible)https://getmegabrain.com/api/gateway/v1
Base URL for Claude Code and the Anthropic SDKhttps://getmegabrain.com/api/anthropic
KeyAuthorization: Bearer <key> — the API key page in your dashboard
Default modelanthropic/claude-sonnet-5.5
Free model for testingmb-auto/free

What is OpenClaw

OpenClaw (formerly Clawdbot and Moltbot) is an open-source personal AI assistant. A gateway process runs on your computer or a server, connects to the chat apps you already use — WhatsApp, Telegram, Slack, Discord, Microsoft Teams, iMessage, Google Chat, Signal and more — and acts with tools, skills from the ClawHub registry and scheduled jobs.

OpenClaw needs a model provider. Its config accepts any OpenAI-compatible endpoint as a custom provider, which is how you connect MegaBrain: one key and balance for Claude, GPT, Gemini, Grok and open models instead of a separate account per lab.

Setup, step by step

  1. Step 1. Get a MegaBrain API key

    Sign up with GitHub, Google or email, add funds on the Balance page and create a key on the API key page. The key works for every text, image and video model, and each request is paid from your balance — no subscription.

    Put the key in an environment variable so it never lands in a config file you share:

    # ~/.zshrc or ~/.bashrc
    export MEGABRAIN_API_KEY="your-megabrain-key"
    curl https://getmegabrain.com/api/gateway/v1/chat/completions \
      -H "Authorization: Bearer $MEGABRAIN_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"model": "anthropic/claude-sonnet-5.5", "messages": [{"role": "user", "content": "Say OK"}]}'

    Check the key before you touch the agent. A JSON reply with choices means the key, the balance and the model all work:

  2. Step 2. Install OpenClaw

    On macOS, Linux or WSL2 (the script starts onboarding when it finishes):

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

    With npm: npm install -g openclaw@latest --allow-scripts=openclaw, then openclaw onboard --install-daemon. On Windows: iwr -useb https://openclaw.ai/install.ps1 | iex.

  3. Step 3. Add MegaBrain as a custom provider

    The fastest way is onboarding with a custom API key. Non-interactive setup requires --accept-risk, your acknowledgement that the agent gets full access to the machine. Without --custom-model-id, OpenClaw reads /models and saves every model it finds:

    openclaw onboard --non-interactive --accept-risk \
      --auth-choice custom-api-key \
      --custom-base-url "https://getmegabrain.com/api/gateway/v1" \
      --custom-model-id "anthropic/claude-sonnet-5.5" \
      --custom-api-key "$MEGABRAIN_API_KEY" \
      --custom-compatibility openai

    Or write the provider into ~/.openclaw/openclaw.json yourself (OpenClaw reloads it on save):

    {
      agents: { defaults: { model: { primary: "megabrain/anthropic/claude-sonnet-5.5" } } },
      models: {
        mode: "merge",
        providers: {
          megabrain: {
            baseUrl: "https://getmegabrain.com/api/gateway/v1",
            apiKey: "${MEGABRAIN_API_KEY}",
            api: "openai-completions",
            models: [
              { id: "anthropic/claude-sonnet-5.5", name: "Claude Sonnet 5.5",
                input: ["text", "image"], contextWindow: 1000000, maxTokens: 32000 },
              { id: "openai/gpt-6.1-sol", name: "GPT-6.1 Sol",
                input: ["text", "image"], contextWindow: 1050000, maxTokens: 32000 },
              { id: "google/gemini-3.8-flash", name: "Gemini 3.8 Flash",
                input: ["text", "image"], contextWindow: 1048576, maxTokens: 32000 },
              { id: "mb-auto/free", name: "Auto Free",
                input: ["text"], contextWindow: 128000, maxTokens: 8000 }
            ]
          }
        }
      }
    }

    A model reference splits at the first slash: in megabrain/anthropic/claude-sonnet-5.5 the provider is megabrain and the model is anthropic/claude-sonnet-5.5. Each model you reference must be listed in models. The config is validated strictly, so a misspelled key stops the gateway — check the log.

  4. Step 4. Connect a channel and test

    Open the Control UI at http://127.0.0.1:18789 or run onboarding again to connect WhatsApp, Telegram or Slack. Send the assistant a message; the reply comes from the model in primary.

Which model to choose

OpenClaw uses tools on almost every turn, so pick a model with reliable tool calling. Claude Sonnet 5.5 is the default; put a cheaper model on high-volume channels. Set input: ["text", "image"] on models that see images so photos sent in chat reach them.

Model IDWhen to use it
anthropic/claude-sonnet-5.5The default for an agent: reliable tool calls, holds long tasks, 1M-token context.
anthropic/claude-opus-5.5Hard multi-step work, code review and analysis where a mistake costs more than tokens.
openai/gpt-6.1-solOpenAI's flagship: the alternative to Claude for code and reasoning.
google/gemini-3.8-flashFast and cheap: long documents, spreadsheets, inbox triage.
moonshotai/kimi-k3.1-proA strong open-weight model for agents and code.
z-ai/glm-5.3Open-weight model for code and tools with good price-to-quality.
deepseek/deepseek-v4.1-flashHigh-volume routine work: classification, drafts, summaries.
mb-auto/freeFree, for checking your setup. 128K context, weaker at tool calls; do not send confidential data.

Every model with its price and context window is in the catalog. They all work with the same key.

What you can do

20+ chat channels

WhatsApp, Telegram, Slack, Discord, Teams, iMessage, Google Chat, Signal and more, configured under channels in one gateway.

Cron jobs

Schedule recurring tasks with openclaw cron add --name "Morning brief" --cron "0 8 * * 1-5" --message "…" and have the answer posted to a channel.

Skills and plugins

Install skills from ClawHub or write your own to teach the assistant your processes.

Several models at once

List many models under one provider and switch per agent or per task, all billed to one MegaBrain balance.

Business use cases

WhatsApp front desk for a small business

Customers write to the business WhatsApp; OpenClaw answers questions about hours, prices and availability from your FAQ file, books requests into a sheet and hands complex cases to a person.

Task for the agent:

You answer customers of our studio in WhatsApp. Use only facts from ~/business/faq.md. If someone wants to book, collect name, date and service and append a row to ~/business/bookings.csv. If you are unsure, say a manager will reply within an hour and notify me in Telegram.

Sales assistant in Slack

Sales reps ask in Slack “prepare me for the call with Acme”; the assistant pulls the CRM notes (through a skill or MCP), recent news and drafts talking points.

Social media content from a chat

A marketer sends a product photo to Telegram; OpenClaw writes captions for three platforms and calls MegaBrain’s image and video API to make a 9:16 clip with the same key.

Daily operations digest

A cron job collects orders, refunds and support tickets every evening and posts a short digest to the team channel.

Troubleshooting

401 Unauthorized

The key is missing or mistyped, or the agent did not read the environment variable (restart the agent after export). Test the key with the curl command from step 1.

402 Payment Required

The balance is empty. Add funds on the Balance page, or switch to mb-auto/free to keep testing.

Model not found

The model ID must match the catalog exactly, including the lab prefix: anthropic/claude-sonnet-5.5, not claude-sonnet-5.5. The base URL must end in /v1.

The gateway does not start after editing openclaw.json

OpenClaw rejects unknown keys. Compare your file with the snippet in step 3, check the gateway log, or use openclaw config set and the Control UI instead of editing by hand.

“Unknown model” for a model the catalog has

Add it to the provider’s models array with the exact ID, and reference it as megabrain/<id>.

FAQ

Can OpenClaw use Claude without an Anthropic API key?

Yes. Through MegaBrain, OpenClaw reaches anthropic/claude-sonnet-5.5, anthropic/claude-opus-5.5 and anthropic/claude-fable-5.2 with your MegaBrain key; no Anthropic account is needed.

Which `api` value should I use?

openai-completions with the base URL https://getmegabrain.com/api/gateway/v1. MegaBrain also serves the OpenAI Responses API and the Anthropic Messages API, but Chat Completions is the most widely tested path.

How much does it cost?

You pay per token at each model’s price, from a prepaid balance in US dollars topped up by card. There is no subscription and no seat fee, so an agent that sits idle costs nothing. Prices per million tokens are in the model catalog; mb-auto/free costs nothing at all.

Do I need separate Anthropic, OpenAI or Google accounts?

No. One MegaBrain key reaches Claude, GPT, Gemini, Grok, Kimi, GLM, DeepSeek, Qwen and MiniMax. You switch models by changing the model ID, not the provider or the key.

Where does OpenClaw store its config?

In ~/.openclaw/openclaw.json (JSON5). Keep the key in the MEGABRAIN_API_KEY environment variable and reference it as ${MEGABRAIN_API_KEY} so the file is safe to back up.

MegaBrain · one API for every model

Claude, GPT, Gemini, Kimi, GLM and DeepSeek in any agent — one key, one balance.

Sign up, add funds by card and pay only for what your agents use. No subscription. Free models work without a key.

Sources

More MegaBrain University guides