Point Cursor at a custom Anthropic base URL
Cursor lets you override the API endpoint it talks to. Once you do, every request is billed against your own key at your own rate instead of Cursor's pooled quota.
curl https://aicomp.ai/v1/models \
-H "Authorization: Bearer sk-your-gateway-key"
You should get back a JSON list of model IDs. If you see
Invalid token, the key is wrong or was not copied in full.
Step 1 — create a key
Sign up, generate an API key in the dashboard, and copy your base URL (https://aicomp.ai/v1).
Step 2 — open the override field
In Cursor: Settings → Models. Look for the base URL override (in some versions it sits under "Override OpenAI Base URL" or the Anthropic section). Enter:
https://aicomp.ai/v1
Then paste your key into the API key field and save.
Step 3 — confirm it took effect
Open a new chat and send a short message. If routing works you get a normal reply. To be certain, check the usage log in your gateway dashboard (the request should appear there within a minute).
If it does not work
| Symptom | Fix |
|---|---|
| Invalid API key | Cursor may cache the old key. Restart Cursor fully after saving. |
| 404 errors | Remove or add the /v1 suffix so it is not doubled. |
| Falls back to Cursor quota | Some versions ignore the override unless "use my own key" is explicitly enabled. |
| Empty model list after saving | The URL is missing its scheme or its /v1 segment. Paste the whole root, including https://. |
| Works in chat, fails in agent mode | Agent mode sends a longer context, and needs tool calls and streaming that plain chat never exercises. See the Agent-mode triage table before assuming the base URL is wrong. |
Why changing one URL is enough
An OpenAI-compatible client does not have a provider hardcoded into it. It holds a base
URL, and at request time it concatenates that base URL with a resource path —
/chat/completions, /models, then sends the same JSON body it would
have sent anywhere else, with your key in an Authorization: Bearer header. The
base URL is therefore the only thing that decides where the request physically goes.
That is why this change is one line and not a rewrite. Your message array, your tool
definitions, your streaming handling and your response parsing are all unchanged, because the
wire format is unchanged. What changes is who answers, and what they charge per token. The two
values that travel with the new destination are the base URL itself and the API key; the model
ID is the third, and it has to be one the new endpoint actually serves, which you can list with
a single call to /v1/models rather than guess at.
The practical consequence is that this is reversible. Keep the base URL in configuration rather than inline, and moving between providers is a config change you can undo in a minute — which is also the right way to test it: point a single non-critical call at the new endpoint first, confirm it in the usage log, then move the rest.
What it does not change
Swapping the base URL is narrower than it looks, and the gap between expectation and reality is where most of the frustration comes from.
- Not every endpoint on the surface. Compatibility usually covers
/chat/completionsand/models. Embeddings, audio, files, fine-tuning and the newer response APIs are a separate question (assume they are absent until you have listed them). - Not the model's own limits. Context window, output cap, rate limits and moderation behaviour belong to the model and the provider serving it. A shorter context window on the far side shows up as truncation, not as an error.
- Not your timeout and retry semantics. Those live in your client. A gateway adds a hop, so an aggressive timeout that was fine against a direct provider can start failing here, set it explicitly rather than inheriting a default.
- Not your error handling. Status codes mean roughly the same thing but the bodies differ between providers. Anything that parses an error message string is the first thing to break.
- Not the identity of the caller. The endpoint sees one key. If several people or services share it, their spend is indistinguishable in the usage log. Give each one its own key before you need to tell them apart.
What it costs
| Model | Gateway rate in / out per 1M tokens | Official list in / out per 1M tokens | Diff |
|---|---|---|---|
| claude-haiku-4-5 | $0.5 / $2.5 | $1 / $5 | 50% |
| claude-sonnet-5 | $1 / $5 | $2 / $10 | 50% |
| claude-opus-5 | $2.5 / $12.5 | $5 / $25 | 50% |
Rates checked 2026-11-02. Gateway rates move with upstream promotions, verify the current number in your dashboard before committing to a budget.
| Workload | claude-haiku-4-5-20251001 | claude-sonnet-5 | claude-opus-5 |
|---|---|---|---|
| Chat assistance 50 requests a day, 2k in / 500 out | $2 | $4 | $11 |
| Bulk processing 5,000 short jobs a day, 800 in / 300 out | $115 | $230 | $575 |
| Agent loop 20 turns a day, 60k in / 800 out | $13 | $26 | $64 |
One month at 20 working days, gateway rates checked 2026-11-02. These are the token volumes, not a quote Your own shape may be larger or smaller.
The agent row is the one that surprises people. Autocomplete and chat feel cheap because they are mostly short output; an agent run resends the working context on every turn, so input, not output, becomes most of the bill, and the gap between the cheapest and most expensive model in that row is several times wider than in the chat row. With your own key your bill is pure token spend, with no per-request markup on top. Estimate it with the Cursor cost calculator, or compare Sonnet 5 against Haiku 4.5 for your workload For autocomplete and small edits the difference is most of the bill.
FAQ
Can I use my own Claude API key in Cursor?
Yes. Cursor accepts an Anthropic API key and, in current versions, lets you override the base URL. With both set, requests bill to your key instead of consuming Cursor's pooled quota.
Where exactly is the base URL setting?
Under Cursor Settings → Models. Depending on version it appears as an Anthropic base URL field or alongside the 'Override OpenAI Base URL' option. If it is not exposed in the UI, it can be set in settings.json and Cursor restarted.
How do I know Cursor is actually using my key?
A successful reply is not proof. Check your gateway usage log, if the request does not appear there within a minute, Cursor is still routing through its own quota.
Do I still pay Cursor if I use my own key?
You pay for token spend on your own account rather than drawing down Cursor's included usage. Your subscription covers the editor; the API consumption is billed wherever your key lives.
Does it work in agent mode?
Yes, provided the model you selected is reachable through the configured endpoint. Agent mode sends more context per turn, so the per-token rate matters more there than in ordinary chat.
What is the Cursor custom API endpoint URL?
It is whatever your provider publishes as its OpenAI-compatible root — usually ending in /v1. Paste the whole thing including the scheme; a base URL without https://, or one missing the /v1 segment, is the most common cause of a blank model list after saving.
Can I point Cursor at a non-Anthropic model this way?
Yes, if the endpoint speaks the OpenAI-compatible /chat/completions shape That is the whole point of routing through one gateway. Cursor still labels the field as an Anthropic override, but what it sends is a standard request, so any model the gateway exposes on that route will answer.
Why is agent mode so much more expensive than chat?
Because each turn resends the accumulated context, not just your new message. A chat exchange is mostly short output; an agent run is overwhelmingly input, and input is priced separately. That is also why switching to a cheaper model helps more in agent mode than in chat — and why a model with a cheap input rate but a dearer output rate can come out ahead here while losing on a chat workload.
Can I use one key across a whole team?
Technically yes, and operationally it is a mistake. The endpoint sees a single credential, so every person's spend lands in one indistinguishable usage log, and rotating the key means interrupting everyone at once. Issue one key per person or per service before you need to attribute a bill to someone. Retrofitting that after the fact does not work, because the usage log cannot be un-mixed.
Next
- Full walkthrough: Claude API in Cursor
- Which Cursor features actually reach your endpoint (Agent mode), sub-agents and Tab
- Chat works but Agent fails, tool calls, streaming and context exhaustion
- Do the same in Cline — another editor agent on an OpenAI-compatible endpoint
- Every tool that accepts a custom endpoint (LiteLLM, Vercel AI SDK), Cline and the rest
- Do the same in Continue — roles let autocomplete use a cheaper model than chat
- Eight ways to cut the bill
- All model prices