How to Add Custom API Keys to Cursor: A Comprehensive Guide

This tutorial will guide you through the process of setting up and managing custom API keys in Cursor, covering all supported providers: OpenAI, Anthropic, Google, and Azure

Mark Ponomarev

Mark Ponomarev

26 June 2025

How to Add Custom API Keys to Cursor: A Comprehensive Guide

Introduction

Cursor is a powerful AI-enhanced code editor that leverages large language models (LLMs) to help developers write, understand, and transform code more efficiently. One of its key features is the ability to use custom API keys from various providers, giving you more control over your AI usage while allowing unlimited AI messages at your own cost. This tutorial will guide you through the process of setting up and managing custom API keys in Cursor, covering all supported providers: OpenAI, Anthropic, Google, and Azure.

💡
Before diving into detaiils, check out Apidog—a powerful tool for designing, testing, and documenting APIs. Apidog allows you to seamlessly integrate your APIs, enhancing your workflow with structured models and easy collaboration. If you're looking to boost your automation and API management.
button

Why Use Custom API Keys in Cursor?

Before diving into the setup process, let's understand why you might want to use your own API keys:

  1. Cost Control: Manage and monitor your own AI usage expenses directly with the provider.
  2. Higher Rate Limits: Potentially access higher rate limits than what's available on Cursor's shared infrastructure.
  3. Model Flexibility: Use specific models and configurations that align with your development needs.
  4. Privacy Considerations: Have more direct control over how your code and prompts are processed.

Understanding API Key Integration in Cursor

When you configure custom API keys in Cursor, the application will use your provided keys to make calls to the respective LLM providers for AI-assisted features. This means:

It's important to note that some specialized features like Tab Completion require specific models and won't work with custom API keys. Custom keys only work for features utilizing standard models from the supported providers.

Setting Up Custom API Keys in Cursor

Step 1: Access the Settings Panel

  1. Open the Cursor application on your computer

2. Click on the Settings icon (typically found in the right sidebar or menu)

3. In the Settings menu, locate and select "Models"

This will take you to the API key configuration page where you can add keys for different providers.

Step 2: Adding an OpenAI API Key

OpenAI's models, including GPT-4 and GPT-3.5, are among the most widely used in Cursor. Here's how to add your OpenAI API key:

  1. First, obtain an API key from the OpenAI platform
  1. In Cursor's Custom API Keys settings:
  1. Once successfully verified, your OpenAI API key will be enabled and Cursor will start using it for appropriate features

Important Note: OpenAI's reasoning models (o1, o1-mini, o3-mini) require special configuration and are not currently supported with custom API keys.

Step 3: Adding an Anthropic API Key

Anthropic's Claude models provide another powerful option for AI-assisted development. To add your Anthropic API key:

  1. Obtain an API key from Anthropic's developer platform
  1. In Cursor's Custom API Keys settings:
  1. After successful verification, Cursor will use your Anthropic API key for claude-based model interactions

Step 4: Adding a Google API Key

Google's Gemini models are another option for AI assistance in Cursor. To configure a Google API key:

  1. Obtain an API key from Google AI Studio or Google Cloud Platform
  1. In Cursor's Custom API Keys settings:
  1. Upon verification, your Google API key will be used for models like gemini-1.5-flash-500k at your own cost

Step 5: Setting Up Azure Integration

For organizations using Azure OpenAI services, Cursor offers integration with Azure's API. To configure:

  1. Set up Azure OpenAI in your Azure portal
  1. In Cursor's Custom API Keys settings:
  1. After verification, Cursor will route appropriate requests to your Azure OpenAI deployment

Managing Your API Keys

Monitoring Usage

Since you're using your own API keys, monitoring usage is important:

  1. Track provider billing: Regularly check your billing dashboards at OpenAI, Anthropic, Google, or Azure to monitor costs
  2. Set budget alerts: Configure spending limits or alerts with your providers to avoid unexpected charges
  3. Evaluate usage patterns: Consider which models and features you're using most frequently to optimize costs

Securing Your API Keys

While Cursor doesn't store your API keys permanently, they are transmitted with requests. To maintain security:

  1. Use appropriate permissions: Create API keys with the minimum necessary permissions
  2. Rotate keys regularly: Periodically generate new API keys and update them in Cursor
  3. Monitor for unauthorized usage: Check for unusual activity in your provider dashboards
  4. Never share keys: Avoid sharing API keys or including them in code repositories

Troubleshooting Common Issues

Key Verification Failures

If you encounter issues verifying your API key:

  1. Check for typos: Ensure the API key is copied correctly without extra spaces
  2. Verify account status: Confirm your provider account is in good standing with available credits
  3. Check rate limits: Temporary verification issues might occur if you've hit rate limits
  4. Try a different browser/device: Sometimes local network issues can interfere with verification

Feature Compatibility

Remember that not all Cursor features work with custom API keys:

  1. Tab Completion: This feature requires specialized models and won't work with custom keys
  2. Provider-specific features: Some capabilities might be tied to specific providers or models
  3. Model availability: Ensure the models you need are available and enabled in your provider account

Frequently Asked Questions

Will my API key be stored or leave my device?

Your API key will not be permanently stored by Cursor, but it will be sent to Cursor's server with every request. All requests are routed through Cursor's backend where the final prompt building occurs.

What custom LLM providers are supported?

Cursor officially supports OpenAI, Anthropic, Google, and Azure. The application also supports API providers that are compatible with the OpenAI API format (like OpenRouter). Cursor does not provide support for custom local LLM setups or other API formats.

Can I switch between custom and Cursor-provided API keys?

Yes, you can disable your custom API keys at any time to return to using Cursor's built-in service, subject to any plan limitations.

Enhance Your AI Automation with Apidog MCP Server Integration
Take your AI-driven workflows even further by integrating with the Apidog MCP Server.

This powerful connection allows your AI assistant to interact directly with API specifications from Apidog projects, enabling seamless API exploration, code generation, and structured model creation.

Conclusion

Adding custom API keys to Cursor gives you greater flexibility and control over your AI-assisted development workflow. By following this tutorial, you can seamlessly integrate your preferred AI providers—whether OpenAI, Anthropic, Google, or Azure—and leverage the full power of Cursor while managing costs on your terms.

Remember that while custom API keys offer many advantages, they also come with the responsibility of monitoring and managing your own usage. Regularly check your provider billing dashboards to ensure you're staying within budget, and take appropriate measures to secure your API keys.

With your custom API keys properly configured, you can enjoy unlimited AI assistance in Cursor, tailored to your specific development needs and preferences.

Explore more

Complete Guide to Creating Online API Documentation

Complete Guide to Creating Online API Documentation

Delve into the ultimate guide for creating online API documentation. Learn the essentials, best practices, and a step-by-step guide on creating online API documentation.

2 July 2025

5 Easy Methods to Control API Documentation Access in Apidog

5 Easy Methods to Control API Documentation Access in Apidog

Not all API docs should be public. With Apidog, you can control who sees what—use password protection, IP or email allowlists, or even connect your own login system. This guide walks through each method to help you choose the right one for your API access needs.

1 July 2025

Apidog SEO Settings Explained: Maximize Your API Docs Visibility

Apidog SEO Settings Explained: Maximize Your API Docs Visibility

Discover how to supercharge your API documentation's visibility with Apidog's powerful SEO features. This comprehensive guide covers everything from page-level optimizations like custom URLs and meta tags to site-wide settings such as sitemaps and robots.txt.

18 June 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs