OpenAI-compatibleAI Code Editor

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

Setup

1

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).

2

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.

3

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.

4

Set the custom base URL

Enable the Override OpenAI Base URL toggle, then enter:

https://getmegabrain.com/api/gateway/v1

All model requests will now route through MegaBrain Gateway instead of OpenAI.

5

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-6

You can add as many models as you like. Each will appear in Cursor's model picker.

6

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

FieldValueNotes
Base URLhttps://getmegabrain.com/api/gateway/v1Requires the override toggle enabled
API Keymb-…Your MegaBrain key from /profile
Model formatprovider/model-ide.g. anthropic/claude-sonnet-4-6

How Cursor uses the model

Tab

Tab completion

Ghost-text inline suggestions as you type. The model predicts your next edit based on surrounding code.

Cmd + L

Chat

Conversational AI panel. Ask questions, get explanations, request code — with full codebase context.

Cmd + I

Composer

Multi-file agentic editing. Describe a feature and Cursor plans and applies changes across files.

Cmd + K

Inline 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-flash

Troubleshooting

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.