cocodot
← Back to guides
Local card declined for overseas AI? cocodot: one card + one key
IntegrationUpdated 2026-08

Use a Claude API Key in Cursor: Custom Endpoint Setup, Model Names, and the Errors

Cursor lets you override the OpenAI base URL, which means you can drive it with any OpenAI-compatible endpoint. Two minutes to configure, and nearly every failure lands in one of three places.

TL;DR: Cursor exposes a standard escape hatch: Settings → Models lets you override the OpenAI Base URL, pointing it at any OpenAI-compatible endpoint. That means you can drive Cursor with your own API credit and your own choice of models rather than a bundled subscription. Three values to set: API key, base URL (ending in `/v1` — this trips people constantly), and model name. One thing to understand before you start: the modes differ. Chat works fully. Tab completion runs on Cursor's own models and is unaffected by your endpoint. Agent and Composer depend on tool-calling behaviour and are worth testing after Chat works rather than at the same time. Nearly all errors are one of three: a model name the endpoint does not recognize, a key without balance, or a base URL missing the `/v1` suffix.

Why this works at all

Cursor speaks the OpenAI chat completions protocol. Any endpoint implementing that protocol is a valid target, which is why the base URL is exposed as a setting rather than hidden. Nothing is being worked around — this is the intended extension point, and the same trick works for any OpenAI-compatible tool.

The two-minute setup

Open Settings → Models. Enable the custom OpenAI key option, paste your key, and set the base URL to your provider's endpoint — for cocodot that is `https://cocodot.co/api/ai/v1`, including the `/v1`. Add the model names you intend to use. Then verify with a Chat message before touching anything else; if Chat works, the connection is correct and any remaining issue is mode-specific rather than configuration.

Model names are the first source of errors

A `model not found` response means the endpoint does not serve that name — not that your key is wrong. With cocodot both forms work: the official names (`claude-sonnet-5`, `claude-opus-5`) and the gateway codes (`mcs-6`, `mco-7`). The full list is published at cocodot.co/pricing#models, and the machine-readable version is `GET https://cocodot.co/api/ai/models` if you would rather copy from JSON than a page.

The modes behave differently — expect that

Chat works fully through a custom endpoint. Tab completion uses Cursor's own models regardless of your setting, so do not expect your endpoint to change it. Agent and Composer lean on tool-calling behaviour and are sensitive to how faithfully a model implements it; test them separately after Chat is confirmed. Knowing this in advance saves you from concluding the whole setup is broken when only one mode is.

A cost split that actually holds up

Use a mid-tier model as the default for reading code and making scoped edits, and switch to a frontier model only for genuinely hard problems. On published rates that is roughly a fifth of the cost for the majority of your calls, and in day-to-day coding the difference is much smaller than the price gap suggests. Since both run on the same key and balance here, switching is a dropdown rather than a migration.

Verifying before you rely on it

1. Send a Chat message and confirm a reply. 2. Check the call appears in your provider's billing detail — that confirms the request actually routed through your endpoint rather than falling back. 3. Try Agent on a small task. 4. Confirm your balance moves by the amount you expect. If step 2 shows nothing, Cursor is not using your endpoint, and the base URL is the first thing to re-read.

Cursor has two different key slots — do not mix them

Cursor separates the OpenAI key field (with the overridable base URL) from the Anthropic key field. If you want to use a Claude model through an OpenAI-compatible gateway, the key goes into the OpenAI slot together with the gateway's base URL, and you select the model by the name the gateway serves. Pasting a gateway key into the Anthropic slot sends it to Anthropic's own address, where it fails with an authentication error that looks like a bad key but is really a wrong destination. Which slot is which can shift between Cursor versions, so if a screen does not match this page, check Cursor's current docs for the field names.

Where the request actually comes from

Per Cursor's documentation at the time of writing, requests made with a custom key are sent from Cursor's servers, not directly from your machine. Two consequences follow. An endpoint running only on your own laptop (localhost) will not be reachable, so a public HTTPS endpoint is required. And the provider sees Cursor's server address rather than yours, so an IP allowlist on your key will block everything. If a request never shows up in your provider's billing detail, this is a likely reason; verify against the current docs, since architecture like this can change.

Reading the errors

401 or 'invalid API key' — the key is wrong, expired, or in the wrong slot. 404 or 'not found' on the URL — the base URL is missing `/v1` or has an extra path segment. 'Model not found' or 400 — the endpoint does not serve that model name; copy the exact string from the provider's model list rather than typing it from memory. 402 or 'insufficient balance' — the key is valid but has no credit, and retrying will not help. 429 — you hit a rate limit and should back off; see our guide to 429 errors for the three limit types. A timeout on Agent only — usually a long tool-calling turn, not a connection fault. Match the message to this list before changing any setting.

What custom keys do and do not replace

A custom endpoint changes where Chat-style requests go. It does not replace features Cursor implements on its own infrastructure, and which features fall in which group depends on your Cursor version and plan. The honest test is empirical: enable the custom key, then run one request in each mode you rely on and compare what appears in the provider's billing detail. If a mode does not appear there, Cursor handled it itself. Doing this once takes five minutes and prevents weeks of assuming a feature runs on your key when it does not.

What to put where

FieldValueCommon mistake
API keyYour key from the provider consoleUsing an expired or zero-balance key
Base URLhttps://cocodot.co/api/ai/v1Omitting the trailing /v1
Model nameclaude-sonnet-5, or the gateway code mcs-6A name the endpoint does not serve
Verify stepRun Cursor's key check, then send one Chat messageTreating a green check as proof — only a real reply is proof

FAQ

Do I still need a Cursor subscription?

For Chat through your own endpoint, no. Tab completion runs on Cursor's own models, so if that feature is why you use Cursor, weigh it separately.

Why does Chat work but Agent fails?

Agent depends on tool-calling behaviour that varies by model. Try a different model before assuming the endpoint is at fault — Chat succeeding already proved the connection is fine.

How do I add a Claude API key to Cursor?

There are two routes. With Anthropic's own key, use the Anthropic key field. With an OpenAI-compatible gateway, put the gateway key in the OpenAI field, set the base URL to the gateway's `/v1` address, and choose the Claude model by the gateway's model name. Verify with one Chat message before anything else.

Why is my Cursor custom API key not working?

Check in this order: the key is in the correct slot; the base URL ends in `/v1`; the model name is spelled exactly as the endpoint serves it; the key has balance. If all four are right and Chat works but Agent does not, the connection is fine and the issue is mode-specific.

Can I use a Claude Code API key in Cursor?

A key is a key: if it belongs to an endpoint that speaks the protocol Cursor calls, it works in the matching slot. The subscription login used by Claude Code is a different credential and does not transfer. Use an API key, not a login.

About cocodot

cocodot is a payment and AI access service for developers and cross-border teams in mainland China. It provides US-BIN virtual cards issued by a licensed institution — used to pay for overseas subscriptions and ad accounts — and an OpenAI-compatible AI API gateway for calling Claude, GPT and Gemini from within mainland China. Both share one wallet, funded by Alipay and accounted in USD. Card: $9.9 to open, 3% to load, $1 per active card per month; spending: $0.60 settlement fee on purchases under $20; a corresponding fee applies when the issuer charges one.

Service scope, pricing and limits →
Use a Claude API Key in Cursor: Setup and Errors · cocodot