Configure Bring Your Own Key (BYOK) for AI model providers in Cursor. BYOK lets you use your own API keys to bypass Cursor's monthly quota, pay per token directly, and access models not included in Cursor's subscription.
| Provider | Key Format | Models Available |
|---|---|---|
| OpenAI | sk-proj-... or sk-... |
GPT-4o, GPT-4o-mini, o1, o3, GPT-5 |
| Anthropic | sk-ant-api03-... |
Claude Sonnet, Claude Opus, Claude Haiku |
AIzaSy... |
Gemini 2.5 Pro, Gemini Flash | |
| Azure OpenAI | Azure portal key | Any deployed Azure OpenAI model |
| AWS Bedrock | IAM credentials | Claude, Titan, Llama models |
| OpenAI-compatible | Varies | Ollama, LM Studio, Together AI, etc. |
Cursor Settings > Models > check Use own API key
gpt-4o)Cursor Settings > Models > check Use own API key
Cursor Settings > Models > check Use own API key
Azure requires additional configuration beyond a simple API key:
gpt-4o)Cursor Settings > Models:Azure Configuration:
API Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Endpoint: https://your-instance.openai.azure.com
Deployment: your-gpt4o-deployment-name
API Version: 2024-10-21
For self-hosted models (Ollama, vLLM) or third-party providers:
Cursor Settings > Models > Add Model
llama-3.1-70b
Override OpenAI Base URL
Ollama: http://localhost:11434/v1
LM Studio: http://localhost:1234/v1
Together AI: https://api.together.xyz/v1
BYOK key used: Cursor model (always):
┌──────────────────────┐ ┌──────────────────────┐
│ Chat (Cmd+L) │ │ Tab Completion │
│ Composer (Cmd+I) │ │ Apply from Chat │
│ Agent Mode │ │ (diff application) │
│ Inline Edit (Cmd+K) │ │ │
└──────────────────────┘ └──────────────────────┘
Tab Completion and Apply always use Cursor's proprietary models. You cannot route these through your own API key.
With BYOK, you pay the provider directly. Monitor costs at:
Set monthly spending limits at the provider level:
@Files not @Codebase when you know the location| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|---|---|---|
| GPT-4o | $2.50 | $10.00 |
| GPT-4o-mini | $0.15 | $0.60 |
| Claude Sonnet | $3.00 | $15.00 |
| Claude Opus | $15.00 | $75.00 |
| o1 | $15.00 | $60.00 |
A typical Composer session generating multi-file code uses 5K-20K tokens.
Cursor stores API keys locally in its settings database:
~/Library/Application Support/Cursor/
~/.config/Cursor/
%APPDATA%\Cursor\
Keys are stored in the local Cursor configuration, not in project files. They do not sync between machines.
Cursor Settings > Models
For teams using BYOK:
| Error | Cause | Fix |
|---|---|---|
401 Unauthorized |
Invalid or expired API key | Regenerate key at provider |
429 Rate Limited |
Too many requests | Wait, or upgrade provider plan |
403 Forbidden |
Key lacks model access | Enable model access at provider |
| Model not appearing | Key not saved or wrong provider | Re-enter key in Cursor Settings |
| Azure connection refused | Wrong endpoint or API version | Verify endpoint URL and version |
| Slow responses with BYOK | Provider rate limits apply | Check provider dashboard |