Hypereal AIHypereal AI
Video StudioVideo AgentMedia APICoding LLMsMCP
视频 APISeedance 2.0KlingVeo 3.1Gemini Omni VideoHappyHorse 1.1HappyHorse 1.0全部模型 →
图像 APIGPT Image 2Nano BananaFLUXMidjourney Alternative全部模型 →
LLM APIClaude OpusClaude SonnetClaude FableGPT-5.5GPT-5.5 ProGemini 3 ProGemini 3.5 FastGemini 3.5 ThinkingDeepSeek全部模型 →
价格
API 参考示例集
企业版推广计划关于我们更新日志联系我们

价格

返回文章列表
AITutorialDeveloper Tools

How to Add Custom API Keys to Cursor: Complete Guide (2026)

Use your own OpenAI, Anthropic, and Google API keys in Cursor

Hypereal AI TeamHypereal AI Team
9 min read
2026年2月6日
100+ AI 模型,一个 API

开始使用 Hypereal AI 构建

通过单个 API 访问 Kling、Flux、Sora、Veo 等模型。免费额度即可起步,可扩展至千万级。

获取免费 API Key查看文档

无需信用卡 • 10 万+ 开发者 • 企业级服务

How to Add Custom API Keys to Cursor: Complete Guide (2026)

⚠️ Note — GPT-5.5 BYOK is currently broken in Cursor. Cursor's BYOK validator is rejecting gpt-5.5 regardless of provider — confirmed in the Cursor forum thread. Until Cursor ships the fix, use gpt-5.4 (works perfectly) or any Claude / Gemini model in Cursor BYOK. gpt-5.5 itself still works fine in Codex CLI, OpenCode, or direct API calls — only Cursor BYOK is affected.

Cursor is one of the most popular AI-powered code editors, but its built-in AI usage comes with monthly limits. By adding your own API keys, you can bypass these limits, choose your preferred models, and control costs directly. This guide walks you through adding API keys from OpenAI, Anthropic, Google, and other providers to Cursor.

Why Add Custom API Keys?

There are several reasons to bring your own API keys to Cursor:

Benefit Default Cursor Custom API Keys
Monthly fast requests 50 (free) / 500 (Pro) Unlimited (pay per token)
Model selection Cursor's available models Any model from your provider
Cost control Fixed subscription Pay only for what you use
Rate limits Shared with all users Your own API rate limits
Privacy Cursor processes requests Direct to provider

If you already have API credits from OpenAI, Anthropic, or Google, using them in Cursor means you do not need a Cursor Pro subscription for AI features.

Step 1: Open Cursor Settings

There are two ways to access the API key settings in Cursor:

Method 1: Settings UI

  1. Open Cursor.
  2. Press Cmd + , (macOS) or Ctrl + , (Windows/Linux) to open Settings.
  3. Click on "Models" in the left sidebar.

Method 2: Command Palette

  1. Press Cmd + Shift + P (macOS) or Ctrl + Shift + P (Windows/Linux).
  2. Type "Cursor Settings" and select "Cursor: Open Cursor Settings."
  3. Navigate to the "Models" section.

You will see a list of AI providers with fields for API keys.

Step 2: Add an OpenAI API Key

Get your OpenAI API key

  1. Go to platform.openai.com/api-keys.
  2. Click "Create new secret key."
  3. Name it something like "Cursor IDE" for easy identification.
  4. Copy the key (it starts with sk-).

Add it to Cursor

  1. In Cursor Settings > Models, find the "OpenAI API Key" field.
  2. Paste your API key.
  3. Click "Verify" to test the connection.

Once added, you can use OpenAI models like GPT-4o, GPT-4o-mini, o4-mini, and o3 in Cursor's chat, inline edits, and agent mode.

Recommended OpenAI models for Cursor

