Convert the Cursor Editor to an OpenAI API interface service.
This project provides a proxy service that converts the AI chat of the Cursor Editor into an OpenAPI API, allowing you to reuse the LLM of the Cursor in other applications.
Visit Cursor and register a account.
- 150 fast premium requests are given, which can be reset by deleting the account and then registering again
- Suggest to use gmail/outlook email, some temp emails have been disabled by Cursor.
The cookie from Cursor webpage does not work in Cursor-To-OpenAI server. You need to get the Cursor client cookie following these steps:
- Run
npm installto initialize the environment。 - Run
npm run login. Open the URL shows in the log, and then login your account. - The cookie shows in your command is the
Curosr Cookievalue. Copy and save it to your notepad.
The log of this command looks like:
[Log] Please open the following URL in your browser to login:
https://www.cursor.com/loginDeepControl?challenge=6aDBevuHkK-HLiZ<......>k2lEjbVRMpg&uuid=5147ac09<....>5fe5f3aeb&mode=login <-- Copy the url and open it in your browser.
[Log] Waiting for login... (1/60)
[Log] Waiting for login... (2/60)
[Log] Waiting for login... (3/60)
[Log] Waiting for login... (4/60)
[Log] Login successfully. Your Cursor cookie:
user_01JJF<.....>K3F4T8%3A%3AeyJhbGciOiJIUzI1NiIsInR5cCI6Ikp<...................>AsCpbPfnlHy022WxmlKIt4Q7Ll0 <-- This is the Cursor cookie, please save it.
We provide an API to save you from manual login. You need to log in to your Cursor account in browser and get WorkosCursorSessionToken from Application-Cookie.
- Get Cursor client cookie
- Url:
http://localhost:3010/cursor/loginDeepContorl - Request:
GET - Authentication:
Bearer Token(The value ofWorkosCursorSessionTokenfrom Cursor webpage) - Reponse: In JSON, the value of
accessTokenis theCursor Cookiein JWT format. That's what you want.
- Url:
Sample request:
import requests
WorkosCursorSessionToken = "{{{Repalce by your WorkosCursorSessionToken from cookie in browser}}}}"
response = requests.get("http://localhost:3010/cursor/loginDeepControl", headers={
"authorization": f"Bearer {WorkosCursorSessionToken}"
})
data = response.json()
cookie = data["accessToken"]
print(cookie)
docker run -d --name cursor-to-openai -p 3010:3010 ghcr.io/jiuz-chn/cursor-to-openai:latest
npm install
npm run start
-
Get models
- Url:
http://localhost:3010/v1/models - Request:
GET - Authentication:
Bearer Token(The value ofCursor Cookie)
- Url:
-
Chat completion
- Url:
http://localhost:3010/v1/chat/completions - Request:
POST - Authentication:
Bearer Token(The value ofCursor Cookie,supports comma-separated values)
- Url:
for the response body, please refer to the OpenAI interface
from openai import OpenAI
client = OpenAI(api_key="{{{Replace by the Cursor cookie of your account. It starts with user_...}}}",
base_url="http://localhost:3010/v1")
response = client.chat.completions.create(
model="claude-3-7-sonnet",
messages=[
{"role": "user", "content": "Hello."},
],
stream=False
)
print(response.choices)
- Please keep your Cursor cookie properly and do not disclose it to others
- This project is for study and research only, please abide by the Cursor Terms of Use
- This project is based on cursor-api(by zhx47).
- This project integrates the commits in cursor-api(by lvguanjun).