Categories
Software Development

Adding Claude 3 Opus (or any other model) to Cursor

Cursor is a VSCode fork with built-in support for large language models (LLMs). It allows users to select code, hit Ctrl+K, write an LLM prompt, and see how the LLM writes or changes code for them. Cursor is backed by OpenAI, which is why they currently only support OpenAI's API and models (GPT-4 and GPT-3).

Recently, Anthropic released Claude 3 Opus, a new model that outperforms GPT-4 in code generation. Many Cursor users have expressed interest in using Claude 3 Opus, but Cursor hasn't integrated it yet.

Update: You can now simply add "claude-3-opus" as a custom model in the Settings page without using OpenRouter. Just do steps 4, 5, 6, 8, 9, then enter "claude-3-opus", then step 11 and close settings.

Using OpenRouter.ai

OpenRouter.ai is a SaaS that provides an API mimicking the OpenAI API, but allows users to choose from a large list of models, including open-source models, proprietary models like OpenAI's GPT models, and Anthropic's Claude 3 models.

By using OpenRouter, we can use Claude 3 Opus (or any other supported model) in Cursor.

Here's a step-by-step guide:

  1. Create an account on OpenRouter.ai.
  2. Go to Account → Settings, save your payment details, and add credits (set up auto-top up if desired).
  3. Go to Account → API Keys and create a new API key (you can set a credit limit).
  4. Open Cursor.
  5. Hit Ctrl+Shift+J to enter Cursor settings.
  6. Scroll to "OpenAI API".
  7. Enter the OpenRouter key you generated where it says "Enter your OpenAI API Key".
  8. Click on "Configure models" below the API key field.
  9. Click on "+ Add model" (below the model names).
  10. Enter "anthropic/claude-3-opus" as the model name.
  11. Click on the "+" next to the field.
  12. There's a small text with an arrow that says "Override OpenAI Base URL (when using key)". Click on this.
  13. Enter "https://openrouter.ai/api/v1" into this field (as the API base URL).
  14. Important: Click on the tiny arrow to the right of the OpenAI API key field above.
  15. Wait (there's no indication of wait time).
  16. A small switch/checkbox "Using key" should appear below the OpenAI API key field. Ensure it's green/checked.
  17. (Optional) You can disable all models except the new anthropic/claude-3-opus. Alternatively, you can have multiple models active and choose when using Ctrl+K or chat.
  18. Use Cursor as before with the new Claude 3 Opus model.

Other Models

With this setup, you're not limited to using Claude 3 Opus. You can use any of the models supported by OpenRouter. Check out the list of supported models for more options.

Leave a Reply

Your email address will not be published. Required fields are marked *