Model Best For Cost (per 1M tokens)
gpt-4o General coding, complex tasks $2.50 in / $10 out
gpt-4o-mini Fast completions, simple tasks $0.15 in / $0.60 out
o4-mini Reasoning, debugging $1.10 in / $4.40 out
o3 Complex architecture decisions $2.00 in / $8.00 out

Step 3: Add an Anthropic API Key

Get your Anthropic API key

  1. Go to console.anthropic.com.
  2. Sign in or create an account.
  3. Navigate to "API Keys" and click "Create Key."
  4. Copy the key (it starts with sk-ant-).

Add it to Cursor

  1. In Cursor Settings > Models, find the "Anthropic API Key" field.
  2. Paste your API key.
  3. Click "Verify."

You now have access to Claude models directly through your own API key.

Recommended Anthropic models for Cursor

Model Best For Cost (per 1M tokens)
claude-sonnet-4-5-20250514 Best all-around coding $3.00 in / $15.00 out
claude-haiku-3-5-20241022 Fast completions, light tasks $0.80 in / $4.00 out
claude-opus-4-20250514 Complex reasoning, architecture $15.00 in / $75.00 out

For most coding tasks, Claude Sonnet 4.5 offers the best balance of quality and cost.

Step 4: Add a Google Gemini API Key

Get your Google AI API key

  1. Go to aistudio.google.com/apikey.
  2. Click "Create API Key."
  3. Select or create a Google Cloud project.
  4. Copy the generated key.

Google offers a generous free tier for Gemini models, making this a cost-effective option.

Add it to Cursor

  1. In Cursor Settings > Models, find the "Google AI API Key" field.
  2. Paste your API key.
  3. Click "Verify."

Recommended Google models for Cursor

Model Best For Cost (per 1M tokens)
gemini-2.0-flash Fast, cost-effective coding Free tier available
gemini-3-pro-preview Complex multi-file tasks $1.25 in / $10.00 out
gemini-2.5-flash Balanced speed and quality $0.15 in / $0.60 out

The Gemini 2.0 Flash free tier is particularly useful -- you get substantial free usage before paying anything.

Step 5: Add a Custom OpenAI-Compatible Endpoint

Cursor supports any API that follows the OpenAI API format. This lets you connect to:

  • Local models via Ollama
  • Together AI
  • Groq
  • Fireworks AI
  • OpenRouter
  • Any OpenAI-compatible server

Connect Ollama (local models)

First, install and run Ollama:

# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh

# Pull a coding model
ollama pull qwen2.5-coder:14b

# Ollama runs on localhost:11434 by default

Then in Cursor:

  1. Go to Settings > Models.
  2. Find "OpenAI API Base URL" or "Override OpenAI Base URL."
  3. Set the base URL to http://localhost:11434/v1.
  4. Set the API key to ollama (any non-empty string works).
  5. Add the model name qwen2.5-coder:14b to your model list.

Connect OpenRouter (access 100+ models)

OpenRouter lets you access hundreds of models through a single API key.

  1. Go to openrouter.ai and create an account.
  2. Generate an API key.
  3. In Cursor, set the OpenAI Base URL to https://openrouter.ai/api/v1.
  4. Paste your OpenRouter API key in the OpenAI API Key field.
  5. Use model identifiers like anthropic/claude-sonnet-4-5, google/gemini-3-pro-preview, etc.

Connect Groq (fast inference)

Groq offers extremely fast inference for open-source models.

  1. Go to console.groq.com and create an account.
  2. Generate an API key.
  3. In Cursor, set the OpenAI Base URL to https://api.groq.com/openai/v1.
  4. Paste your Groq API key.
  5. Use models like llama-3.3-70b-versatile or mixtral-8x7b-32768.

Step 6: Configure Model Preferences

After adding your API keys, you can configure which model Cursor uses for different tasks.

Set default models

