Troubleshooting · Cursor
Cursor Invalid API Key With a Custom Base URL — Why Verify Fails
Cursor rejects an API key on verify when the key and the base URL do not belong together, or the override field still points at the default OpenAI endpoint. The checklist that fixes it.
What you see
Invalid API keyWhy it happens
- The key belongs to a custom endpoint but "Override OpenAI Base URL" is off or empty, so Cursor verifies the key against the default api.openai.com — which has never seen it.
- The base URL is set but the key was pasted with whitespace, a missing prefix, or is a different provider's key format entirely.
- The key was revoked or has expired.
- The override URL is missing /v1 or carries an extra path segment, so the verification request goes to a URL the endpoint does not serve.
How to fix it
- Enable the OpenAI base URL override and set it to https://router.apitoken.sale/v1 before pasting the key — verification runs against whatever URL is active at that moment.
- Paste the key with no surrounding whitespace and check the prefix matches what your dashboard shows.
- Confirm the key is active in the dashboard of its issuer, then re-verify in Cursor.
Cursor settings that verify against this gateway
Cursor Settings → Models → OpenAI API Key
API Key: sk-pool-•••
Override OpenAI Base URL: https://router.apitoken.sale/v1
Model: gpt-6.1-terraRelated searches
cursor openai api key not workingcursor verify api key failed
FAQ
Why does Cursor say my key is invalid when it works in curl?+
Cursor verifies against the base URL configured at that moment. If the override is off, verification hits api.openai.com, which rejects a gateway key. Set the override first, then verify.
Do I need an OpenAI account to use GPT models in Cursor with a custom key?+
No. The OpenAI provider fields accept any OpenAI-compatible endpoint: set the override URL to the issuer and paste that issuer's key.
Which models work after the key verifies?+
The GPT and Gemini models the endpoint behind the override serves. List them with GET /v1/models against the same base URL and key, and add the id as a custom model.