# Getting "Unauthorized User API key" with Custom Gemini Key - Must I be a Pro User?

**URL:** <https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994>\
**Category:** Help\
**Created:** [April 2, 2025, 3:39am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994 "2025-04-02T03:39:50Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaofeidev](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/xiaofeidev/32/33386_2.png) [@xiaofeidev](https://forum.cursor.com/u/xiaofeidev)\
**Post date:** [April 2, 2025, 3:39am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/1 "2025-04-02T03:39:50Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/cursor1/original/3X/d/4/d4ad404148f76d47af64f148373d891fdcd35d7b.png)

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [April 2, 2025, 10:45am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/2 "2025-04-02T10:45:25Z")

</div>

Hey, this error might occur if you have a custom base URL set for the OpenAI model. Try resetting to default, that should work.

---

<div class="post-metadata">

**Author:** ![xiaofeidev](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/xiaofeidev/32/33386_2.png) [@xiaofeidev](https://forum.cursor.com/u/xiaofeidev)\
**Post date:** [April 2, 2025, 11:14am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/3 "2025-04-02T11:14:34Z")

</div>

It’s worked, thanks. Amazing Cursor 😁.

---

<div class="post-metadata">

**Author:** ![pequet](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@pequet](https://forum.cursor.com/u/pequet)\
**Post date:** [April 14, 2025, 6:29pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/4 "2025-04-14T18:29:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [April 14, 2025, 6:32pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/5 "2025-04-14T18:32:00Z")

</div>

Hey, which provider are you trying to use?

---

<div class="post-metadata">

**Author:** ![pequet](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@pequet](https://forum.cursor.com/u/pequet)\
**Post date:** [April 14, 2025, 6:36pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/6 "2025-04-14T18:36:11Z")

</div>

Hi. Google/Gemini.

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [April 14, 2025, 6:41pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/7 "2025-04-14T18:41:15Z")

</div>

That’s strange. Can you try clicking the “Reset to default” button, then “Save” for the base URL, and reload Cursor?

---

<div class="post-metadata">

**Author:** ![Ssss112358](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/ssss112358/32/48288_2.png) [@Ssss112358](https://forum.cursor.com/u/Ssss112358)\
**Post date:** [April 19, 2025, 7:10am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/8 "2025-04-19T07:10:19Z")

</div>

Did you get this solved? What solution worked for you?

---

<div class="post-metadata">

**Author:** ![Drickon](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/drickon/32/37900_2.png) [@Drickon](https://forum.cursor.com/u/Drickon)\
**Post date:** [April 20, 2025, 4:54am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/9 "2025-04-20T04:54:52Z")

</div>

Same issue for me. Worked yesterday with no problems:

 ![image](https://us1.discourse-cdn.com/cursor1/original/3X/9/c/9c416ea569b58514506758cd57c67bdbde0d82d0.png)

Tried refreshing the seemingly unrelated OpenAI URL as in your previous response to the OP and this didn’t help.

---

<div class="post-metadata">

**Author:** ![SpeedRanger](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/speedranger/32/44402_2.png) [@SpeedRanger](https://forum.cursor.com/u/SpeedRanger)\
**Post date:** [April 20, 2025, 8:40am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/10 "2025-04-20T08:40:39Z")

</div>

Same here.

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [April 20, 2025, 10:28am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/11 "2025-04-20T10:28:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Drickon](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/drickon/32/37900_2.png) [@Drickon](https://forum.cursor.com/u/Drickon)\
**Post date:** [April 21, 2025, 2:26am UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/12 "2025-04-21T02:26:34Z")

</div>

I tested my Gemini API key and the model using the following code:

```python
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.

---

<div class="post-metadata">

**Author:** ![thesoulpole](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/thesoulpole/32/56002_2.png) [@thesoulpole](https://forum.cursor.com/u/thesoulpole)\
**Post date:** [May 17, 2025, 7:46pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/13 "2025-05-17T19:46:59Z")

</div>

I have my own Gemini API key. The key works for sure, I have used it with RooCode a moment ago. In Cursor, when I input that key in settings, and click Verify, no message shows up (so to be specific- no ERROR message, but I suggest you could CONFIRM a succesful verifications!!). BUT - of the several Gemini models you have available for picking, only two work with the switch in setting set to green (“use my Gemini API key”). the 2 that work, in the picker list are shown as 1) Gemini 2.5 Flash preview 04-17 and 2) Gemini 2.5 Pro (in the flashcard that pops up its described as “preview -5-06”, IDENTICALLY as the flashcard for pro-exp-03-25)  
The other Gemini models do NOT WORK with my API key activated.  
WHY?!

---

<div class="post-metadata">

**Author:** ![thesoulpole](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/thesoulpole/32/56002_2.png) [@thesoulpole](https://forum.cursor.com/u/thesoulpole)\
**Post date:** [May 17, 2025, 7:54pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/14 "2025-05-17T19:54:36Z")

</div>

SECOND BIGGER problem - Azure key, which works in RooCode, here not only does not work. If I toggle in Cursor settings the “Azure API key” to green (i.e. activate) it blocks some of the models via Cursor. eg no model Claude 3.5, 3.7 (gemini works).  
I get this noinsense message ( I input the Azure key, not Anthropic):  
We encountered an issue when using your API key: Provider was unable to process your request  
API Error:  
Request failed with status code 400: {  
“error”: {  
“message”: “Unknown parameter: ‘system’.”,  
“type”: “invalid\_request\_error”,  
“param”: “system”,  
“code”: “unknown\_parameter”  
}  
}

---

<div class="post-metadata">

**Author:** ![FunnyRyan](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/funnyryan/32/36870_2.png) [@FunnyRyan](https://forum.cursor.com/u/FunnyRyan)\
**Post date:** [May 18, 2025, 4:23pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/15 "2025-05-18T16:23:15Z")

</div>

After testing, I clearly stated that it’s because cursor doesn’t want it’s users to use custom Google API Keys because it wants you to use it’s paid service, not just use it for free ~~haha, that’s a bad idea~~ I’m a bit disappointed with it

---

<div class="post-metadata">

**Author:** ![lifeinchords](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/lifeinchords/32/34549_2.png) [@lifeinchords](https://forum.cursor.com/u/lifeinchords)\
**Post date:** [July 16, 2025, 7:50pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/16 "2025-07-16T19:50:32Z")

</div>

Shady ■■■■ all around

---

<div class="post-metadata">

**Author:** ![strazto](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@strazto](https://forum.cursor.com/u/strazto)\
**Post date:** [March 3, 2026, 11:20pm UTC](https://forum.cursor.com/t/getting-unauthorized-user-api-key-with-custom-gemini-key-must-i-be-a-pro-user/73994/17 "2026-03-03T23:20:15Z")

</div>

FYI - having the “override openAI base URL” toggled ON will still break your Google API key even though you might assume they’re unrelated
