cursor icon indicating copy to clipboard operation
cursor copied to clipboard

Bug: Incorrect "Unauthorized OpenAI API key" error when using a personal Gemini API key

Open jorell-hub opened this issue 7 months ago • 11 comments

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

  1. Navigate to Settings > API Keys in Cursor.
  2. Enter a valid Google API key in the "Google API Key" field and ensure the toggle to use it is enabled.
  3. Ensure the "OpenAI API Key" field is empty.
  4. In a chat pane, select a Gemini model from the dropdown, such as gemini-2.5-pro.
  5. Try to send any prompt to the model.
  6. 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
Image

jorell-hub avatar Jul 19 '25 03:07 jorell-hub

i have the same problem

JosefHobler avatar Jul 19 '25 14:07 JosefHobler

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

Image

hitoshyamamoto avatar Jul 22 '25 02:07 hitoshyamamoto

Same problem with Anthropic keys, Google keys and any other key

david-becks avatar Aug 15 '25 16:08 david-becks

any updates on this?

hendrikschafer avatar Aug 20 '25 19:08 hendrikschafer

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)

gedsmit avatar Aug 30 '25 20:08 gedsmit

Image

I realized I had accidentally turned on this setting. Turning it off helped, so check your switches carefully

gedsmit avatar Aug 30 '25 20:08 gedsmit

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. Image

raselmahmud-coder avatar Sep 09 '25 09:09 raselmahmud-coder

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. Image

it worked for me!! many thx

GeunCheolOh avatar Sep 24 '25 08:09 GeunCheolOh

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:

  1. Added my OpenAI API key
  2. Overrode the base URL to point to my custom provider
  3. 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.

mehmetbaykar avatar Nov 06 '25 13:11 mehmetbaykar

Still having the same issue when using an Anthropic API key. Seems like requests are being sent to OpenAI for some reason.

kevingil avatar Nov 10 '25 21:11 kevingil

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

Hkhan161 avatar Nov 13 '25 02:11 Hkhan161