# Gemini API Randomly returning Invalid API Key

**URL:** <https://discuss.ai.google.dev/t/gemini-api-randomly-returning-invalid-api-key/128882>\
**Category:** Gemini API\
**Tags:** api-key, api, bug\
**Created:** [March 5, 2026, 11:21am UTC](https://discuss.ai.google.dev/t/gemini-api-randomly-returning-invalid-api-key/128882 "2026-03-05T11:21:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amusa\_Abdulahi\_tomis](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/amusa_abdulahi_tomis/32/32083_2.png) [@Amusa\_Abdulahi\_tomis](https://discuss.ai.google.dev/u/Amusa_Abdulahi_tomis)\
**Post date:** [March 5, 2026, 11:21am UTC](https://discuss.ai.google.dev/t/gemini-api-randomly-returning-invalid-api-key/128882/1 "2026-03-05T11:21:58Z")

</div>

Hello there,

Since I started using “gemini-3-flash-preview“, I have been randomly getting error saying “Invalid API Key“ and whenever I process the request again, I run successfully.

For example, I send about 10 requests to the API, at least, 2 of the requests will come back with invalid API key.

I am currently using the “google.genai“ python sdk.  
What could be the problem?

---

<div class="post-metadata">

**Author:** ![system](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/system/32/1_2.png) [@system](https://discuss.ai.google.dev/u/system)\
**Post date:** [November 5, 2026, 6:35pm UTC](https://discuss.ai.google.dev/t/gemini-api-randomly-returning-invalid-api-key/128882/2 "2026-11-05T18:35:57Z")

</div>

Closed on November 5, 2026, 6:35pm UTC

This thread was automatically closed 60 days after the last reply. If you are running into an issue, please create a new post.
