# API Error 400: API key not valid. Please pass a valid API key

**URL:** <https://discuss.ai.google.dev/t/api-error-400-api-key-not-valid-please-pass-a-valid-api-key/87862>\
**Category:** Gemini API\
**Tags:** gemini-flash, api-key\
**Created:** [June 9, 2025, 1:58am UTC](https://discuss.ai.google.dev/t/api-error-400-api-key-not-valid-please-pass-a-valid-api-key/87862 "2025-06-09T01:58:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FakeLag\_234](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/fakelag_234/32/54869_2.png) [@FakeLag\_234](https://discuss.ai.google.dev/u/FakeLag_234)\
**Post date:** [June 9, 2025, 1:58am UTC](https://discuss.ai.google.dev/t/api-error-400-api-key-not-valid-please-pass-a-valid-api-key/87862/1 "2025-06-09T01:58:27Z")

</div>

Greetings, I will not provide the code, the problem is DEFINITELY not in it. I haven’t changed anything in my code, but now I get an API error Error 400: API key not valid. Please pass a valid API key, although I did not change the API key in any way, I did not touch the code, I use gemini-2.0-flash, I definitely did not exceed the quota, the key of the free version. I tried different keys, but still the same error.

---

<div class="post-metadata">

**Author:** ![Sangeetha\_Jana](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/sangeetha_jana/32/48788_2.png) [@Sangeetha\_Jana](https://discuss.ai.google.dev/u/Sangeetha_Jana)\
**Post date:** [June 9, 2025, 9:13am UTC](https://discuss.ai.google.dev/t/api-error-400-api-key-not-valid-please-pass-a-valid-api-key/87862/3 "2025-06-09T09:13:25Z")

</div>

Hey @FakeLag_234  
Welcome to the community!  
Please ensure the API key is passed correctly. Recommend you to check for leading and trailing spaces.  
Also, recommend you to create a new API key and try.  
Feel free to reach out to us if you are still facing issue.  
Thank you!
