Cursor API Key Setup (2026): Use Your Own OpenAI, Anthropic, Google Key or a Custom Base URL
On this page
Short answer: open Cursor Settings → Models, scroll to API Keys, paste your OpenAI, Anthropic or Google key and save. For any OpenAI-compatible provider, also fill in Override OpenAI Base URL, then use Add Custom Model for the provider's model names. Own keys need a Premium plan or higher, they work for chat and Agent models but not for Tab, and requests still pass through Cursor's servers.
The setting names here come from the Cursor 3.9.16 app itself and from Cursor's documentation as of October 15, 2026; both were rechecked on November 1, 2026 and nothing had changed.
Cursor vs Codex vs Claude Code: custom API setup at a glance
All three can use a third-party API, but each expects a different API format and base URL. Copying settings from one tool's guide into another is the most common mistake:
| Cursor | Codex | Claude Code | |
|---|---|---|---|
| Where to set it | Cursor Settings → Models: OpenAI API Key + Override OpenAI Base URL | ~/.codex/config.toml |
env in ~/.claude/settings.json |
| Base URL (api.foo example) | With /v1: https://api.foo/v1 |
With /v1: https://api.foo/v1 |
Without /v1: https://api.foo |
| API the provider must support | Chat Completions (/v1/chat/completions) |
Responses (/v1/responses) |
Anthropic Messages (/v1/messages) |
| Where requests come from | Cursor's servers — the URL must be public | Your computer | Your computer |
| Subscription needed | Cursor Premium or higher | No ChatGPT plan needed | No Claude plan needed |
Setup guides for the other two: Codex config.toml and custom providers, Claude Code with a custom API.
Which plans allow your own key
Cursor is now sold as part of a combined subscription with Grok and X, and plan names changed in 2026:
| Plan | Price | Own API keys / third-party models |
|---|---|---|
| Free | $0 | No third-party models |
| Plus | $8/mo | No: Cursor's own models only |
| Premium | $30/mo | Yes |
| Super | $100/mo | Yes |
| Ultra | $200/mo | Yes |
| Teams / Enterprise | per seat / custom | Yes, plus a $0.25 per million token Cursor Token Rate |
| Legacy Pro, Pro+, Ultra | — | Yes |
On individual plans, requests made with your own key are billed by your provider and don't use your included Cursor usage, so you can make as many as your provider allows. On Teams and Enterprise plans, Cursor still charges its Token Rate on those tokens.
What your own key covers, and what it doesn't
| With your own key | |
|---|---|
| Chat and Agent with that provider's models | Billed to your key |
| Tab completion | Always Cursor's built-in models |
| OpenAI models | Cursor's docs say standard, non-reasoning chat models. The model picker shows which |
| Cursor's Zero Data Retention | Does not apply. Your provider's privacy policy does |
| Where requests go | Through Cursor's servers, which build the final prompt, then on to your provider |
The last row has practical consequences. Your key travels with each request (Cursor says it isn't stored), and a custom base URL must be reachable from the internet. localhost or a private network address won't work.
Add a key from OpenAI, Anthropic or Google
- Open Cursor Settings: the gear icon at the top right, or Cursor Settings in the Command Palette.
- Go to Models and scroll to API Keys.
- Paste your key into OpenAI API Key, Anthropic API Key or Google API Key. Azure OpenAI and AWS Bedrock have their own sections.
- Save. That provider's models now use your key and appear in the model picker.
If a key is invalid or the provider rejects it, requests to that provider fail until you fix or remove the key. Need a key? See How to get an OpenAI API key or How to get a Claude API key.
Use an OpenAI-compatible provider (custom base URL)
Under the OpenAI key field, Override OpenAI Base URL ("Change the base URL for OpenAI API requests") lets Cursor send OpenAI-format requests to another service, such as a self-hosted model server or an API gateway. The field's default is https://api.openai.com/v1.
- OpenAI API Key: paste the key from that provider, not your OpenAI key.
- Override OpenAI Base URL: the provider's OpenAI-compatible base URL, including
/v1, for examplehttps://api.foo/v1for api.foo, the gateway that publishes these docs. - Add Custom Model (in the same Models settings): enter each model name exactly as the provider spells it, and enable it.
- Pick the model in the chat or Agent model picker and send a test message.
Keep in mind:
- It's OpenAI format only. The override changes where Cursor's OpenAI requests go. Your provider must implement the OpenAI Chat Completions API. See OpenAI-compatible APIs explained.
- Use the provider's exact model IDs. A mistyped name returns a "model not found" error from the provider.
- Public HTTPS only, because requests come from Cursor's servers, not your machine.
- To go back to Cursor's own OpenAI models, clear the base URL override and the key.
Test the endpoint before you paste it into Cursor
Cursor shows a one-line error, which rarely says whether the URL, key or model name is wrong. Send the same kind of request from a terminal first (on Windows, use Git Bash or WSL; this line-wrapping and quoting breaks in PowerShell):
curl https://api.foo/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "hi"}]}'
- JSON with
choices: URL, key and model name are all right. Use the same values in Cursor. 无效的令牌("invalid token"): the URL is right but the key isn't. That's exactly what we got on November 1, 2026 with a deliberately wrong key:{"error":{"code":"","message":"无效的令牌 (request id: …)","type":"new_api_error"}}.- 404 or an HTML page: the URL or path is wrong — often
/chat/completionspasted into the base URL. With most providers a missing/v1does this too; api.foo adds it for you.
To see which model names your key can use, run curl https://api.foo/v1/models -H "Authorization: Bearer sk-your-key" or check the Models page.
Troubleshooting
My own key doesn't seem to be used
Check your plan first. Plus and Free plans don't support your own keys. Then make sure you selected one of that provider's models in the picker. Tab always uses Cursor's models, whatever keys you've added.
"Model not available"
Cursor's docs say some models are unavailable in certain regions because of restrictions set by the model providers, and those models don't appear in Cursor at all.
Custom base URL errors
| Symptom | Likely cause |
|---|---|
| 401 / invalid key | The key in the OpenAI field belongs to a different service than the base URL |
| 404 | The base URL is missing /v1, or you included a full path such as /chat/completions |
| Model not found | The custom model name doesn't match the provider's ID exactly |
| Timeouts or connection errors | The URL isn't publicly reachable, or the provider is down |
For the meaning of each status code, see LLM API errors and rate limits.
Related
FAQ
Can I use my own API key in Cursor?
Yes, on Premium, Super and Ultra plans (and legacy Pro, Pro+ and Ultra plans). Open Cursor Settings → Models, find the API Keys section, paste a key for OpenAI, Anthropic, Google, Azure OpenAI or AWS Bedrock, and save. The Plus plan doesn't allow your own keys.
Does my own API key work for Cursor Tab?
No. Custom API keys only apply to chat models. Tab completion always uses Cursor's built-in models.
Do I pay Cursor when I use my own API key?
On individual plans, no. Your provider bills you directly and the requests don't use your included usage. On Teams and Enterprise plans, Cursor adds a Cursor Token Rate of $0.25 per million tokens, even with your own key.
Can I use a custom OpenAI base URL in Cursor?
Yes. Under the OpenAI API key there's an Override OpenAI Base URL setting (default https://api.openai.com/v1). Enter an OpenAI-compatible provider's URL, add its model names with Add Custom Model, and select them in the model picker.
How is Cursor's custom API setup different from Codex and Claude Code?
Cursor sends Chat Completions requests from its own servers, so the base URL must include /v1 and be reachable from the internet, and you need a Premium plan or higher. Codex sends Responses API requests from your computer (base URL with /v1). Claude Code sends Anthropic Messages requests from your computer (base URL without /v1).
Is my API key stored on Cursor's servers?
Cursor says the key isn't stored on its servers, but it's sent to its backend with every request, because all requests are routed through Cursor's servers for final prompt building. That's also why a custom base URL has to be reachable from the public internet.
Found a mistake? Email support@api.foo.