Skip to main content

Cursor

Point Cursor's bring-your-own-key lane at the gateway: every model your org holds a key for, in Ask, Plan, and Agent, with the full optimizer and per-developer spend.

Only chat routes. Tab, inline edit (Cmd/Ctrl+K), Cloud Agents, and Cursor's own models (Auto, Composer) stay on Cursor.

You need a gateway on public HTTPS (Cursor's servers make the call), one provider key on the gateway, Cursor Pro, Teams, or Enterprise, and each developer enrolled with a personal ark_… key.

Route Cursor through Anyray​

1
Quit Cursor

The write only lands while Cursor is closed.

2
Connect the developer
Direct gateway
anyray-connect https://gateway.example.com --org --tools cursor \
--user developer@example.com --yes

--org sets Cursor's Override OpenAI Base URL and OpenAI API Key, and installs the hooks and MCP server.

3
Add the model in Cursor

Cursor → Settings → Models → add a custom model named anyray-default and enable it. Leave every other provider-key field (Anthropic, Google, Azure, Bedrock) off.

4
Pick it in the chat box

Choose anyray-default in Ask, Plan, or Agent. It routes to your deployment's default model.

warning

Pick only names you added. The override captures every OpenAI-family model, built-ins such as gpt-6.1-sol included, and those fail.

5
Verify the lane
anyray-connect doctor --verify

It passes when the base URL, enable toggle, personal ark_… key, and at least one custom model all match. Then send one Ask prompt and find it in console Sessions, and one Agent turn that edits a file to prove the tool-call round trip.

Routed requests get the same treatment as Claude Code, including cache_optimizer. Claude and Gemini work on this lane too; the gateway translates to each provider's wire format, tool calls included.

Offer a menu of models​

Cursor rejects a custom model named like a built-in, so give each alias an Anyray name, then add those names as custom models in Cursor:

PUT /admin/model-aliases
{
"anyray-opus": "anthropic/claude-opus-5-5",
"anyray-sonnet": "anthropic/claude-sonnet-5-5",
"anyray-gpt": "openai/gpt-6.1-sol"
}

An alias binds provider and model, so re-pointing it moves every developer with no client edit. Requires modelaliases:write; ANYRAY_MODEL_ALIASES seeds the map at boot (endpoint reference).

Set it up by hand

Connect prints these steps when it cannot recognize Cursor's settings shape.

1
Open the key settings
Cursor → Settings → Models → OpenAI API Key.
2
Override the base URL
Enable Override OpenAI Base URL and set it to https://gateway.example.com/v1/seat/cursor.
3
Set the key
Paste the key from anyray-connect print-key, restart Cursor, and add the models as above.
Cost and prompt visibility

Provider usage bills to the org's key, less what the optimizer removes. Each active developer counts as one Anyray seat, identified by the /v1/seat/cursor path.

Cursor still charges its seat, and on Teams and Enterprise its Token Rate (US$0.25 per million tokens) applies to BYOK requests too.

Cursor's backend assembles every BYOK request, and its Zero Data Retention terms do not cover BYOK. What the gateway keeps follows Anyray's content mode.

Retrieval-gated trimming

The in-flight eliders (relevance_filter and friends) run when the request declares the anyray_retrieve tool, or under a fresh lease. Connect renews the lease every 5 minutes while Cursor keeps the stdio transport alive; it expires after 6 hours without verified activity.

Whether Cursor forwards MCP tools into BYOK requests varies by release. A routed Agent trace shows one of:

  • the eliders among the optimizer decisions
  • no_retrieve: the tool was not forwarded
  • toolless_turn: the turn declared no tools; no fix needed

Troubleshooting​

SymptomFix
The model "X" is already available as "Y" when adding a modelName collides with a built-in. Register an alias and add that name.
Sessions empty, doctor reports no model registeredAdd anyray-default or an alias, enable it, relaunch, select it.
Sessions empty, doctor reports the lane healthyYou picked a Cursor model (Auto, Composer, native Claude). Pick an Anyray name.
424 with no provider key configured for <provider>Add that provider key on Providers, or re-point the alias.
The Agent explains a change but never edits the fileAnother provider key is enabled. Disable it, quit Cursor fully, relaunch.
A request with no model lands on the gateway (a Cursor 3.x Agent-mode bug)It routes to anyray-default. Register an alias to change that.
doctor reports Cursor not pointed at the gateway after it workedQuit Cursor, run anyray-connect doctor --repair, relaunch.
A built-in model errors with The requested model is not availableThe override captured it. Pick an Anyray name.

Keep Cursor's native models​

For orgs staying on Cursor's own Claude and Opus. Anyray never sees the model request but trims the local tool output that feeds it.

1
Enroll the developer without --org
Direct gateway
anyray-connect https://gateway.example.com --tools cursor \
--user developer@example.com --yes

No inference base URL is set and no Cursor credential is copied.

2
Restart Cursor once

It loads the MCP registration on launch; hooks.json reloads on its own.

Coming from BYOK, Connect first restores the two journaled Cursor settings, which needs Cursor closed. If it reports the restore as queued, quit Cursor, wait for the watcher, then reopen.

3
Verify native mode
anyray-connect status

Healthy means the Shell, Read/Grep, MCP, and prompt hooks and the retrieval MCP registration are present. Native prompts do not appear as gateway traces; savings show in Sessions as connect hook · tool-output optimization.

SeamWhat it does
preToolUse shell hookRuns recognized bulky shell commands through Anyray's output reducer.
preToolUse Read/Grep hookRedirects a bulky built-in Read or Grep to anyray_read or anyray_search, which return trimmed content.
postToolUse MCP hookTrims an oversized anyray_read or anyray_search result reversibly. Other MCP results pass through.
The anyray MCP serveranyray_retrieve, anyray_recall, anyray_search, anyray_read, anyray_history.

Size gates and fail-open limits: Cursor reference.

Routing boundary​

The OpenAI override is Cursor's only redirectable inference seam. Native Team Claude and Opus, Tab, inline edit, Cloud Agents, and indexing cannot be redirected, so hooks are the limit there.

For full optimization of a subscription Claude session, use Claude Code with its own Claude Pro, Max, Team, or Enterprise plan via ANTHROPIC_BASE_URL. A Cursor Team entitlement does not work in Claude Code.

What Cursor's Admin API can import: Cursor reference.