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

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 surface | Expected path with custom OpenAI base URL | First verification check |
|---|---|---|
| Chat on a custom model | Uses the overridden OpenAI-compatible route | Confirm exact model ID and gateway request log |
| Inline or Composer edit | Depends on model capabilities and Cursor mode | Test a single-file diff on a disposable branch |
| Verify button | Sends a probe request from Cursor's backend | Check whether Cursor's default probe model matches your key scope |
| Cursor Tab / proprietary tools | Controlled by Cursor's own service rules | Do 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:
- Add the exact catalog ID from the KeepRouter model catalog (for example
freefor a basic text check, or a paid coding model on a funded account with a matching key scope). - Paste your KeepRouter API key into the OpenAI API Key field. Keep the key private and out of repository files such as
.cursorrules. - Enable Override OpenAI Base URL, enter
https://keeprouter.com/v1without 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 Cursor | Likely cause | Fix |
|---|---|---|
| 401 Unauthorized | Key pasted into Anthropic/Google field or unsaved override | Paste into OpenAI API Key, save base URL first, re-test |
| 404 Not Found | Base URL includes /chat/completions or extra suffix | Set base URL to https://keeprouter.com/v1 |
| Model not allowed on Verify | Key is scoped to one model while Cursor probes another enabled model | Add and select the permitted model, or use an unrestricted test key with a small balance |
| Chat replies work, multi-file agent stalls | Selected route uses Responses-only tools or lacks Chat tool support | Check endpoint contract with the API migration checker |
| Unexpected spend during a short session | Large attached file context and repeated repair turns | Inspect 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