possivel erro na api gemini ?
I also periodically encounter the error “Error from Gemini API: 400 Bad Request. {‘message’: None, ‘status’: ‘Bad Request’}”.
I’m using gemini-2.0-flash, but I initially thought the problem was on my end, possibly due to using a VPN. I noticed that the agent has a “retries” parameter. Should that help with these occasional errors?
(I also decided to try the Gemma models today, but every request returns a 400 error.)
Hi @Alex88
Thanks for reaching out and for using Agno! I’ve looped in the right engineers to help with your question. We usually respond within 24 hours, but if this is urgent, just let us know, and we’ll do our best to prioritize it.
Appreciate your patience—we’ll get back to you soon!
@Alex88 we made various Gemini updates on the latest version, 1.5.5. Could you check whether this is resolved for you?
Okay, I understand my mistake with Gemma. I was accidentally passing an empty system prompt through additional_context, and Gemma doesn’t support system instructions.
If I use agent.arun(message), it gives a clear error:
ERROR Error from Gemini API: 400 INVALID_ARGUMENT. {‘error’: {‘code’: 400, ‘message’: ‘Developer instruction is not enabled for models/gemma-3-27b-it’, ‘status’: ‘INVALID_ARGUMENT’}}
But if I use agent.arun(message, stream=True), the detailed description is missing:
ERROR Error from Gemini API: 400 Bad Request. {‘message’: None, ‘status’: ‘Bad Request’}
It’s possible that my rare problem with Gemini-2.0-flash would also be clearer, but I can’t disable streaming for the agent.
import asyncio
from agno.agent import Agent
from agno.models.google import Gemini
agent = Agent(
model=Gemini(id="gemma-3-27b-it"),
additional_context="",
debug_mode=True,
)
asyncio.run(agent.aprint_response("hello", stream=True))
#asyncio.run(agent.aprint_response("hello"))
I completely forgot about the “google-genai” update.
So basically, in both cases, the error now comes with all the details.
Ah thanks for that. I’ll give it a test.
But it looks like Gemma is simply not happy with the system message that is provided. On your agent do you have any fields activated that would create a system message? You can check by setting debug_mode=True
and it should show the generated system message. Perhaps you have markdown=True
?
I probably didn’t explain it well.
- The problem with Gemma was on my side and I found it. As I wrote above, in my code I passed an empty string through
additional_context
. - The problem with the error detail difference turned out to be in the unupdated
google-genai
package, not Agno.
So, everything is fine. Thanks.
Ah good to hear! Thanks for letting me know