页面简介
Connect Cursor to AI Gateway with its OpenAI base URL override. Configure the Cursor compatibility endpoint, API key, and model IDs.
正文摘录
Copy pageCopy pageCursor with AI GatewayCopy pageCopy pageCursor 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. Set up with the Vercel CLI Run the Vercel CLI setup command for Cursor: terminalnpx vercel@latest 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. Configuring 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. Get your API keyIf 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:terminalprintf %s "$AI_GATEWAY_API_KEY" | pbcopyIf 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.Open the model settingsIn Cursor, open Settings with Cmd+Shift+J, then go to Models.Add your key and base URLUnder 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/v1Cursor'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.Add the models you wantUse 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. Limitations Cursor's bring-your-own-key support has constraints that come from Cursor itself, not from AI Gateway: LimitationWhat it meansBuilt-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 backTab completions are excludedTab never uses a custom key, so those requests don't reach the gatewayAgent and Auto may bypass the overrideSome agent modes route to Cursor's own models regardless of the overrideRequests pass through CursorBring-your-own-key traffic still goes through Cursor's backend on the way to the gatewayNo local sessionsCursor stores chats in its backend, so there are no local sessions to migrate when you switch providers Next steps Browse the models catalog for available models Configure spend limits on your API key Connect your terminal agents with the Vercel CLI Last updated October 16, 2026PreviousCrushNextDeep Agents CLIWas this helpful?