Use Claude in Cursor with a Custom API Key & Base URL

Cursor is a fantastic AI-first editor, and its best feature for power users is quietly tucked into settings: you can use Claude in Cursor — or GPT-5, or any model you like — through a custom API key and a custom base URL. Instead of being tied to Cursor's built-in provider, you point the editor at your own OpenAI-compatible endpoint and drive it with your own key. This guide walks the exact Cursor Settings flow, screen by screen, so you can add ApiTopMix as a custom provider and run Cursor on Claude and GPT models with full cost control.

Why bother with Cursor BYOK (bring your own key)? Two reasons. First, cost control: you pay per token on your own account instead of being metered by a bundled plan. Second, model choice: one key gives you the whole Claude family plus GPT-5 and other models, and you switch between them from Cursor's model picker without touching any config. ApiTopMix provides an OpenAI-compatible gateway at https://apitopmix.com/v1, which is exactly the shape Cursor expects when you enable Override OpenAI Base URL.

TL;DR: In Cursor go to Settings → Models, enable the OpenAI API Key section, turn on Override OpenAI Base URL and set it to https://apitopmix.com/v1, paste your ApiTopMix sk- key, then add a custom model such as claude-sonnet-4-6 or gpt-5 and verify. Using the Claude Code CLI instead? See our Claude Code guide.

Prerequisites

Before you open Cursor's settings, make sure you have:

That is the whole shopping list. No local proxy, no config files to edit — everything happens inside Cursor's Settings UI plus one paste of your key.

Step 0: Get your ApiTopMix API key

  1. Create an account at apitopmix.com (email signup works).
  2. Open the console, go to Tokens, and click Create new token.
  3. Copy the key — it starts with sk-. You will paste it into Cursor's OpenAI API key field in a moment.

Keep that single sk- key handy; it is the only credential you need for the rest of this Cursor custom API setup.

Step-by-step: add ApiTopMix as a custom provider in Cursor

This is the core of the guide — the exact Cursor custom API key flow, described as if you were looking at the screen. Cursor's wording shifts slightly between versions, but the shape is always the same: a Models panel with an OpenAI section, a Base URL override, an API key field, and a custom model list.

  1. Open Cursor Settings. Click the gear icon in the top-right, or press Cmd/Ctrl + Shift + J. The full settings window opens.
  2. Go to the Models tab. In the left sidebar of settings, select Models. This is where every provider and model lives.
  3. Find the OpenAI API Key section. Scroll to the OpenAI API Key block. This is the section Cursor uses for any OpenAI-compatible provider — including a custom one like ApiTopMix.
  4. Enable Override OpenAI Base URL. Turn on the Override OpenAI Base URL toggle and enter exactly https://apitopmix.com/v1. The /v1 suffix matters — that is where the OpenAI-compatible endpoint lives. No trailing slash.
  5. Paste your API key. In the OpenAI API key field, paste your ApiTopMix sk- key. Cursor treats this key as the credential for the overridden Base URL, so it goes to ApiTopMix, not to OpenAI.
  6. Add a custom model. In the custom models area, click Add model and type an exact ApiTopMix model ID, for example claude-sonnet-4-6. Add claude-opus-4-6 and gpt-5 too if you want to switch between them. Cursor sends this string verbatim as the model field, so it must match a real ID.
  7. Verify. Click Verify (or the equivalent confirm button). Cursor fires a small test request at your Base URL to confirm the key works. A success state means you are wired up.
  8. Select your model. Open any chat in Cursor and pick your custom claude-sonnet-4-6 (or gpt-5) from the model dropdown. Chat and inline edits now route through ApiTopMix to the model you chose.

Here is the whole configuration as a copy-paste reference — plug these three values into the matching fields in Cursor's Models settings:

# Cursor → Settings → Models → OpenAI API Key
Override OpenAI Base URL:  https://apitopmix.com/v1
OpenAI API Key:           sk-your-apitopmix-key
Custom model(s):          claude-sonnet-4-6   # and/or claude-opus-4-6, gpt-5
Heads up on verification: Cursor validates the key against the Base URL you entered by sending a real request. If you added only model names that ApiTopMix does not recognize, that check can fail even when the key is fine — so add at least one valid model ID (like claude-sonnet-4-6) before you verify.

Sanity-check the endpoint with curl

Before blaming Cursor for anything, confirm the key and Base URL work on their own. Fire a one-line request at the OpenAI-compatible endpoint — if this returns a normal chat completion, Cursor will too:

curl https://apitopmix.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your-apitopmix-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-4-6","messages":[{"role":"user","content":"Say hi from Cursor setup"}]}'

A valid JSON completion in the response proves three things at once: your sk- key is good, the https://apitopmix.com/v1 base URL is reachable, and the model ID you typed exists. That makes the Cursor-side troubleshooting below much faster, because you have already ruled out the key, the URL, and the model name.

Which models work well in Cursor

Once ApiTopMix is wired in, you can add several custom models and switch per task from Cursor's picker. A practical split:

ModelBest for in Cursor
claude-sonnet-4-6Everyday chat, refactors, writing functions and tests, quick multi-file edits. Fast and the best value — your default.
claude-opus-4-6Hard debugging, large architecture changes, dense reasoning over long context. Reach for it when Sonnet stalls.
gpt-5A strong alternative voice for planning, prose, and cross-checking Claude's output. Handy to keep in the picker.

Because all of these sit behind the same ApiTopMix key and the same Base URL, adding another model is just one more entry in Cursor's custom model list — no second provider, no second key. For current, per-model rates across the whole catalog, see the ApiTopMix pricing page, and the API documentation for exact model IDs and endpoint details. Trying to keep costs down specifically? Our cheap Claude API guide goes deeper on that.

