api2cursor  by h88782481

API proxy enabling Cursor to use third-party LLM relay stations

Created 4 months ago
262 stars

Top 97.0% on SourcePulse

GitHubView on GitHub
Project Summary

Summary

API 2 Cursor addresses the incompatibility between Cursor's varied LLM API request formats and the standard protocols supported by third-party API gateways. It acts as a protocol bridge, enabling Cursor Pro users to leverage any LLM API via these gateways by translating request and response formats. This enhances flexibility for users seeking to integrate diverse AI models.

How It Works

The project functions as a protocol bridge, translating between Cursor's three input API formats (/v1/chat/completions, /v1/responses, /v1/messages) and various upstream backend protocols (OpenAI CC, Anthropic Messages, Responses, Gemini). Core logic resides in chat.py, responses.py, and messages.py, which adapt requests based on model mapping and upstream gateway capabilities. This architecture ensures seamless communication regardless of the specific API format used by Cursor or the gateway.

Quick Start & Requirements

  • Installation: Clone the repository, install dependencies via pip install -r requirements.txt, copy and edit the .env.example file with gateway details, then run python start.py.
  • Docker: Use docker compose up -d after configuring .env.
  • Prerequisites: Python environment, requirements.txt dependencies.
  • Configuration: Via .env file (PROXY_TARGET_URL, PROXY_API_KEY, PROXY_PORT). Model mapping and custom endpoints are configurable via the admin panel at http://localhost:3029/admin.
  • Cursor Setup: Add custom models in Cursor settings, pointing to http://localhost:3029 and using the ACCESS_API_KEY.

Highlighted Details

  • Protocol Translation: Supports bridging Cursor's Chat Completions, Responses, and Messages formats to OpenAI, Anthropic, Responses, and Gemini backends.
  • Model Mapping: Flexible configuration of Cursor model names to upstream model names and backend types via a web admin panel.
  • Compatibility Fixes: Automatic correction for Cursor's tools format, reasoningContent, <think> tags, function_call to tool_calls conversion, missing tool_calls fields, smart quotes, file_path to path mapping, and finish_reason adjustments.
  • Debugging: Three logging levels (off, simple, verbose) controllable via environment variables or the admin panel, with detailed conversation logging.

Maintenance & Community

No specific details regarding maintainers, community channels (e.g., Discord, Slack), or project roadmap were found in the provided README content.

Licensing & Compatibility

  • License: MIT License.
  • Compatibility: The MIT license permits broad use, including commercial applications and linking within closed-source projects.

Limitations & Caveats

The project requires an external third-party API gateway to function. Setup involves configuring environment variables and potentially adjusting Cursor's model settings. No explicit mention of alpha status, known bugs, or unsupported platforms was present in the README.

Health Check
Last Commit

3 days ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
15 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.