One-command setup

Claude Code and Codex at half price

The same Claude and GPT models, called through one MegaBrain key and paid per token from a prepaid balance: no subscription, and about half of what the official APIs charge, or less. If one provider fails, the request goes to the next one serving the same model. One command sets up your agent.

curl -fsSL https://getmegabrain.com/setup.mjs -o mb-setup.mjs && node mb-setup.mjs

On Windows, in PowerShell:

irm https://getmegabrain.com/setup.mjs -OutFile mb-setup.mjs; node mb-setup.mjs

It sets up Claude Code and Codex (Node 18 or newer, which both already need). Create a key on the API key page first (sign up and top up from $10). The script asks for it, checks it and changes only the agents’ own config files, after a backup. Read the script.

Price per 1M tokens vs the official API

ModelMegaBrain in / outOfficial in / outYou save
Claude Opus 5.5Claude Code$1.92 / $9.6$4 / $20−52%
Claude Sonnet 5.5Claude Code$0.96 / $4.8$2 / $10−52%
GPT-6.1 SolCodex$0.72 / $3.6$2 / $10−64%
GPT-6.2 AstraCodex$2.88 / $14$8 / $40−64%

Pick your agent

Claude Code

The script asks for your key, checks it and puts the MegaBrain address, the key and Claude Opus, Sonnet and Haiku 5.5 into the env block of ~/.claude/settings.json, after a backup.

curl -fsSL https://getmegabrain.com/setup.mjs -o mb-setup.mjs && node mb-setup.mjs --claude

Step-by-step guide

Codex CLI

The script adds a megabrain model provider to ~/.codex/config.toml and makes it the default with GPT-6.1 Sol, keeping the rest of the file and a backup.

curl -fsSL https://getmegabrain.com/setup.mjs -o mb-setup.mjs && node mb-setup.mjs --codex

Step-by-step guide

Kilo Code

In the extension: Settings → Providers → Custom provider → OpenAI Compatible, with the base URL below and your key, then Fetch models. For the Kilo CLI, add this to ~/.config/kilo/kilo.jsonc:

{
  "$schema": "https://app.kilo.ai/config.json",
  "model": "megabrain/anthropic/claude-sonnet-5.5",
  "provider": {
    "megabrain": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "MegaBrain",
      "options": {
        "baseURL": "https://getmegabrain.com/api/gateway/v1",
        "apiKey": "{env:MEGABRAIN_API_KEY}"
      },
      "models": {
        "anthropic/claude-sonnet-5.5": {
          "name": "Claude Sonnet 5.5",
          "tool_call": true,
          "limit": { "context": 1000000, "output": 32000 }
        }
      }
    }
  }
}

Step-by-step guide

OpenCode

Add the same provider to ~/.config/opencode/opencode.json (with "$schema": "https://opencode.ai/config.json"), keep the key in MEGABRAIN_API_KEY, then pick the model with /models.

{
  "$schema": "https://opencode.ai/config.json",
  "model": "megabrain/anthropic/claude-sonnet-5.5",
  "provider": {
    "megabrain": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "MegaBrain",
      "options": {
        "baseURL": "https://getmegabrain.com/api/gateway/v1",
        "apiKey": "{env:MEGABRAIN_API_KEY}"
      },
      "models": {
        "anthropic/claude-sonnet-5.5": {
          "name": "Claude Sonnet 5.5",
          "tool_call": true,
          "limit": { "context": 1000000, "output": 32000 }
        }
      }
    }
  }
}

Step-by-step guide

Cline

Open Cline’s settings and choose the OpenAI Compatible provider:

Base URL:  https://getmegabrain.com/api/gateway/v1
API Key:   your MegaBrain key
Model ID:  anthropic/claude-sonnet-5.5   (or openai/gpt-6.1-sol, anthropic/claude-opus-5.5)

OmniRoute

OmniRoute 3.8.54 and later has MegaBrain built in: Dashboard → Providers → MegaBrain → add a connection and sign in with your MegaBrain account or paste your key, then use its models in your combos. On an older version, add an OpenAI-compatible provider:

Base URL:  https://getmegabrain.com/api/gateway/v1
API key:   your MegaBrain key

Key already in your environment?

The script reads MEGABRAIN_API_KEY when it is set, so it runs without a prompt on a new machine or in CI.

Prices for every model are in the catalogue, and step-by-step guides for each agent in MegaBrain University.