I’m receiving an “Unauthorized User API key” error even though I’m sure my key is valid. Is this related to subscription status? Does using a custom key require a Pro subscription?
I’m a free user now.
Hey, this error might occur if you have a custom base URL set for the OpenAI model. Try resetting to default, that should work.
It’s worked, thanks. Amazing Cursor .
I don’t have a OpenAI Base URL and have been getting the same Unauthorized User API key now for weeks (still on 0.48.8). My key is valid as confirmed with the curl command.
Hey, which provider are you trying to use?
Hi. Google/Gemini.
That’s strange. Can you try clicking the “Reset to default” button, then “Save” for the base URL, and reload Cursor?
Did you get this solved? What solution worked for you?
Same issue for me. Worked yesterday with no problems:
Tried refreshing the seemingly unrelated OpenAI URL as in your previous response to the OP and this didn’t help.
Same here.
Hey, it seems that this specific model doesn’t work with the API key. Another model, gemini-2.5-pro-exp, still works with the API key. I’ll try to find out.
I tested my Gemini API key and the model using the following code:
import google.generativeai as genai
import os
from google.api_core import exceptions
API_KEY = "MY_API_KEY"
genai.configure(api_key=API_KEY)
model_name = "gemini-2.5-flash-preview-04-17"
try:
# Check if the model exists and is accessible
model = genai.get_model(model_name)
print(f"Successfully accessed model info for: {model.name}")
# Try generating content
print(f"Attempting to generate content using {model_name}...")
model = genai.GenerativeModel(model_name)
response = model.generate_content("Tell me a short story.")
# Print the response if successful
print("\n--- API Response ---")
print(response.text)
print("--------------------")
except exceptions.PermissionDenied as e:
print(f"\n--- Error: Permission Denied ---")
print(f"Your API key is not authorized for model '{model_name}'.")
print(f"Details: {e}")
print("This indicates an issue with your API key's access on Google's side.")
except exceptions.ResourceExhausted as e:
print(f"\n--- Error: Resource Exhausted ---")
print(f"You have exceeded your quota or rate limits for model '{model_name}'.")
print(f"Details: {e}")
print("This indicates a quota/limit issue on Google's side.")
except exceptions.NotFound as e:
print(f"\n--- Error: Model Not Found ---")
print(f"The model '{model_name}' was not found or is not available to your key.")
print(f"Details: {e}")
print("This indicates the model name is wrong or it's not available to your key.")
except Exception as e:
print(f"\n--- An unexpected error occurred ---")
print(f"Error type: {type(e).__name__}")
print(f"Details: {e}")
print("This might be an API issue or another problem.")
The response came back without error.
I can confirm also that other Gemini models, such as “gemini-2.5-pro-exp” works fine with Cursor under my API.