In Cursor Settings > Models, you can assign models to specific features:

  • Chat: The model used for Cursor Chat (Cmd+L). Recommended: Claude Sonnet 4.5 or GPT-4o.
  • Inline Edit: The model used for inline code edits (Cmd+K). Recommended: Claude Sonnet 4.5 or GPT-4o.
  • Agent: The model used for agent mode. Recommended: Claude Sonnet 4.5.
  • Tab Completion: The model for autocomplete suggestions. Recommended: A fast model like GPT-4o-mini or Gemini Flash.

Example configuration for cost optimization

Use cheaper models for frequent, simple tasks and premium models for complex work:

Feature Model Why
Tab completion gpt-4o-mini Fast, cheap, high volume
Inline edits claude-sonnet-4-5 Good quality for targeted changes
Chat claude-sonnet-4-5 Best for discussions and planning
Agent mode claude-sonnet-4-5 Strong for multi-step tasks

Step 7: Verify Everything Works

Test each API key by running a simple task:

  1. Chat test: Press Cmd+L, select your custom model, and ask "Write a hello world function in Python."
  2. Inline edit test: Select a block of code, press Cmd+K, and ask "Add error handling to this function."
  3. Agent test: Start agent mode and ask "Create a new file called test.py with a function that calculates factorial."

If any test fails, check:

  • The API key is entered correctly (no extra spaces).
  • Your API account has credits or an active payment method.
  • The base URL is correct (especially for custom endpoints).
  • The model name matches the provider's naming convention.

Troubleshooting Common Issues

Issue Cause Fix
"Invalid API key" Wrong key or expired Regenerate the key from the provider
"Model not found" Wrong model name Check the provider's docs for exact model IDs
"Rate limit exceeded" Too many requests Wait and retry, or upgrade your API tier
"Connection refused" (Ollama) Ollama not running Start Ollama with ollama serve
Slow responses Server location Choose a provider with servers near you
"Insufficient credits" No balance Add funds to your API account

Frequently Asked Questions

Do I still need Cursor Pro if I add my own API keys? No. With your own API keys, you can use AI features without a Cursor Pro subscription. However, some Cursor-specific features like advanced tab completions may still require Pro.

Which API key is the most cost-effective? Google Gemini offers the most generous free tier. For paid usage, GPT-4o-mini and Gemini Flash are the cheapest quality options.

Can I use multiple API keys at the same time? Yes. You can add keys from multiple providers and switch between models as needed. Cursor will use the appropriate key based on which model you select.

Are my API keys stored securely? Cursor stores API keys locally on your machine. They are not uploaded to Cursor's servers when you use your own keys -- requests go directly to the provider.

Does using custom API keys affect Cursor's built-in limits? Yes. When you use your own API key, those requests do not count against Cursor's free or Pro request limits. You are billed directly by the API provider.

Wrapping Up

Adding custom API keys to Cursor gives you full control over your AI coding experience. You can choose models based on task complexity, manage costs precisely, and avoid hitting Cursor's built-in limits. The setup takes less than five minutes per provider.

If you are building applications that need AI-generated media alongside your code, try Hypereal AI free -- 35 credits, no credit card required. The API integrates seamlessly into projects you build in Cursor or any other editor.

相关文章

Claude Code 入门指南与最佳实践 (2026)

12 min read

Claude Code IDE 集成:VS Code、JetBrains 等 (2026)

13 min read

如何在 Windows 环境下通过 WSL 使用 Codex (2026)

10 min read

On this page

  • How to Add Custom API Keys to Cursor: Complete Guide (2026)
  • Why Add Custom API Keys?
  • Step 1: Open Cursor Settings
  • Step 2: Add an OpenAI API Key
  • Get your OpenAI API key
  • Add it to Cursor
  • Recommended OpenAI models for Cursor
  • Step 3: Add an Anthropic API Key
  • Get your Anthropic API key
  • Add it to Cursor
  • Recommended Anthropic models for Cursor
  • Step 4: Add a Google Gemini API Key
  • Get your Google AI API key
  • Add it to Cursor
  • Recommended Google models for Cursor
  • Step 5: Add a Custom OpenAI-Compatible Endpoint
  • Connect Ollama (local models)
  • Connect OpenRouter (access 100+ models)
  • Connect Groq (fast inference)
  • Step 6: Configure Model Preferences
  • Set default models
  • Example configuration for cost optimization
  • Step 7: Verify Everything Works
  • Troubleshooting Common Issues
  • Frequently Asked Questions
  • Wrapping Up
