danilofalcao/cursor-deepseek
关于
一款支持 HTTP/2 的高性能代理服务器,专为让 Cursor IDE 的 Composer 使用 DeepSeek 和 OpenRouter 的语言模型而设计。该代理会将兼容 OpenAI 的 API 请求转换为 DeepSeek/OpenRouter API 格式,使 Cursor 的 Composer 及其他兼容 OpenAI API 的工具能够无缝使用这些模型。
系统与基础设施可以做什么
- HTTP/2 support for improved performance
- Full CORS support
- Streaming responses
- Support for function calling/tools
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文DeepSeek API Proxy
A high-performance HTTP/2-enabled proxy server designed specifically to enable Cursor IDE's Composer to use DeepSeek's, OpenRouter's and Ollama's language models. This proxy translates OpenAI-compatible API requests to DeepSeek/OpenRouter/Ollama API format, allowing Cursor's Composer and other OpenAI API-compatible tools to seamlessly work with these models.
Primary Use Case
This proxy was created to enable Cursor IDE users to leverage DeepSeek's, OpenRouter's and Ollama's powerful language models through Cursor's Composer interface as an alternative to OpenAI's models. By running this proxy locally, you can configure Cursor's Composer to use these models for AI assistance, code generation, and other AI features. It handles all the necessary request/response translations and format conversions to make the integration seamless.
Features
- HTTP/2 support for improved performance
- Full CORS support
- Streaming responses
- Support for function calling/tools
- Automatic message format conversion
- Compression support (Brotli, Gzip, Deflate)
- Compatible with OpenAI API client libraries
- API key validation for secure access
- Docker container support with multi-variant builds
Prerequisites
- Cursor Pro Subscription
- Go 1.19 or higher
- DeepSeek or OpenRouter API key
- Ollama server running locally (optional, for Ollama support)
- Public Endpoint
Installation
- Clone the repository
- Install dependencies:
go mod download
Docker Installation
The proxy supports both DeepSeek and OpenRouter variants. Choose the appropriate build command for your needs:
Build the Docker image:
- For DeepSeek (default):
docker build -t cursor-deepseek .- For OpenRouter:
docker build -t cursor-openrouter --build-arg PROXY_VARIANT=openrouter .- For Ollama:
docker build -t cursor-ollama --build-arg PROXY_VARIANT=ollama .Configure environment variables:
- Copy the example configuration:
cp .env.example .env- Edit
.envand add your API key (either DeepSeek or OpenRouter)
Run the container:
docker run -p 9000:9000 --env-file .env cursor-deepseek
# OR for OpenRouter
docker run -p 9000:9000 --env-file .env cursor-openrouter
# OR for Ollama
docker run -p 9000:9000 --env-file .env cursor-ollama
Configuration
The repository includes an .env.example file showing the required environment variables. To configure:
- Copy the example configuration:
cp .env.example .env
- Edit
.envand add your API key:
# For DeepSeek
DEEPSEEK_API_KEY=your_deepseek_api_key_here
# OR for OpenRouter
OPENROUTER_API_KEY=your_openrouter_api_key_here
# OR for Ollama
OLLAMA_API_KEY=your_ollama_api_key_here
Note: Only configure ONE of the API keys based on which variant you're using.
Usage
- Start the proxy server:
go run proxy.go
# OR you can specify a model:
go run proxy.go -model coder
# OR
go run proxy.go -model chat
# OR for OpenRouter
go run proxy-openrouter.go
# OR for Ollama
go run proxy-ollama.go
The server will start on port 9000 by default.
- Use the proxy with your OpenAI API clients by setting the base URL to
http://your-public-endpoint:9000/v1
Exposing the Endpoint Publicly
You can expose your local proxy server to the internet using ngrok or similar services. This is useful when you need to access the proxy from external applications or different networks.
Using ngrok
Install ngrok from https://ngrok.com/download
Start your proxy server locally (it will run on port 9000)
In a new terminal, run ngrok:
ngrok http 9000
ngrok will provide you with a public URL (e.g., https://your-unique-id.ngrok.io)
Use this URL as your OpenAI API base URL in Cursor's settings:
https://your-unique-id.ngrok.io/v1
Alternative Methods
You can also use other services to expose your endpoint:
Cloudflare Tunnel:
- Install cloudflared
- Run:
cloudflared tunnel --url http://localhost:9000
LocalTunnel:
- Install:
npm install -g localtunnel - Run:
lt --port 9000
- Install:
Remember to always secure your endpoint appropriately when exposing it to the internet.
Supported Endpoints
/v1/chat/completions- Chat completions endpoint/v1/models- Models listing endpoint
Model Mapping
gpt-4omaps to DeepSeek's GPT-4o equivalent modeldeepseek-chatfor DeepSeek's native chat modeldeepseek/deepseek-chatfor OpenRouter's DeepSeek model
Dependencies
github.com/andybalholm/brotli- Brotli compression supportgithub.com/joho/godotenv- Environment variable managementgolang.org/x/net- HTTP/2 support
Security
- The proxy includes CORS headers for cross-origin requests
- API keys are required and validated against environment variables
- Secure handling of request/response data
- Strict API key validation for all requests
- HTTPS support through HTTP/2
- Environment variables are never committed to the repository
License
This project is licensed under the GNU General Public License v2.0 (GPLv2). See the LICENSE.md file for details.
探索相关项目
加载中…