DEV Community

Cover image for How to use a Claude Subscription in Cursor without paying for API tokens
Orchid Files
Orchid Files

Posted on

How to use a Claude Subscription in Cursor without paying for API tokens

In Cursor, you can connect any LLM via API that is compatible with the OpenAI request format. This means you can connect Claude via API and pay for tokens. However, if you have a Claude subscription, you can only use it in Claude Code. There, the request format is Anthropic, which differs from OpenAI. You cannot take your Claude subscription and add it to Cursor because the request formats are incompatible. You cannot make requests to the Claude API using a Claude subscription.

There are already solutions on GitHub that proxy requests from Cursor to Claude using the subscription without paying for API tokens. They convert the OpenAI format to Anthropic and back. But to add this to Cursor, it's not enough to simply run the process on localhost and add the URL to Cursor, because Cursor first sends requests to its own backend, and from there to the OpenAI-compatible API. If you add localhost there, their backend simply won't be able to reach it. That's why you need to set up a tunnel, and Cloudflare is perfect for this. With a single cloudflared tunnel command, you can set up a tunnel that provides a public URL and routes traffic to your localhost. You add this URL to Cursor.
 

How it works

  1. Start the proxy process that converts requests between OpenAI and Anthropic formats
  2. Set up a Cloudflare tunnel and add the URL to Cursor
  3. Send a message in the Cursor chat; it sends a request to its backend
  4. From the backend, it sends a request to Cloudflare, which forwards it to your localhost
  5. The proxy process receives the request from Cloudflare and sends it to Claude
  6. The proxy process receives the response from Claude and sends it to Cloudflare
  7. Cloudflare returns the response to the Cursor backend, which sends it to the IDE
  8. You see the response in the chat  

Various solutions on GitHub retrieve the Claude subscription token in two ways. The first method works only if you already have the Claude CLI installed and are logged in to it. It retrieves the token that the Claude CLI has stored on your system. The second method is not tied to the Claude CLI and allows you to log in to Claude in your browser using OAuth and add the token.

These solutions do not support everything required for development. In some solutions, only the chat is properly proxied, but any use of tools such as reading, modifying files, or creating plans is not supported. Others support tools, but not all of them; for example, sending images or asking questions when creating plans is not supported.

I took the best features from these solutions, added support for all tools, and created a Cursor extension. It allows you to log in to Claude via OAuth, launches a process to proxy requests, and establishes a Cloudflare tunnel. The entire setup takes 30 seconds, and you can use your Claude subscription in Cursor without paying for API tokens.

Project repository: https://github.com/orchidfiles/ungate
VSX Marketplace: https://open-vsx.org/extension/orchidfiles/ungate
Installation from the terminal: cursor --install-extension orchidfiles.ungate
 

After installing the extension in Cursor, an "Ungate :47821" button will appear in the status bar. This means that the proxy service is running on port 47821. Clicking the button will open the Dashboard, which displays statistics on proxied requests and settings. In the settings, you can change the port, restart the tunnel, log in to Claude via OAuth, and view the tunnel and proxy logs. After starting the tunnel, you will receive a URL from Cloudflare. You need to paste this URL into Cursor Settings -> Models -> API Keys -> Override OpenAI Base URL. You also need to paste the API Key, which is displayed on the same settings page, into Cursor Settings -> Models -> API Keys -> OpenAI API Key. This is not related to your Claude subscription. It is just an API key for the proxy service, so other people cannot send requests through your proxy if they do not know this key. It is generated when you install the extension. After configuring these settings, you can select any Claude model in the Cursor chat, and all requests will go through your Claude subscription.
 

Important details

  • Anthropic allows the subscription to be used only in Claude Code and prohibits its use in other tools
  • When you first run the proxy, the extension downloads a build of better-sqlite3 compatible with your OS and Cursor version
  • When you first launch the tunnel, the extension downloads a build of cloudflared
  • When adding or changing tools, you must add them to the mapping Cursor tools -> Claude Code tools -> Cursor tools
  • When adding new Sonnet, Opus, or Haiku models, you must add them to the code
  • There are issues when making changes to large documents and plans; you need to ask the agent to make changes in parts

Top comments (0)