Cursor Custom OpenAI Base URL: Setup, Models and Debug

Connect Cursor to an OpenAI-compatible API with https://keeprouter.com/v1, scope custom model IDs, isolate Verify errors, and reconcile coding task spend.

Published 2026-10-03 · Updated 2026-10-03 · KeepRouter Editorial · 5 minute read

Claude Code workload-routing worksheet grouped by task risk, context, and model acceptance checks
Measure the complete coding task, including context, retries and review. Illustration, not measured savings.

Configure Cursor to call KeepRouter by entering a scoped KeepRouter API key, turning on Override OpenAI Base URL with https://keeprouter.com/v1, and adding the exact model ID you intend to use. Start with one ordinary chat question before testing multi-file edits. Passing Cursor's Verify button only confirms basic connectivity on the model Cursor probes; it does not prove that every custom feature in the editor uses your custom endpoint.

Teams usually test a custom base URL in Cursor when they want prepaid API billing or a specific catalog model without switching editors. Keep that boundary clear from the beginning so subscription features and custom-key requests are not confused during troubleshooting.

Know what Override OpenAI Base URL controls

Cursor's API keys documentation explains how user-supplied OpenAI keys and base URL overrides apply, and its models documentation describes custom model entries and editor features. An OpenAI base URL override affects requests routed through Cursor's OpenAI API integration; proprietary editor features such as Cursor Tab autocomplete or hosted indexing have separate product requirements and do not automatically move to a custom gateway.

Cursor surfaceExpected path with custom OpenAI base URLFirst verification check
Chat on a custom modelUses the overridden OpenAI-compatible routeConfirm exact model ID and gateway request log
Inline or Composer editDepends on model capabilities and Cursor modeTest a single-file diff on a disposable branch
Verify buttonSends a probe request from Cursor's backendCheck whether Cursor's default probe model matches your key scope
Cursor Tab / proprietary toolsControlled by Cursor's own service rulesDo not assume custom API keys replace editor plans

Because Override OpenAI Base URL applies across OpenAI-routed models in that profile, disable built-in OpenAI model names that are not present on your KeepRouter key while testing. Leaving unrelated model names enabled makes it easy to trigger a model_not_allowed or model_not_found error during Verify.

Set up one explicit model and test outside the IDE first

Before clicking Verify inside Cursor, run one terminal request against https://keeprouter.com/v1/chat/completions using the same key and model ID. That separates gateway authentication from editor state.

curl https://keeprouter.com/v1/chat/completions \
  -H "Authorization: Bearer $KEEPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "free",
    "messages": [{"role": "user", "content": "Reply with ready."}],
    "max_tokens": 16
  }'

Once that returns HTTP 200, open Cursor Settings > Models and apply the same values:

  1. Add the exact catalog ID from the KeepRouter model catalog (for example free for a basic text check, or a paid coding model on a funded account with a matching key scope).
  2. Paste your KeepRouter API key into the OpenAI API Key field. Keep the key private and out of repository files such as .cursorrules.
  3. Enable Override OpenAI Base URL, enter https://keeprouter.com/v1 without a trailing /chat/completions, and save before clicking Verify.

Note also how Cursor routes requests: the API keys documentation notes that custom-key requests can still pass through Cursor's backend to assemble prompts. Treat repository code sent through the editor according to both your gateway policy and Cursor's documented data handling.

Why Verify fails when curl succeeds

Symptom in CursorLikely causeFix
401 UnauthorizedKey pasted into Anthropic/Google field or unsaved overridePaste into OpenAI API Key, save base URL first, re-test
404 Not FoundBase URL includes /chat/completions or extra suffixSet base URL to https://keeprouter.com/v1
Model not allowed on VerifyKey is scoped to one model while Cursor probes another enabled modelAdd and select the permitted model, or use an unrestricted test key with a small balance
Chat replies work, multi-file agent stallsSelected route uses Responses-only tools or lacks Chat tool supportCheck endpoint contract with the API migration checker
Unexpected spend during a short sessionLarge attached file context and repeated repair turnsInspect per-request prompt tokens in the KeepRouter console

Pay close attention to protocol boundaries on newer coding models. If a catalog model requires POST /v1/responses for function calling rather than POST /v1/chat/completions, a Chat Completions client can receive plain text replies yet fail when invoking tools. For terminal workflows built natively around Responses, compare the OpenAI Codex CLI custom provider guide or test native extension workflows in the Cline setup guide.

Validate a bounded repository patch

Do not judge coding quality from free connectivity checks. Switch to your target paid model, open a clean Git branch on a small test module, and run a reproducible three-step check:

1. Read src/slug.ts and tests/slug.test.ts without editing files.
2. State how consecutive hyphens are currently handled.
3. Collapse consecutive hyphens into a single hyphen and add one unit test.
Do not modify package.json or unrelated files.

Verify the resulting git diff and run your local test suite directly. Record total billed tokens across the entire task, including follow-up turns, and compare candidates with the API cost calculator and quickstart before rolling the configuration out to a team.

Frequently asked questions

What base URL should I enter in Cursor for KeepRouter?

Enter https://keeprouter.com/v1 under Override OpenAI Base URL. Do not append /chat/completions; Cursor adds the operation path.

Does a custom OpenAI key replace Cursor Tab autocomplete?

No. Cursor's proprietary editor features such as Cursor Tab follow Cursor's own plan rules; the override applies to OpenAI-routed model requests.

Why does Verify fail when my key is scoped to one model?

Cursor's verification probe may request a default OpenAI model ID that is outside a single-model key's allowlist. Disable unused built-in OpenAI models and test with the exact permitted model ID.

Sources reviewed

Article last reviewed 2026-10-03

  1. [1] Cursor API keys and custom base URL documentation
  2. [2] Cursor models documentation

Related guides

← All posts · Models & pricing · Get an API key

Featured on Twelve Tools