# deepseek-cursor-proxy **Repository Path**: wangtaosz/deepseek-cursor-proxy ## Basic Information - **Project Name**: deepseek-cursor-proxy - **Description**: deepseek-cursor代理 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2026-05-15 - **Last Updated**: 2026-05-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # DeepSeek Cursor Proxy 一个兼容代理,通过正确处理 DeepSeek thinking 模型的 `reasoning_content` 字段,让 Cursor 能够使用 `deepseek-v4-pro` / `deepseek-v4-flash` 等 thinking 模型。 ## 前置条件 - 安装 [Docker](https://docs.docker.com/get-docker/) 和 Docker Compose - 一个 [ngrok](https://ngrok.com/) 免费账号(Cursor 不允许直连 localhost,需要 ngrok 提供公网 HTTPS 地址) ## 快速开始 ### 1. 获取 ngrok authtoken 登录 [ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken),复制你的 authtoken。 ### 2. 配置环境变量 将项目根目录下的 `.env.example` 复制为 `.env`,并填入你的 ngrok authtoken: ```bash cp .env.example .env ``` 编辑 `.env`: ```env NGROK_AUTHTOKEN=你的ngrok-authtoken ``` ### 3. 配置 ngrok 域名(可选) 编辑 `docker-compose.yml`,将 `--ngrok-url` 参数替换为你自己的 ngrok 域名: ```yaml command: ["deepseek-cursor-proxy", "--ngrok", "--ngrok-url", "你的域名.ngrok-free.dev"] ``` 如果不指定 `--ngrok-url`,ngrok 会每次分配一个临时域名,你需要每次将新域名更新到 Cursor 的 Base URL 中。 ### 4. 启动服务 ```bash docker compose up -d ``` 首次启动会自动: - 构建 Docker 镜像 - 在 `~/.deepseek-cursor-proxy/` 下创建配置文件和推理缓存(SQLite) - 配置 ngrok authtoken ### 5. 查看 ngrok 公网地址 ```bash docker compose logs -f ``` 启动后会打印 ngrok 公网地址,类似 `https://xxx.ngrok-free.dev`。 ### 6. 配置 Cursor 在 Cursor 中添加自定义模型: - **Model**: `deepseek-v4-pro` - **API Key**: 你的 DeepSeek API key - **Base URL**: ngrok 公网地址 + `/v1`,例如 `https://xxx.ngrok-free.dev/v1` 配置完成后在 Cursor 中选择 `deepseek-v4-pro` 即可开始使用。 ## 常用命令 ```bash # 启动服务 docker compose up -d # 查看日志 docker compose logs -f # 重启服务 docker compose restart # 停止服务 docker compose down # 重新构建镜像 docker compose build --no-cache # 清除推理缓存(重启容器后生效) docker compose down docker volume rm deepseek-cursor-proxy-data docker compose up -d ``` ## 配置说明 ### 环境变量 (.env) | 变量 | 说明 | |------|------| | `NGROK_AUTHTOKEN` | ngrok 认证令牌 | ### 命令行参数 | 参数 | 说明 | |------|------| | `--ngrok` | 启用 ngrok 隧道 | | `--no-ngrok` | 禁用 ngrok(仅用于 localhost 测试或其他允许本地地址的应用) | | `--ngrok-url` | 指定固定的 ngrok 域名 | | `--port` | 本地监听端口,默认 9000 | | `--no-display-reasoning` | 在 Cursor UI 中隐藏思考过程 | | `--verbose` | 打印详细的请求/响应日志 | | `--config` | 指定配置文件路径 | 参数通过修改 `docker-compose.yml` 中的 `command` 字段来生效。 ### 持久化数据 项目使用两个 Docker Volume 持久化数据: - `deepseek-cursor-proxy-data`: 配置文件 (`config.yaml`) 和推理缓存 (`reasoning_content.sqlite3`) - `deepseek-cursor-proxy-ngrok`: ngrok 配置文件(authtoken 等) ## 故障排查 ### 容器无法启动 ```bash # 查看详细错误 docker compose logs deepseek-cursor-proxy # 确保 .env 文件存在且已填入 ngrok authtoken cat .env ``` ### ngrok 报错 ```bash # 检查 ngrok 配置是否成功 docker compose exec deepseek-cursor-proxy ngrok config check # 验证 authtoken docker compose exec deepseek-cursor-proxy ngrok config authtoken ``` ### Cursor 连接报 400 错误 这通常意味着 ngrok 域名与 Cursor Base URL 不匹配。查看日志中的公网地址,更新 Cursor 配置即可。 ### 清除所有数据重新开始 ```bash docker compose down -v docker compose up -d ``` ## 工作原理 DeepSeek 的 [thinking 模式 tool calls](https://api-docs.deepseek.com/guides/thinking_mode#tool-calls) 要求在多轮对话中回传完整的 `reasoning_content` 链。Cursor 不会发送此字段,导致 400 错误。本代理在 Cursor 与 DeepSeek API 之间缓存原始的 `reasoning_content`,并在每次请求时自动补全缺失的字段,同时将思考过程以 Markdown 折叠块形式展示在 Cursor 中。