Model Gemini 2.5 Pro get error when call via API

My code worked fine yesterday but now It got error with model “gemini-2.5-pro”, switch to “gemini-2.5-flash” work fine.

INFO:google_genai.models:AFC is enabled with max remote calls: 10.

INFO:httpx:HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent “HTTP/1.1 500 Internal Server Error”

2025-06-27 11:44:26 - ERROR - backend.app.agents.reasoning_agent - Reasoning error: 500 INTERNAL. {‘error’: {‘code’: 500, ‘message’: ‘An internal error has occurred. Please retry or report in Troubleshooting guide  |  Gemini API  |  Google AI for Developers’, ‘status’: ‘INTERNAL’}}

Anyone get error like me

2 Likes

Hi @NGUY_N_HOANG_TU_N_IT ,
Welcome to the Forum!

500 INTERNAL means an unexpected error on Google’s side. Try reducing input context or switch to another model(e.g.,gemini-2.5-flash,etc). If it keeps happening, retry later or report using the Send feedback button in Google AI Studio.

Thanks!

2 Likes

I am also getting the same issue.

AFC stands for Automatic Function Calling

seems to be enabled by default (which has no sense if one haven’t defined any)

we can disable it declaring in the generation config

config = types.GenerateContentConfig(
automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True)
)

And also setting the mode of the function calling config as ‘NONE’

tool_config = types.ToolConfig( function_calling_config=types.FunctionCallingConfig( mode=“NONE”, ) )

Why the fuck ‘AUTO’ mode is the default. even if one haven’t defined any function tool.

3 Likes

google_genai.models:AFC is enabled with max remote calls: 10. is just info and not the cause of error and AUTO is default because it’ll call functions if you define it or it won’t call any functions they’re not passed in the request. So this is still in your control. It’ll be even weirder that you pass functions in request but still have to explicitly enable function calling.

You can check in the description of NONE that it’s equivalent to sending a request without any function declarations.

2 Likes