Cursor + MegaBrain Gateway
Cursor is an AI-first code editor built on VS Code — with tab completion, chat, Composer, and inline edits baked in. By default it only exposes a handful of built-in models. MegaBrain Gateway unlocks all 500+ models by acting as an OpenAI-compatible proxy, so Cursor thinks it's talking to OpenAI while actually routing to whichever model you choose.
Why use MegaBrain?
Any model
Claude, GPT-4o, Gemini, Mistral, Llama — every major model in one place. Switch with a single model ID.
Exact provider pricing
Pay the provider's list price per token, not a bundled Cursor subscription. No seat fees for heavy users.
One key for everything
One MegaBrain API key replaces a dozen provider accounts. Rotate once, rotate everywhere.
Prerequisites
- Cursor installed — download at cursor.com
- A MegaBrain API key — get one from your profile
Setup
Open Cursor Settings
Press Cmd + Shift + J on Mac or Ctrl + Shift + J on Windows, or go to File → Preferences → Cursor Settings. This opens the dedicated Cursor Settings panel (separate from the VS Code settings).
Go to the Models section
In the left sidebar of the Cursor Settings panel, click Models. This is where all model configuration lives — both built-in models and custom OpenAI-compatible providers.
Add your MegaBrain API key
Scroll down to the OpenAI API Key section and paste your MegaBrain key into the field. Cursor uses this key for all requests to OpenAI-compatible endpoints, including custom base URLs.
Set the custom base URL
Enable the Override OpenAI Base URL toggle, then enter:
https://getmegabrain.com/api/gateway/v1All model requests will now route through MegaBrain Gateway instead of OpenAI.
Add a model
In the Models list, click + Add model. Type the model ID exactly as shown and press Enter to confirm:
anthropic/claude-sonnet-4-6You can add as many models as you like. Each will appear in Cursor's model picker.
Select the model in Cursor
Open the chat panel (Cmd + L) and click the model picker at the top of the panel. Your newly added model will appear in the list. Select it — all chat, Composer, and inline edit requests will now use MegaBrain.
Settings reference
| Field | Value | Notes |
|---|---|---|
| Base URL | https://getmegabrain.com/api/gateway/v1 | Requires the override toggle enabled |
| API Key | mb-… | Your MegaBrain key from /profile |
| Model format | provider/model-id | e.g. anthropic/claude-sonnet-4-6 |
How Cursor uses the model
TabTab completion
Ghost-text inline suggestions as you type. The model predicts your next edit based on surrounding code.
Cmd + LChat
Conversational AI panel. Ask questions, get explanations, request code — with full codebase context.
Cmd + IComposer
Multi-file agentic editing. Describe a feature and Cursor plans and applies changes across files.
Cmd + KInline edit
Select code and describe the change. The model rewrites only the selected block, in-place.
Recommended models for Cursor
# Complex reasoning & multi-file Composer tasks
anthropic/claude-opus-4-8
# Daily driver — fast, smart, great tab completion
anthropic/claude-sonnet-4-6
# Speed-optimised chat and inline edits
openai/gpt-4o
# Cheap high-volume tab completion
google/gemini-2.5-flashTroubleshooting
Model not responding in chat
Confirm the base URL toggle is enabled and the URL has no trailing slash. Open the Cursor Settings panel again and check both the API Key and Override OpenAI Base URL fields are saved correctly.
Base URL is not saving
Make sure you hit Enter or click outside the field after typing the URL — Cursor requires an explicit confirm before persisting custom values.
"Invalid API key" error
Double-check your key in your MegaBrain profile. Keys start with mb-. Make sure you have not accidentally copied whitespace around the key.
Tab completion not working with my custom model
Tab completion (ghost text) in Cursor uses a separate model slot from chat. Open Settings → Models and look for the Autocomplete model section — add your model there as well, or select it from the autocomplete model picker.