How to Use Cursor AI with Claude 3.5 Sonnet (Step-by-Step Guide)

Sebastian Petrus
5 min readSep 4, 2024

--

Cursor AI is a powerful development environment that integrates seamlessly with various AI models, including Claude 3.5 Sonnet. This article will explore two methods to use Claude 3.5 Sonnet within Cursor AI, providing detailed steps for each approach.

Method 1: Using Anthropic API Directly

The most reliable way to use Claude 3.5 Sonnet in Cursor AI is by directly connecting to the Anthropic API. Here’s a detailed guide on how to set it up:

Step 1. Obtain an Anthropic API Key

To get started, you’ll need to acquire an API key from Anthropic. Visit the Anthropic website (https://www.anthropic.com) and create an account if you don’t already have one. Once logged in, navigate to the API section of your account dashboard. Look for an option to generate a new API key. This key is crucial for authenticating your requests to the Anthropic API, so make sure to copy it and store it in a secure location. Remember, this key should be kept confidential as it provides access to paid services.

Create an Anthropic API Key

Step 2. Configure Cursor AI Settings

Launch the Cursor AI application on your computer, ensuring you’re running the latest version for optimal compatibility. Look for the settings icon, typically represented by a gear symbol, in the main interface. Click on this to open the Settings panel. Within the Settings, locate the “AI Models” or “Integrations” section. This is where you’ll input your Anthropic API key and enable Claude 3.5 Sonnet.

Cursor Settings

In the API key field, carefully paste your Anthropic API key, double-checking for any accidental extra spaces or characters. Next, find the list of available AI models and locate Claude 3.5 Sonnet. There should be a toggle switch or checkbox next to it — activate this to enable the model. Some versions of Cursor AI might require you to select Claude 3.5 Sonnet from a dropdown menu instead.

After entering your API key and enabling Claude 3.5 Sonnet, look for a “Save” or “Apply” button to confirm your changes. Click this to ensure your new settings are activated.

Step 3. Test and Use Claude 3.5 Sonnet

Test API Key with Cursor AI

With the configuration complete, it’s time to test your connection. Close the Settings panel and return to your main Cursor AI workspace. Try using a Claude-specific command or prompt to ensure the integration is working correctly. For example, you could ask Claude to explain a code snippet or suggest improvements to a function.

If everything is set up correctly, you should receive responses from Claude 3.5 Sonnet. You can now use its capabilities for various tasks such as code completion, refactoring, answering queries, and more within your Cursor AI environment.

Method 2: Using OpenRouter API (Currently Not Working)

While this method is currently experiencing issues, here’s what the process would typically involve:

Step 1. Get an OpenRouter API Key

Get an OpenRouter API Key

OpenRouter is a service that allows access to multiple AI models, including Claude 3.5 Sonnet, through a single API. To use this method, you would need to sign up for an OpenRouter account and obtain an API key from their website. This process is similar to getting an Anthropic API key, but you’d be using OpenRouter’s platform instead.

Step 2. Configure Cursor AI for OpenRouter

How to Configure Cursor AI for OpenRouter

In Cursor AI’s settings, you would need to add a custom API endpoint for OpenRouter. This typically involves entering the OpenRouter base URL (usually something like https://api.openrouter.ai/api) in a designated field. You would then input your OpenRouter API key in the appropriate section.

The next step would be to select Claude 3.5 Sonnet from the list of models available through OpenRouter. However, due to ongoing issues, this selection might not be visible or functional at the moment.

Augest 30. 2024. Update: Users have reported several issues when trying to use Claude 3.5 Sonnet with Cursor AI, particularly through the OpenRouter method. These include API key errors, incorrect routing of requests, and connectivity problems.

While the Cursor AI team works on resolving these issues, the most effective workaround is to use the Anthropic API directly (Method 1). If you encounter persistent problems, try clearing and resyncing your codebase indexing in Cursor AI settings, which can sometimes resolve connection issues.

By following these steps and being aware of current limitations, you can maximize your chances of successfully using Claude 3.5 Sonnet within Cursor AI. Remember to be patient as the developers work on enhancing the integration and resolving existing issues.

Before we conclude, let’s talk about something that we all face during development: API Testing with Postman for your Development Team.

Yeah, I’ve heard of it as well, Postman is getting worse year by year, but, you are working as a team and you need some collaboration tools for your development process, right? So you paid Postman Enterprise for…. $49/month.

Now I am telling you: You Don’t Have to:

APIDog: You Get Everything from Postman Paid Version, But CHEAPER

That’s right, APIDog gives you all the features that comes with Postman paid version, at a fraction of the cost. Migration has been so easily that you only need to click a few buttons, and APIDog will do everything for you.

APIDog has a comprehensive, easy to use GUI that makes you spend no time to get started working (If you have migrated from Postman). It’s elegant, collaborate, easy to use, with Dark Mode too!

APIDog makes you very easy to migrate from Postman with No Learning Curve

Want a Good Alternative to Postman? APIDog is definitely worth a shot. But if you are the Tech Lead of a Dev Team that really want to dump Postman for something Better, and Cheaper, Check out APIDog!

--

--

Sebastian Petrus
Sebastian Petrus

Written by Sebastian Petrus

Asist Prof @U of Waterloo, AI/ML, e/acc

No responses yet