Desktop agent

Download Hypereal Agent

Run a local AI media workspace for image generation, video prompts, model selection, credit tracking, and saved artifacts.

MacWindows
v0.1.2Requires a hypereal.cloud API keyRelease manifest
Hypereal Agent desktop app screenshot

立即开始构建

立即开始构建
LogoHypereal AI
所有系统正常
LLM API
  • Hypereal SDK
  • MCP Server
  • Enterprise API
  • All LLM Models
  • Claude Fable 5
  • Claude Opus 4.7
  • Claude Sonnet 4.6
  • GPT-5.5
  • Claude Haiku 4.5
  • GPT-5.5 Pro
  • Gemini 3.1 Pro Preview
  • Gemini 3.5 Thinking
  • Gemini 3.5 Fast
  • DeepSeek V4 Pro
  • Kimi K2.6
  • GLM 5.2
  • Claude API in China
  • OpenAI API in China
AI API
  • AI API Overview
  • Seedance 2.0 API
  • Kling 3.0 API
  • Veo 3.1 API
  • FLUX API
  • GPT Image 2 API
  • vs WaveSpeed
  • vs fal.ai
  • vs Replicate
  • vs KIE.ai
  • vs OpenRouter
  • vs Together AI
  • vs SiliconFlow
  • Midjourney Alternative
  • Higgsfield Alternative
  • OpenRouter Alternative
视频模型
  • Google Veo 3.1 API
  • Kling 3.0 API
  • Kling O3 Pro API
  • Seedance 2.0 API
  • HappyHorse 1.1 API
  • HappyHorse 1.0 API
  • WAN 2.7 API
  • WAN Video API
  • Grok Video API
  • Hunyuan Video API
  • PixVerse V6 API
  • Pika Video API
  • Luma Dream Machine API
  • MiniMax Video API
  • Vidu Video API
  • Gemini Omni Video API
图像模型
  • NanoBanana 2 API
  • FLUX 2 API
  • GPT Image 1 API
  • Grok Image API
  • SeeDream V5 API
  • Imagen 4 API
  • Ideogram API
  • Recraft API
  • DALL-E 3 API
  • Stable Diffusion API
  • Gemini Image API
工具
  • Face Swap API
  • Video Face Swap API
  • Virtual Try-On API
  • AI Talking Avatar API
  • Lip Sync API
  • OmniHuman Avatar API
  • Tripo3D H3.1 API
  • ElevenLabs TTS API
  • Fish Audio TTS API
  • Whisper STT API
  • Lyria Music API
生成器
  • Video Agent
  • AI 图像生成器
  • AI 视频生成器
合集
  • 最佳视频模型
  • 最佳图像模型
  • Seedance 2.0
  • WAN 2.7
  • Qwen Image 2
  • Grok AI
  • Seedance 1.5
  • 运动控制
  • 内容检测
  • 目标检测
公司
  • 关于我们
  • 文档
  • Hypereal SDK
  • Cookbook
  • 更新日志
  • 博客
  • 联系我们
  • 常见问题
  • 路线图
  • 企业版
  • 联盟分销计划
  • Be a Creator
  • 开发者计划
法律
  • 隐私政策
  • 服务条款
  • 退款政策
  • Cookie 政策
  • 价格
  • 所有模型
  • 站点地图
  • Status
© 版权所有 2026。保留所有权利。
TwitterGitHubLinkedInYouTubeEmail