Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mocking

API Automated Testing

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

Updated on April 12, 2025

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:

  • The charges for AI usage will appear on your provider account billing (OpenAI, Anthropic, etc.)
  • Your API key will be sent to Cursor's server with each request (though not stored permanently)
  • Cursor handles the final prompt building and processing through its backend

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
  • Log in to your OpenAI account
  • Navigate to the API section
  • Generate a new API key
  • Copy the key to your clipboard (note that OpenAI only shows the key once)
  1. In Cursor's Custom API Keys settings:
  • Locate the "OpenAI API Keys" section
  • Paste your API key into the provided field
  • Click the "Verify" button to validate the key
  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
  • Sign up for or log in to your Anthropic account
  • Navigate to the API section
  • Generate a new API key
  • Copy the key
  1. In Cursor's Custom API Keys settings:
  • Find the "Anthropic API Keys" section
  • Paste your Anthropic API key into the field
  • Click "Verify" to validate the key
  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
  • Sign in to your Google account with API access
  • Navigate to the appropriate credentials section
  • Create a new API key specifically for AI/Gemini usage
  • Copy the key
  1. In Cursor's Custom API Keys settings:
  • Locate the "Google API Keys" section
  • Enter your Google API key
  • Click "Verify" to validate
  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
  • Create an Azure OpenAI resource
  • Deploy the models you want to use
  • Obtain your API key and endpoint information
  1. In Cursor's Custom API Keys settings:
  • Find the "Azure Integration" section
  • Enter your Azure API key and any required endpoint information
  • Configure additional Azure-specific settings if needed
  • Click "Verify" to validate the connection
  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.

How to Use the NVIDIA Llama Nemotron API for Advanced AI AgentsTutorials

How to Use the NVIDIA Llama Nemotron API for Advanced AI Agents

Learn to use the NVIDIA Llama Nemotron API for building AI agents with advanced reasoning.

Ashley Innocent

April 11, 2025

How to Use the Grok-3 APITutorials

How to Use the Grok-3 API

Discover how to use the Grok-3 API with Apidog in this technical guide. Learn setup, text generation, advanced features, and best practices for seamless integration. Download Apidog free and start building with the powerful Grok-3 API today!

Ashley Innocent

April 10, 2025

Automate Mac with Claude's Computer Use, Here's How:Tutorials

Automate Mac with Claude's Computer Use, Here's How:

Discover how to use Claude's Computer Use API in conjunction with Python to automate various operations on your macOS system.

Emmanuel Mumba

April 9, 2025