Getting Started
Prerequisites
1. Cursor Agent CLI
Install the Cursor CLI agent (official docs):
Verify it's installed:
2. Authentication
Pick one:
Opens a browser, authenticates with your Cursor account, and stores credentials locally.
Create a key at cursor.com/dashboard/api — see How to create a Cursor API key for a step-by-step walkthrough.
Choose your path
The fastest way to get an OpenAI-compatible API running. No Python needed on the host.
Test it:
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"claude-4.5-sonnet-thinking","messages":[{"role":"user","content":"Hello!"}]}'
See Docker for full deployment docs.
Run the OpenAI-compatible server without Docker:
Server starts on http://localhost:8080. See HTTP Server for full docs.
Your first prompt (Python library)
Create a file called hello.py:
import asyncio
from cursorpipe import CursorClient
async def main():
client = CursorClient()
response = await client.generate(
model="claude-4.5-sonnet-thinking",
prompt="Say hello in a creative way!",
)
print(response)
await client.close()
asyncio.run(main())
Run it:
Speed up with warmup (recommended)
The first request can take ~14s due to process startup and session creation. Add warmup() at startup to move that cost upfront:
async def main():
client = CursorClient()
await client.warmup(pool_size=3) # pre-start process + pre-create sessions
# First request is now as fast as subsequent ones (~5s)
response = await client.generate(
model="claude-4.5-sonnet-thinking",
prompt="Say hello in a creative way!",
)
print(response)
await client.close()
Optional: faster JSON parsing
Install the fast extra for ~4.6x faster JSON serialization (uses Rust-backed orjson):
That's it! Check out the Examples page for streaming, sessions, framework integration, and more. Or jump to HTTP Server / Docker if you want the language-agnostic API.
Configuration
All behaviour is controlled via environment variables (prefix CURSORPIPE_) or a .env file — including port, timeouts, pool size, and transport strategy. See the full Configuration reference.