API reference
Import everything from the public package:
from cursor_agent import (
SyncClient,
AsyncClient,
Agent,
AsyncAgent,
CursorAPIError,
CursorClient,
DEFAULT_BASE_URL,
)
CursorClient is an alias for cursor_agent.SyncClient.
- class cursor_agent.Agent(client: SyncClient, *, repo: str | None = None, ref: str | None = None, pr_url: str | None = None)[source]
Bases:
objectOne
Agentinstance maps to one Cursor cloud agent (one id from the API).Use with
SyncClient. Callcreate()once (POST /v0/agents), thenfollow_up()for further prompts. Orattach()andfollow_up()only.- create(prompt: str, *, model: str | None = None, target: dict[str, Any] | None = None, webhook: dict[str, Any] | None = None, images: list[dict[str, Any]] | None = None) dict[str, Any][source]
Create the cloud agent (
POST /v0/agents).Requires
repo/pr_urlfromSyncClient.new_agent(). Call at most once perAgentinstance; for more prompts usefollow_up().
- follow_up(prompt: str, *, images: list[dict[str, Any]] | None = None) dict[str, Any][source]
POST /v0/agents/{id}/followup— send another prompt to the same cloud agent.
- class cursor_agent.AsyncAgent(client: AsyncClient, *, repo: str | None = None, ref: str | None = None, pr_url: str | None = None)[source]
Bases:
objectAsync counterpart to
Agentfor use withAsyncClient.Methods mirror
Agentbut are async.
- class cursor_agent.AsyncClient(api_key: str, *, base_url: str = 'https://api.cursor.com', timeout: float = 120.0)[source]
Bases:
objectAsync client for the Cursor Cloud Agents API (
httpx.AsyncClient).Use
async with AsyncClient(...)or callaclose()when done.- classmethod from_httpx_client(client: AsyncClient) AsyncClient[source]
Wrap an existing
httpx.AsyncClient(you manage base URL and auth).
- new_agent(repo: str | None = None, *, ref: str | None = None, pr_url: str | None = None) AsyncAgent[source]
- async launch_agent(*, prompt: str, repository: str | None = None, ref: str | None = None, pr_url: str | None = None, model: str | None = None, target: dict[str, Any] | None = None, webhook: dict[str, Any] | None = None, images: list[dict[str, Any]] | None = None) dict[str, Any][source]
- exception cursor_agent.CursorAPIError(message: str, *, status_code: int | None = None, response: Response | None = None)[source]
Bases:
ExceptionRaised when the API returns an error response.
- cursor_agent.CursorClient
alias of
SyncClient
- class cursor_agent.SyncClient(api_key: str, *, base_url: str = 'https://api.cursor.com', timeout: float = 120.0)[source]
Bases:
objectSynchronous client for the Cursor Cloud Agents API.
See https://cursor.com/docs/cloud-agent/api/endpoints
Authentication uses HTTP Basic auth: API key as username, empty password (equivalent to
curl -u YOUR_API_KEY: ...).- classmethod from_httpx_client(client: Client) SyncClient[source]
Wrap an existing
httpx.Client(you manage base URL and auth).
- new_agent(repo: str | None = None, *, ref: str | None = None, pr_url: str | None = None) Agent[source]
Create an
Agentbound to a GitHub repo or PR.Pass
repo(repository URL) orpr_url— same rules asPOST /v0/agentssource. UseAgent.create()for the first prompt, thenAgent.follow_up()for more.
- list_repositories() dict[str, Any][source]
GET /v0/repositories— GitHub repositories accessible to the key.
- launch_agent(*, prompt: str, repository: str | None = None, ref: str | None = None, pr_url: str | None = None, model: str | None = None, target: dict[str, Any] | None = None, webhook: dict[str, Any] | None = None, images: list[dict[str, Any]] | None = None) dict[str, Any][source]
POST /v0/agents— start a new agent.Provide either
repository(and optionallyref) orpr_urlfor the source.