Web Analytics

cursor-deepseek-v4-proxy

⭐ 131 stars English by wustghj

🧠 Cursor DeepSeek V4 Proxy

One-click fix for the reasoning_content error when using DeepSeek V4 in Cursor, say goodbye to Rate limit exceeded, and make AI Agent mode run stably.

GitHub stars License: MIT


📌 What problems can this project solve for you?

If you frequently encounter any of the following errors when calling DeepSeek V4 (Pro / Flash) in Cursor:

No need to struggle anymore, follow this guide and solve it completely in 5 minutes.

⚠️ Fixed on 2026-05-14: Pure text models now automatically filter images, resolving 502 errors. See Changelog for details.


✨ Core Features

---

🖥️ Supported Environments

| Operating System | Support Status | | :--- | :--- | | Windows 10 / 11 | ✅ Supported | | macOS | ✅ Supported | | Linux | ✅ Supported |

Only requirement: Install Python 3.8 or higher (be sure to check Add Python to PATH during installation).


🚀 Super Detailed Three-Step Getting Started (For Beginners)

Step 1: Download the project and install dependencies

``bash pip install -r requirements.txt ` If you see the prompt pip is not an internal command, please reinstall Python and check Add to PATH.

Step 2: Start Local Proxy + Tunnel

You need a tunnel to generate a public address (Cursor restricts access to localhost).

#### 🪟 Windows Users

#### 🍎 macOS / Linux Users
  • Open the terminal, navigate to the project directory, and run:
`bash bash start_proxy.sh ` > ⚠️ Note: Do not close the window. The tunnel address changes each time it restarts, but it remains valid as long as the window stays open.

Step 3: Configure Cursor

---

🛡️ Fix "Model name not valid" Error

If you encounter an error when running Apply or background tasks, follow these steps:

`json "cursor.models": { "deepseek-v4-pro": { "provider": "openai", "apiBase": "https://你的隧道地址.trycloudflare.com/v1", "apiKey": "你的DeepSeek API Key" } } `
  • Save and restart Cursor.
---

❓ FAQ

🔁 What if the tunnel address changes? A new address is generated every time the script restarts. You just need to retrieve it again and update the Base URL in Cursor.

💸 Still getting "Rate limit exceeded"? DeepSeek's free tier has a very low frequency limit. You can edit proxy.py and reduce the 5 in TokenBucket(rate=5/60.0, capacity=5) (e.g., to 3) to forcibly lower the request frequency.

🚫 Must I use a tunnel? Can I connect to localhost? Cursor forbids direct connections to localhost for security reasons. Cloudflare Tunnel is currently the simplest, free, and registration-free penetration solution.

🧪 Does the proxy affect the model's intelligence? In 99% of scenarios, it is imperceptible. The proxy only automatically completes when the model "forgets" to return the thought chain, ensuring the conversation is uninterrupted.

🧪 Why is there only 200k context, not 1M? This is the default limitation of Cursor, not the proxy issue.

Cursor uses a 200k context window by default. To enable the 1M context supported by the model, you need to turn on Max Mode in Cursor Chat. Path: Chat -> Model Selector -> Max Mode


⚙️ Advanced Customization

🆕 Changelog

2026-05-14: Plain Text Model Image Compatibility Fix

Fix Details When clients like Cursor send messages containing images to deepseek-v4-pro (plain text model), the proxy layer now automatically filters out the image_url content blocks, keeping only the text part. If a message consists entirely of images (no text), it is replaced with a prompt text to avoid the model receiving an empty message. This fix resolves the 502 error caused by DeepSeek API returning "unknown variant image_url, expected text".

Additional Improvements

------

Acknowledgments

Thanks to @BG-ah for reporting the rate limit issue in Issue #4, and to @CH-nolyn for participating in the discussion. Your feedback directly drove this compatibility fix, making the proxy run more stably under the plain text model.

------

💡 Tip: If you want the model to truly understand image content, please change the model field in your request to the multimodal-supported deepseek-chat`, and ensure your DeepSeek account has the corresponding permissions enabled.

--- Tranlated By Open Ai Tx | Last indexed: 2026-06-24 ---