Guide

Use Claude in Cursor with an API key: how custom keys and endpoints work

Prices checked Nov 26, 2026 · 4 min read

Use Claude in Cursor with an API key: a code editor beside a brass key on a dark desk

To use Claude in Cursor with your own API key, open Cursor Settings, go to Models, paste an Anthropic key under its provider and click Save. For any OpenAI-compatible endpoint, you also turn on Override OpenAI Base URL and add the model name. Both routes cover chat only: Cursor's docs say Tab completion keeps using Cursor's built-in models.

Route 1: a provider key (documented by Cursor)

Cursor's API keys page lists five providers: OpenAI, Anthropic, Google, Azure OpenAI and AWS Bedrock. The steps:

  1. Open Cursor Settings, then Models.
  2. Find the provider, such as Anthropic, and paste your key in its field.
  3. Click Save. The models then appear in the model picker.

If the provider rejects the key, requests using it fail until you update or remove it. Three facts from the same page that matter:

  • Chat only. Custom API keys work only with chat models. Tab completion keeps using Cursor's built-in models.
  • Your key passes through Cursor. The page says your key is not stored on Cursor's servers, but is sent to its backend with every request, because all requests are routed through Cursor's servers for final prompt building. It is not persisted after the request completes.
  • Billing and data. On individual plans, using your own key does not count against included usage. On Teams and Enterprise plans, the Cursor Token Rate may still apply to eligible models. Cursor's Zero Data Retention policy does not apply to your own keys.

To get an Anthropic key and pay Anthropic directly, see Claude API free for the credits and tiers.

Route 2: an OpenAI-compatible endpoint

This is how gateways and resellers plug in. Cursor's own docs page does not describe the base URL setting, so the steps below come from OpenRouter's Cursor guide and a community post on Cursor's forum. Check them against your Cursor version.

  1. In Cursor Settings, go to Models and open the API Keys section.
  2. Turn on the OpenAI API Key toggle and paste the endpoint's key.
  3. Turn on Override OpenAI Base URL and enter the endpoint's base URL. Some gateways need a specific path: OpenRouter's guide says its URL must end in /cursor, not /api/v1. Read your provider's docs.
  4. Click Add model and type the model name exactly as the endpoint calls it. The forum post says a mismatched identifier is a common cause of errors.
  5. Pick the model in Chat or Agent.

Known limits from those sources:

  • The override is global. The forum post says it applies to OpenAI-family requests, even some Cursor-managed models, and you may need to switch it off to use Cursor's own models. Per-model base URLs were not supported when the post was written.
  • Tab is unaffected. Autocomplete always uses Cursor's own model.
  • Auto and Composer modes may not route through your key, per OpenRouter's guide.
  • Anthropic keys can conflict. One forum report says Anthropic BYOK works only while the override is off.
  • Test outside Cursor first. Send one request with curl to the endpoint before you debug Cursor.

Because requests pass through Cursor's servers, a URL that only your own computer can reach, such as localhost, is unlikely to work. Use a public endpoint.

Setting it up for TapModels

TapModels lists POST /v1/chat/completions as OpenAI-compatible, with base URL https://api.tapmodels.com/v1. We do not issue OpenAI or Anthropic keys: use a TapModels key, created in the dashboard, and only on our endpoint. Model ids use hyphens: claude-sonnet-5-5, claude-opus-5-5, claude-haiku-5-5.

Test the request outside Cursor first:

curl https://api.tapmodels.com/v1/chat/completions \
  -H "Authorization: Bearer $TAPMODELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Say hi."}], "max_tokens": 20}'

A reply means the key, URL and model name are right. Then enter https://api.tapmodels.com/v1 as the base URL, paste the key in the OpenAI field, and add claude-sonnet-5-5 as a custom model. We have not tested every Cursor version, and new accounts start at 0 credits, so add some first. An empty balance returns 402 insufficient_credits. Give the key a spend limit and an allowed models list when you create it, so a leak costs a known amount at most.

What it costs to code with Claude

Agents resend context on each turn, so editor sessions use many input tokens. Take a session with 300,000 input tokens and 40,000 output tokens on Claude Sonnet 5.5:

RouteRate (in / out per 1M)CalculationCost
Anthropic list price$2.00 / $10.000.3 x $2.00 + 0.04 x $10.00$1.00
TapModels catalog$0.80 / $4.000.3 x $0.80 + 0.04 x $4.00$0.40

Two caveats. First, Anthropic prices cache reads at a fraction of base input (0.05 times on Sonnet 5.5), and our contract states no cache rate, so a heavily cached editor session needs a test run before you trust the saving. The same trap is explained in making Claude Code cheaper. Second, a reseller sees your code. Read the provider checklist before you send private repositories.

Next step: see all Claude prices on the Sonnet pricing page.

Frequently asked questions

Can I use my own API key in Cursor?

Yes. Cursor's docs list OpenAI, Anthropic, Google, Azure OpenAI and AWS Bedrock. Open Cursor Settings, go to Models, paste the key under the provider and click Save. The docs say custom keys work only with chat models and that Tab completion keeps using Cursor's built-in models.

Does Cursor send my API key to its servers?

Yes, per its docs. Cursor says your key is not stored on its servers, but it is sent to its backend with every request because all requests are routed through Cursor's servers for final prompt building, and it is not persisted after the request completes. Its Zero Data Retention policy does not apply to your own keys.

How do I use a custom OpenAI-compatible endpoint in Cursor?

Turn on the OpenAI API Key toggle, paste the endpoint's key, turn on Override OpenAI Base URL and enter the endpoint, then add the model name your endpoint serves. This flow comes from third-party docs and Cursor forum posts, not Cursor's own docs page, so check it against your Cursor version.

Why does my custom model not appear or fail in Cursor?

Common causes from Cursor's forum: the model name does not match an identifier your endpoint supports exactly, the base URL path is wrong, or the global override is also catching Cursor's own models. Test the key, URL and model with a direct curl request first.

Is a TapModels key accepted in Cursor?

TapModels lists an OpenAI-compatible chat endpoint at api.tapmodels.com/v1, so it fits the override setup. We have not tested every Cursor version. We do not issue OpenAI or Anthropic keys, and our key works on our endpoint only. Test one short session before relying on it.

Sources