Skip to content

[Bug] [Gemini] Http Status: 500 ERROR:g4f.api:Response 429, but in a browser everything is OK #3302

@iG8R

Description

@iG8R

Before submitting
☑️ I checked Known Issues
☑️ I searched existing issues

Configuration
(Required)

  • Model: gemini-3-pro
  • Provider: Gemini
  • Interface:** API

Bug description
I'm trying to use Gemini via the g4f API, but every time get Http Request Error Http Status: 500
But it works just fine when I open gemini.google.com in a browser.
If I go to https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?bl=boq_assistant-bard-web-server_20240519.16_p0&hl=en&_reqid=4095&rt=c&f.sid=xxxxxxxxxxxxxxxxxxxxx everything is OK, no CAPTCHA is needed.

Environment

  • Python version: 3.13.5
  • OS: Microsoft Windows [Version 10.0.19045.2673]

Screenshots/Logs

Browser executable path: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Read cookies from firefox for .google.com
Gemini: Cookies refreshed. New __Secure-1PSIDTS: Set-Cookie: __Secure-1PSIDTS=sidts-xxxx; Domain=.google.com; expires=Sun, 20-Dec-2026 18:16:00 GMT; HttpOnly; Path=/; Secure
ERROR:g4f.api:Response 429: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?bl=boq_assistant-bard-web-server_20240519.16_p0&amp;hl=en&amp;_reqid=4095&amp;rt=c&amp;f.sid=xxxxxxxxxxxxxxxxxxxxx</title></head>
<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px; overscroll-behavior:contain;" onload="e=document.getElementById('captcha');if(e){e.focus();} if(solveSimpleChallenge) {solveSimpleChallenge(0,0);}">
<div style="max-width:400px;">
<hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>
<form id="captcha-form" action="index" method="post">
<noscript>
<div style="font-size:13px;">
  In order to continue, please enable javascript on your web browser.
</div>
</noscript>
<script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
<script>var submitCallback = function(response) {document.getElementById('captcha-form').submit();};</script>
<div id="recaptcha" class="g-recaptcha" data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" data-callback="submitCallback" data-s="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></div>

<input type='hidden' name='q' value='xxxxxxxxxxxxxxxxxxxxx'><input type="hidden" name="continue" value="https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?bl=boq_assistant-bard-web-server_20240519.16_p0&amp;hl=en&amp;_reqid=4095&amp;rt=c&amp;f.sid=xxxxxxxxxxxxxxxxxxxxx">
</form>
<hr noshade size="1" style="color:#ccc; background-color:#ccc;">

<div style="font-size:13px;">
<b>About this page</b><br><br>

Our systems have detected unusual traffic from your computer network.  This page checks to see if it&#39;s really you sending the requests, and not a robot.  <a href="#" onclick="document.getElementById('infoDiv').style.display='block';">Why did this happen?</a><br><br>

<div id="infoDiv" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">
This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop.  In the meantime, solving the above CAPTCHA will let you continue to use our services.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help &mdash; a different computer using the same IP address may be responsible.  <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may be asked to solve the CAPTCHA if you are using advanced terms that robots are known to use, or sending requests very quickly.
</div>
<br><div style="font-size:13px; line-break: anywhere;">
IP address: xxx.xxx.xxx.xxx<br>Time: 2025-12-20T18:16:01Z<br>URL: https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?bl=boq_assistant-bard-web-server_20240519.16_p0&amp;hl=en&amp;_reqid=4095&amp;rt=c&amp;f.sid=xxxxxxxxxxxxxxxxxxxxx<br>
</div>
</div>
</div>
</body>
</html>
Traceback (most recent call last):
  File "C:\gpt4free\venv\Lib\site-packages\g4f\api\__init__.py", line 522, in chat_completions
    return await response
           ^^^^^^^^^^^^^^
  File "C:\gpt4free\venv\Lib\site-packages\g4f\client\__init__.py", line 270, in async_iter_append_model_and_provider
    async for chunk in response:
    ...<4 lines>...
        yield chunk
  File "C:\gpt4free\venv\Lib\site-packages\g4f\client\__init__.py", line 185, in async_iter_response
    async for chunk in response:
    ...<42 lines>...
            break
  File "C:\gpt4free\venv\Lib\site-packages\g4f\tools\run_tools.py", line 243, in async_iter_run_tools
    async for chunk in response:
    ...<15 lines>...
        yield chunk
  File "C:\gpt4free\venv\Lib\site-packages\g4f\providers\asyncio.py", line 73, in to_async_iterator
    async for item in iterator:
        yield item
  File "C:\gpt4free\venv\Lib\site-packages\g4f\providers\base_provider.py", line 355, in async_create_function
    yield await asyncio.wait_for(
          ^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
    )
    ^
  File "C:\Python313\Lib\asyncio\tasks.py", line 507, in wait_for
    return await fut
           ^^^^^^^^^
  File "C:\gpt4free\venv\Lib\site-packages\g4f\Provider\needs_auth\Gemini.py", line 235, in create_async_generator
    await raise_for_status(response)
  File "C:\gpt4free\venv\Lib\site-packages\g4f\requests\raise_for_status.py", line 46, in raise_for_status_async
    raise RateLimitError(f"Response {response.status}: {message}")
g4f.errors.RateLimitError: Response 429: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?bl=boq_assistant-bard-web-server_20240519.16_p0&amp;hl=en&amp;_reqid=4095&amp;rt=c&amp;f.sid=xxxxxxxxxxxxxxxxxxxxx</title></head>
<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px; overscroll-behavior:contain;" onload="e=document.getElementById('captcha');if(e){e.focus();} if(solveSimpleChallenge) {solveSimpleChallenge(0,0);}">
<div style="max-width:400px;">
<hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>
<form id="captcha-form" action="index" method="post">
<noscript>
<div style="font-size:13px;">
  In order to continue, please enable javascript on your web browser.
</div>
</noscript>
<script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
<script>var submitCallback = function(response) {document.getElementById('captcha-form').submit();};</script>
<div id="recaptcha" class="g-recaptcha" data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxxxxxx" data-callback="submitCallback" data-s="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></div>

<input type='hidden' name='q' value='xxxxxxxxxxxxxxxxxxxxx'><input type="hidden" name="continue" value="https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?bl=boq_assistant-bard-web-server_20240519.16_p0&amp;hl=en&amp;_reqid=4095&amp;rt=c&amp;f.sid=xxxxxxxxxxxxxxxxxxxxx">
</form>
<hr noshade size="1" style="color:#ccc; background-color:#ccc;">

<div style="font-size:13px;">
<b>About this page</b><br><br>

Our systems have detected unusual traffic from your computer network.  This page checks to see if it&#39;s really you sending the requests, and not a robot.  <a href="#" onclick="document.getElementById('infoDiv').style.display='block';">Why did this happen?</a><br><br>

<div id="infoDiv" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">
This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop.  In the meantime, solving the above CAPTCHA will let you continue to use our services.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help &mdash; a different computer using the same IP address may be responsible.  <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may be asked to solve the CAPTCHA if you are using advanced terms that robots are known to use, or sending requests very quickly.
</div>
<br><div style="font-size:13px; line-break: anywhere;">
IP address: xxx.xxx.xxx.xxx<br>Time: 2025-12-20T18:16:01Z<br>URL: https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?bl=boq_assistant-bard-web-server_20240519.16_p0&amp;hl=en&amp;_reqid=4095&amp;rt=c&amp;f.sid=xxxxxxxxxxxxxxxxxxxxx<br>
</div>
</div>
</div>
</body>
</html>

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingstale

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions