Skip to content
Docs

Cursor with AI Gateway

Cursor is an AI-first code editor. Point its OpenAI API key settings at AI Gateway to reach every model in the gateway catalog and track spend in one place.

Run the Vercel CLI setup command for Cursor:

terminal
npx vercel ai-gateway setup --agent cursor

The command provisions a key, exports it as AI_GATEWAY_API_KEY from your shell startup file, and prints the remaining setup steps with your values filled in. Cursor keeps API-key settings in its account-synced store instead of a file on disk, so you must finish the setup in Cursor.

Complete these steps in Cursor after running the Vercel CLI. If you don't use the CLI, create an API key in the first step.

  1. If you ran the Vercel CLI setup command on macOS, open a new terminal so your shell loads the AI_GATEWAY_API_KEY export, then copy the key without displaying it in the terminal:

    terminal
    printf %s "$AI_GATEWAY_API_KEY" | pbcopy

    If you didn't use the Vercel CLI, go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a key.

  2. In Cursor, open Settings with Cmd+Shift+J, then go to Models.

  3. Under OpenAI API Key, paste your AI Gateway key. Then enable Override OpenAI Base URL and set it to Cursor's dedicated compatibility endpoint:

    https://ai-gateway.vercel.sh/cursor/v1

    Cursor's base URL override sends /chat/completions bodies that the standard OpenAI schema rejects. Version 3.14.x sends flat tool definitions whose type isn't function, and newer builds send Responses-shaped bodies with input instead of messages. The /cursor/v1 endpoint normalizes both into standard Chat Completions. Every other path falls through to the standard /v1 handlers, so routing, billing, and errors are unchanged. Pointing Cursor at the bare /v1 or coding agent surface returns a 400 on tools.0.type instead.

  4. Use Add model to add gateway model IDs to the picker, for example anthropic/claude-opus-5 or openai/gpt-6-astra. Model IDs use the gateway's creator/model-name format, and the models catalog lists what's available.

Cursor's bring-your-own-key support has constraints that come from Cursor itself, not from AI Gateway:

LimitationWhat it means
Built-in models stop workingWhile the base URL override is on, Cursor's own non-OpenAI models are unavailable. Use gateway model IDs for everything, or turn the override off to go back
Tab completions are excludedTab never uses a custom key, so those requests don't reach the gateway
Agent and Auto may bypass the overrideSome agent modes route to Cursor's own models regardless of the override
Requests pass through CursorBring-your-own-key traffic still goes through Cursor's backend on the way to the gateway
No local sessionsCursor stores chats in its backend, so there are no local sessions to migrate when you switch providers
Last updated September 13, 2026

Was this helpful?

supported.