Skip to main content

Cursor pass-through

The /cursor route forwards Cursor Cloud Agents API paths to Cursor. That covers launching an agent with POST /v0/agents, reading its status and conversation, adding follow-ups, stopping or deleting it, and listing models and repositories. Cursor authenticates with Basic auth built from the Cursor key, and the gateway builds that header from its own credential, so callers only need a virtual key. Every call is checked against the key and recorded in the spend logs. To use gateway models in the Cursor editor's chat and agent, see Cursor instead.

A real-world scenario​

An engineering manager wants a ticket bot to launch Cursor cloud agents on bug reports. The bot runs in a shared automation platform where a Cursor key would be visible to many people. The bot calls /cursor/v0/agents on the gateway with a virtual key. The Cursor key stays on the gateway, the admin sets a price per agent run so the bot's monthly budget counts its launches, and every launched agent is listed on the Logs page with the key that launched it.

Before you start​

The gateway needs a Cursor credential. It looks, in order, for a model_list deployment of provider Cursor with use_in_pass_through: true, for a Cursor credential saved on the LLM Credentials tab, and for the environment below.

VariablePurpose
CURSOR_API_KEYThe Cursor key the gateway sends upstream.
CURSOR_API_BASEOptional. Changes the upstream address from https://api.cursor.com.
CURSOR_AGENT_RUN_COST_USDOptional, default 0. The price in US dollars the gateway records for each agent launch (POST /v0/agents) and each follow-up (POST /v0/agents/{id}/followup).

Cost and budgets​

Cursor's API does not report what an agent run costs, so the gateway cannot read a price from the answer. By default every Cursor call is recorded at a cost of 0, which means a key's budget never goes down from Cursor use and only stops Cursor calls once other spend on the same key has used it up. To make budgets count Cursor, set CURSOR_AGENT_RUN_COST_USD to what one agent run costs you on average, for example 0.50, and restart the gateway. Launches and follow-ups are then charged that amount against the key, team and user, and status reads, conversation reads, stops, deletes and list calls stay free because Cursor does not bill them as new work. Pick the number from your Cursor invoice divided by the runs in the same period, and revisit it when your usage pattern changes.

Make a key for the bot​

Give each bot or script that launches agents its own key, so its launches, spend and limits stay separate and it can be switched off on its own.

  1. In the Admin UI open Virtual Keys (/ui/api-keys) and click + Create New Key.
  2. Under Key Details, set Key Name to the bot, for example ticket-bot-cursor. Leave Key Type on AI APIs, which covers the /cursor routes and keeps the key away from the management routes.
  3. In Models, pick the models the bot also calls through the gateway, for example claude-haiku-5-5 for its own ticket summaries. An empty Models list lets the key call every model, so pick at least one.
  4. Open Optional Settings. Set Max Budget (USD), for example 50, with Reset Budget on monthly, which counts agent runs once CURSOR_AGENT_RUN_COST_USD is set, and Requests per minute Limit (RPM), for example 10, so a bot stuck in a loop cannot launch agents in a burst.
  5. Click Create Key and copy the key. It is shown once.

The same key from the API, with the master key or a proxy admin's key:

curl -X POST https://gateway.example.com/key/generate \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"key_alias": "ticket-bot-cursor", "key_type": "llm_api", "models": ["claude-haiku-5-5"], "max_budget": 50, "budget_duration": "30d", "rpm_limit": 10}'

Steps​

  1. Give the gateway the credential. Open /ui/models-and-endpoints, open the LLM Credentials tab, click Add Credential, enter a Credential Name, pick Cursor as the Provider, paste the key and click Add Credential. Or set CURSOR_API_KEY and restart the gateway.

  2. Make a key for the bot, as in make a key for the bot.

  3. Launch an agent through the gateway.

    curl -X POST http://localhost:4000/cursor/v0/agents \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"prompt": {"text": "Add unit tests for the refund calculator."}, "source": {"repository": "https://git.example.com/example/billing", "ref": "main"}}'
  4. Read the agent back with GET /cursor/v0/agents/{id} and the same key.

  5. Open /ui/logs and click the newest row to see the request and the key that made it.

Expected result​

Cursor's own response, with its status code and headers.

{
"id": "bc_abc123",
"name": "Add unit tests for the refund calculator",
"status": "CREATING",
"source": {"repository": "https://git.example.com/example/billing", "ref": "main"}
}

The spend log row carries the key, team and user, with the operation as the model name, for example cursor/cursor:agent:create, and the cost set by CURSOR_AGENT_RUN_COST_USD.

Errors​

StatusMessageWhat it means and how to fix it
401Authentication Error, Invalid proxy server token passedThe virtual key is missing, wrong, expired or blocked.
403Key/team denied access to passthrough route /cursor/...The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team.
401Cursor API key not found. Add Cursor credentials via the UI (Models + Endpoints -> LLM Credentials) or set CURSOR_API_KEY environment variable.The gateway has no Cursor credential. Add one as described in step 1.
Any otherCursor's own error bodyCursor refused the request. The message is returned unchanged.

Troubleshooting​

  1. Open Logs (/ui/logs) and filter by the bot's key alias. A row with the Cursor operation means the call reached the gateway, so read its status and message against the table above.
  2. No row means the request never reached the gateway. Check the address and that the path starts with /cursor/v0/.
  3. A 401 that names the Cursor API key means the gateway has no Cursor credential. Check the LLM Credentials tab or CURSOR_API_KEY, then restart the gateway if you set the variable.
  4. A launch that succeeds but leaves the key's spend at 0 means CURSOR_AGENT_RUN_COST_USD is not set, see cost and budgets.

Pass-through endpoints lists every built-in route. The Cursor provider page covers Cursor through the unified endpoints, and agent governance explains how agent runs are tracked.