Troubleshooting Cursor-specific errors

Custom providers in Cursor fail in a small number of predictable ways. This table maps each symptom to the fix:

SymptomLikely causeFix
Key won't verify / "invalid API key" Base URL wrong, key truncated, or no valid model added yet Set Base URL to exactly https://apitopmix.com/v1 (no trailing slash), re-paste the full sk- key, and add a real model ID before verifying. Confirm with the curl test.
"model not found" / model_not_found Custom model name doesn't match an ApiTopMix ID Cursor sends your exact string as the model. Use a valid ID like claude-sonnet-4-6 or gpt-5; check the list in the docs or the /v1/models endpoint.
Requests 404 or route to the wrong place Base URL missing the /v1, or an extra path/slash appended The value must end in /v1 and nothing more. https://apitopmix.com or .../v1/chat/completions in the Base URL field are both wrong.
Override seems ignored The OpenAI section isn't enabled, or a non-custom model is selected Enable the OpenAI API Key section, keep the override toggle on, and pick your custom model from the dropdown — not a built-in Cursor model.
Tab / Composer behaves differently Cursor-native features are tuned to its own backend Use your custom model for chat and inline edits; expect Tab autocomplete and parts of Composer/Agent to stay on Cursor's default model. This is a Cursor design choice, not an ApiTopMix limit.
401 / 403 on requests Key not applied to the overridden URL, or out of balance Re-paste the key in the OpenAI field so it binds to the custom Base URL, and check your ApiTopMix balance in the console.
A note on Tab and Composer: Cursor's Tab model and some Composer/Agent internals are built around Cursor's own infrastructure. Adding a custom provider changes what powers chat and edits, not necessarily every native feature. That is expected and honest — for those Cursor-specific features, the custom model may not apply. Everything you drive through the chat and inline-edit surfaces, however, runs on your ApiTopMix model.

Cursor vs the Claude Code CLI

This page is deliberately Cursor-specific. If you also live in the terminal, the Claude Code CLI is the other great way to use Claude with a custom endpoint — but it is configured completely differently (through ANTHROPIC_BASE_URL environment variables and the native Anthropic protocol, not an OpenAI Base URL override). The two complement each other: Cursor for the editor, Claude Code for the shell.

Same ApiTopMix key drives both, so you can set up one, the other, or both.

Frequently asked questions

How do I use Claude in Cursor with a custom API key?

Open Settings → Models, enable the OpenAI API Key section, turn on Override OpenAI Base URL and set it to https://apitopmix.com/v1, paste your ApiTopMix sk- key, then add a custom model like claude-sonnet-4-6 and verify. Cursor sends OpenAI-format requests to ApiTopMix, which routes them to Claude.

Where is the Override OpenAI Base URL setting in Cursor?

Under Settings → Models, inside the OpenAI API Key section. Expand it and you'll find the Override OpenAI Base URL toggle. Set it to https://apitopmix.com/v1 — the trailing /v1 is required.

Why does Cursor say my API key is invalid or fails to verify?

Cursor verifies by sending a test request to your Base URL. Check that the URL is exactly https://apitopmix.com/v1 with no trailing slash, that the sk- key was copied in full, and that you added at least one real ApiTopMix model. The curl test confirms the key and endpoint independently of Cursor.

Why do I get a "model not found" error in Cursor?

Your custom model name doesn't match an ApiTopMix model ID. Cursor sends the exact string you typed, so a typo or unavailable model returns model not found. Use a valid ID such as claude-sonnet-4-6 or gpt-5, matching the docs or the /v1/models list.

Can I use GPT-5 in Cursor through a custom API too?

Yes. The same key and Base URL work for GPT-5 and other families. Add gpt-5 as a custom model and select it from the picker. One key and one Base URL cover both Claude and GPT models.

Do Cursor Tab and Composer work with a custom provider?

Chat and inline edits work reliably. Some Cursor-native features like Tab autocomplete and parts of Composer/Agent are tuned to Cursor's own backend and may behave differently or fall back to a default model. Use your custom Claude or GPT model for chat and edits.

Do I still need a Cursor subscription?

A custom OpenAI-compatible key lets you run chat and edits on your own model and billing. Cursor still governs which of its features are available on which plan, so check Cursor's own terms. ApiTopMix only provides the model API — it doesn't change Cursor's plan rules.

Is ApiTopMix OpenAI-compatible so Cursor can use it?

Yes. ApiTopMix exposes an OpenAI-compatible endpoint at https://apitopmix.com/v1 (including /v1/chat/completions and /v1/models). That is exactly the shape Cursor expects when you override the OpenAI Base URL.

Run Cursor on your own Claude and GPT key

Grab a key, override one Base URL, add a model — and keep coding in Cursor with the model and billing you control.

Further reading

Conclusion

Using Claude in Cursor with your own API key comes down to one setting: Override OpenAI Base URL. Point it at https://apitopmix.com/v1, paste your ApiTopMix key, add a custom model like claude-sonnet-4-6 or gpt-5, and Cursor's chat and edits run on the model and billing you control. Keep the Base URL exact, add real model IDs, and lean on the curl sanity-check whenever verification acts up.

Set it up once and Cursor becomes a front-end for whatever ApiTopMix model fits the task — Sonnet for daily work, Opus for the hard problems, GPT-5 for a second opinion — all from one key. And when you move to the terminal, the same key powers the Claude Code CLI, so your editor and your shell stay in sync.