Bug: Incorrect "Unauthorized OpenAI API key" error when using a personal Gemini API key
NOTE: We will try our best to check Github Issues, but forum.cursor.com is our main site for bug reports / user feedback. We'd recommend you post there for the fastest response.
Description
When attempting to use a Gemini model (e.g., gemini-2.5-pro) with a personal Google API key, the editor incorrectly throws an "Unauthorized User Openai API key" error. This indicates that the request is being mistakenly routed to an OpenAI authentication endpoint instead of the Google/Gemini endpoint.
Steps to Reproduce
- Navigate to
Settings>API Keysin Cursor. - Enter a valid Google API key in the "Google API Key" field and ensure the toggle to use it is enabled.
- Ensure the "OpenAI API Key" field is empty.
- In a chat pane, select a Gemini model from the dropdown, such as
gemini-2.5-pro. - Try to send any prompt to the model.
- Observe the error message that appears.
Expected Behavior
The request should be successfully sent to the Gemini API using the provided Google API key, and a valid response from the model should be received.
Actual Behavior
An error message is immediately displayed: Unauthorized User Openai API key. The request fails and is not processed.
Example Request ID: 5f03da8d-3d0b-421d-aab4-c2da46826fd8
Screenshots
(Please see the attached screenshots showing my API key configuration, the selected Gemini model, and the resulting error message.)
Environment
- Cursor Version: 1.2.2
- Operating System: Windows
i have the same problem
I'm facing a similar issue on my side. I'm using my own Anthropic API key (Claude models). However, the Cursor editor incorrectly shows an error related to Google API key verification, even though I never configured or even generated any Google API key.
It seems that the request is being mistakenly routed or validated against Google’s endpoints, despite using Anthropic models exclusively.
This issue is currently blocking me from using Claude models with Cursor.
Request ID: 34b8e7ae-945e-4178-81bb-5eeff4ece676
Same problem with Anthropic keys, Google keys and any other key
any updates on this?
Same problem here, I cant use antrophic key anymore. It worked fine before a few weeks, what happened?
Unauthorized User API key (Request ID: c81009bf-263f-4e0c-8e24-7ee9f1b8becb)
I realized I had accidentally turned on this setting. Turning it off helped, so check your switches carefully
Hey guys,
Make sure you turn off all custom API providers except the one you want to use. For example, if I want to use Claude, I need to ensure that only it is turned on.
Hey guys, Make sure you turn off all custom API providers except the one you want to use. For example, if I want to use Claude, I need to ensure that only it is turned on.
it worked for me!! many thx
Is there any update on this? Cursor won't let me use custom OpenAI providers
The Problem
I tried connecting my own OpenAI API provider to Cursor instead of using the default. Here's what I did:
- Added my OpenAI API key
- Overrode the base URL to point to my custom provider
- Attempted to use a GPT model
What happened? Cursor rejected the request with an "Unauthorized User OpenAI API key" error, even though my credentials are valid.
ERROR_BAD_USER_API_KEY
Bad User API key: Unauthorized User OpenAI API key
[unauthenticated] Error
The Frustration
I don't understand why I can't use an alternative provider instead of being locked to OpenAI's official service. My API key works fine with other tools and direct OpenAI API calls.
It feels like Cursor is specifically blocking non-official OpenAI endpoints at the provider level, even when you're technically pointing to a valid OpenAI-compatible API.
Questions
- Is this a deliberate restriction or a bug?
- Does Cursor validate the API endpoint somehow and reject non-official ones?
- Is there a workaround I'm missing?
If this is by design, I'd love to understand the reasoning. If it's a limitation, hopefully it's something the Cursor team can address in future updates.
Still having the same issue when using an Anthropic API key. Seems like requests are being sent to OpenAI for some reason.
Any update? when i turn off open api url it works and then my next request to the llm resets the url toggle and turns it back on
