[GH-ISSUE #907] [BUG]: Gemini Bad Request Error #541

Closed
opened 2026-02-22 18:20:05 -05:00 by yindo · 6 comments
Owner

Originally created by @wirelessed on GitHub (Mar 14, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/907

How are you running AnythingLLM?

AnythingLLM desktop app

What happened?

Hi, I uploaded some files and tried to query my files using the gemini-pro chat model, and got this error:

Could not respond to message.

[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1/models/gemini-pro:streamGenerateContent?alt=sse: [400 Bad Request] Please ensure that multiturn requests ends with a user role or a function response.

Are there known steps to reproduce?

No response

Originally created by @wirelessed on GitHub (Mar 14, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/907 ### How are you running AnythingLLM? AnythingLLM desktop app ### What happened? Hi, I uploaded some files and tried to query my files using the gemini-pro chat model, and got this error: > Could not respond to message. > > [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1/models/gemini-pro:streamGenerateContent?alt=sse: [400 Bad Request] Please ensure that multiturn requests ends with a user role or a function response. ### Are there known steps to reproduce? _No response_
yindo added the possible bug label 2026-02-22 18:20:05 -05:00
yindo closed this issue 2026-02-22 18:20:05 -05:00
Author
Owner

@PierrunoYT commented on GitHub (Mar 14, 2024):

I get something similar here
grafik

@PierrunoYT commented on GitHub (Mar 14, 2024): I get something similar here ![grafik](https://github.com/Mintplex-Labs/anything-llm/assets/95778421/2706085c-d7f6-48ab-a0a5-cdf5bbde2078)
Author
Owner

@PierrunoYT commented on GitHub (Mar 14, 2024):

I get something similar here grafik

With Claude 3

@PierrunoYT commented on GitHub (Mar 14, 2024): > I get something similar here ![grafik](https://private-user-images.githubusercontent.com/95778421/312899282-2706085c-d7f6-48ab-a0a5-cdf5bbde2078.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTA0MzA0MDcsIm5iZiI6MTcxMDQzMDEwNywicGF0aCI6Ii85NTc3ODQyMS8zMTI4OTkyODItMjcwNjA4NWMtZDdmNi00OGFiLWEwYTUtY2RmNWJiZGUyMDc4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzE0VDE1MjgyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJiOTM0ZjRjNDRiZjBhNzUxMjk5OWJhMjQ4ZDQ5YTU2ZGE2YTFkYTJjOTM5YTcwOTI1OGFjOThkNGZjMGQwZjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.x7ny4RqJcsVzlOjdi3cEsj1nKttT02X9hauQrSkYbHI) With Claude 3
Author
Owner

@timothycarambat commented on GitHub (Mar 14, 2024):

Sounds like it is not the LLM and is an issue with the document perhaps? Just tried with Gemini and had no issue.

Are you able to send a chat in a totally empty workspace or does that fail as well

@timothycarambat commented on GitHub (Mar 14, 2024): Sounds like it is not the LLM and is an issue with the document perhaps? Just tried with Gemini and had no issue. Are you able to send a chat in a totally empty workspace or does that fail as well
Author
Owner

@wirelessed commented on GitHub (Mar 14, 2024):

Hi, I don't think it's an issue with the documents, cos I managed to switch to Claude's API and it seems to work.

@wirelessed commented on GitHub (Mar 14, 2024): Hi, I don't think it's an issue with the documents, cos I managed to switch to Claude's API and it seems to work.
Author
Owner

@bookfun commented on GitHub (Mar 26, 2024):

Because anythingllm still use gemini 1.0,but the api key you get is 1.5

@bookfun commented on GitHub (Mar 26, 2024): Because anythingllm still use gemini 1.0,but the api key you get is 1.5
Author
Owner

@timothycarambat commented on GitHub (Mar 26, 2024):

Found the root cause. You are sending message which are being blocked by Google for Safety reasons. This is not handled in the code and will patch
https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-attributes#gemini-TASK-samples-nodejs

@timothycarambat commented on GitHub (Mar 26, 2024): Found the root cause. You are sending message which are being blocked by Google for Safety reasons. This is not handled in the code and will patch https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-attributes#gemini-TASK-samples-nodejs
yindo changed title from [BUG]: Gemini Bad Request Error to [GH-ISSUE #907] [BUG]: Gemini Bad Request Error 2026-06-05 14:35:53 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#541