How to use ChatGPT and Claude subscriptions in Cursor without paying for API tokens

от автора

In Cursor, you can connect any LLM via API that is compatible with the OpenAI request format. However, if you have a Claude or ChatGPT subscription, you won’t be able to use them directly in Cursor. Their request formats differs from the OpenAI API format, so you’ll need a workaround — proxying the requests.

There are already solutions on GitHub that convert the OpenAI format to the provider’s required format and back. But to add this to Cursor, simply running the process on localhost and adding it to Cursor is not enough, because Cursor first sends requests to its own backend, and from there to an 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 that forwards traffic to your localhost. Cloudflare is very well suited for this. With the cloudflared tunnel command, you can start a tunnel and add the tunnel address to Cursor.

So, when you buy a $20 ChatGPT subscription, you get access to ~$1,000 worth of tokens. When you buy a $100 Claude subscription, you get access to ~$2,000 worth of tokens. However, to use custom OpenAI URLs in Cursor, you’ll also need a $20 Cursor subscription.

These solutions do not support everything required for development. In some of them, only chat is proxied properly, while tool use, such as modifying files or using planning mode, is not supported. Others support only some tools, but not all of them. In some cases, only Claude is supported, and ChatGPT does not work.

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 and ChatGPT via OAuth, launches a process to proxy requests, and establishes a Cloudflare tunnel. The entire setup takes just one minute, and you can use your subscriptions in Cursor instead of paying for API tokens.

GitHub: https://github.com/orchidfiles/ungate

Installation

You can install the extension from the Extensions panel in Cursor by searching for @id:orchidfiles.ungate.

Install from the terminal: cursor --install-extension orchidfiles.ungate

You can also compile the extension from source:

git clone https://github.com/orchidfiles/ungate.gitcd ungatepnpm installpnpm run package:buildcursor --install-extension "apps/extension/out/ungate.vsix"

After installing the extension in Cursor, a button labeled Ungate: API running | Tunnel stopped appears in the status bar. It means the proxy service is running and the tunnel is paused. Clicking it opens the Dashboard with proxied request statistics and settings. In Settings, you can change the port, restart the tunnel, log in to Claude and ChatGPT via OAuth, and view the tunnel and proxy logs.

Initial setup:

  • Start a tunnel in the dashboard and get the URL from Cloudflare.

  • Paste this URL into Cursor Settings -> Models -> API Keys -> Override OpenAI Base URL.

  • Copy the API Key from the dashboard and paste it into Cursor Settings -> Models -> API Keys -> OpenAI API Key. This is not your subscription key, but the API key for the proxying service, so that other people cannot make requests to your localhost. It’s generated when the extension is installed.

  • Copy the ID of the desired model and add a custom model in Cursor using that exact name.

Once you’ve done this, you can select this model in Cursor chat, and all requests will be routed through your subscription.

The extension has a quick actions menu. When you hover over the extension in the status bar, a tooltip will appear. In it, you can restart the tunnel, copy the tunnel address, and toggle request proxying.

Issues and Solutions

  1. Cursor automatically disables the custom OpenAI Base URL setting every few hours, causing all requests to go through API tokens again. This “bug” has existed for a very long time, and they haven’t fixed it. I think it’s not economically viable for them to fix this bug. The extension automatically checks whether this setting is enabled. When Cursor unchecks this, the extension re-enables it.

  2. Standard model names in Cursor only work for certain providers. For example, if you send a request using the built-in GPT-5.4 model, the request will go through the proxy using your subscription. But if you use Sonnet 4.7, the request will go through the API to Claude using tokens. In the extension, you can create custom model names and add them to Cursor so that requests are guaranteed to go through the proxy.

  3. To avoid releasing a new extension for every version of Node and OS, the extension downloads the better-sqlite3 and cloudflared builds from their repositories during the initial installation.

  4. If you disconnect your laptop from the internet and then reconnect, you need to restart the tunnel. If you see “Reconnecting…” when making a request in the chat, you need to restart the tunnel.

  5. If you receive a 401 error when making requests, it means you have an incorrect API key. You need to go to the extension’s Dashboard, copy the api-key, and paste it into Cursor Settings -> Models -> API Keys -> OpenAI API Key.

  6. If you receive a 404 error, it means the tunnel is not running or the tunnel address is incorrect.

  7. Automatic token refresh only works for Claude. With ChatGPT, you need to re-authorize your account via OAuth every few weeks.

If something does not work in the extension, or if you have any questions, please create an issue on GitHub or write here in the comments. I would appreciate any feedback.

My BlogTelegram ChannelBluesky

ссылка на оригинал статьи https://habr.com/ru/articles/1039334/