Image upload fails with error code [13] - text-only works fine #126

Closed
opened 2026-02-13 17:27:53 -06:00 by mirrors · 2 comments
Owner

Originally created by @holzhaker1 on GitHub (Dec 17, 2025).

Test Code

from gemini_webapi import GeminiClient
from pathlib import Path

async def test():
client = GeminiClient(secure_1psid, secure_1psidts)
await client.init()

# This works:
response = await client.generate_content("Hello!", model="gemini-3.0-pro")
print(response.text)  # ✅ Success

# This fails:
response = await client.generate_content(
    "Describe this image",
    files=[Path("test_image.png")]
)  # ❌ APIError: Invalid response data received

Test Results

I created a test script to isolate the issue:

Test Model Files Result
Text-only gemini-3.0-pro None SUCCESS
Image unspecified (default) 1 PNG file FAILED
Image gemini-2.5-flash 1 PNG file FAILED
Image gemini-3.0-pro 1 PNG file FAILED

Error Logs

2025-12-18 00:32:16.053 | DEBUG | gemini_webapi.utils.parsing:get_nested_value:32 - Safe navigation: path [0, 5, 2, 0, 1, 0] ended at index 2 (key '2'), returning default. Context: [13]
2025-12-18 00:32:16.053 | DEBUG | gemini_webapi.client:generate_content:406 - Invalid response: )]}'
"wrb.fr",null,null,null,null,[13,["di",382],["af.httprm",381,"-5881216359610352895",17]]

Additional Context

File upload to Google's servers appears to succeed (no error from
upload_file
)
The error occurs when the API processes the request with the uploaded file
Cookies are valid (text-only requests work)
Tried multiple models - all fail with images

Originally created by @holzhaker1 on GitHub (Dec 17, 2025). ## Test Code from gemini_webapi import GeminiClient from pathlib import Path async def test(): client = GeminiClient(secure_1psid, secure_1psidts) await client.init() # This works: response = await client.generate_content("Hello!", model="gemini-3.0-pro") print(response.text) # ✅ Success # This fails: response = await client.generate_content( "Describe this image", files=[Path("test_image.png")] ) # ❌ APIError: Invalid response data received ## Test Results I created a test script to isolate the issue: | Test | Model | Files | Result | |------|-------|-------|--------| | Text-only | gemini-3.0-pro | None | ✅ SUCCESS | | Image | unspecified (default) | 1 PNG file | ❌ FAILED | | Image | gemini-2.5-flash | 1 PNG file | ❌ FAILED | | Image | gemini-3.0-pro | 1 PNG file | ❌ FAILED | ## Error Logs 2025-12-18 00:32:16.053 | DEBUG | gemini_webapi.utils.parsing:get_nested_value:32 - Safe navigation: path [0, 5, 2, 0, 1, 0] ended at index 2 (key '2'), returning default. Context: [13] 2025-12-18 00:32:16.053 | DEBUG | gemini_webapi.client:generate_content:406 - Invalid response: )]}' [["wrb.fr",null,null,null,null,[13]],["di",382],["af.httprm",381,"-5881216359610352895",17]] ## Additional Context File upload to Google's servers appears to succeed (no error from upload_file ) The error occurs when the API processes the request with the uploaded file Cookies are valid (text-only requests work) Tried multiple models - all fail with images
mirrors 2026-02-13 17:27:53 -06:00
Author
Owner

@luuquangvu commented on GitHub (Dec 18, 2025):

This could be related to error #198. You could try checking out that PR to see if it works for you.

@luuquangvu commented on GitHub (Dec 18, 2025): This could be related to error #198. You could try checking out that PR to see if it works for you.
Author
Owner

@holzhaker1 commented on GitHub (Dec 18, 2025):

This could be related to error #198. You could try checking out that PR to see if it works for you.

This did not fix it for me. I tried nearly everything, rotating models etc, switching file types, it simply wont work when adding a file

@holzhaker1 commented on GitHub (Dec 18, 2025): > This could be related to error #198. You could try checking out that PR to see if it works for you. This did not fix it for me. I tried nearly everything, rotating models etc, switching file types, it simply wont work when adding a file
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mirrors/Gemini-API#126
No description provided.