Gemini-2.5-pro-exp-03-25 Function Calling 500 Error with Complex Schema

Hi everyone!

We’ve been testing the new gemini-2.5-pro-exp-03-25 model via the Python google-genai library and encountered an issue specifically related to function calling with complex schemas.

Scenario:

  1. We define a function (execute_operations) with a relatively complex parameter schema (nested objects, arrays of objects with multiple properties, enums).

  2. We use a system instruction prompting the model to generate complex, dummy data for this function call for testing purposes.

Observation:

  • When using gemini-2.5-pro-exp-03-25 , the API consistently returns a ServerError: 500 INTERNAL when the model attempts to generate a FunctionCall with complex arguments trying to match the schema. The specific error message is:
{'error': {'code': 500, 'message': 'An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting', 'status': 'INTERNAL'}}

Here is a colab notebook that reproduces the error: Google Colab

  • When using gemini-2.0-flash with the exact same code, schema, and prompt, the model successfully generates the FunctionCall with the expected complex arguments.

  • It seems gemini-2.5-pro-exp-03-25 can successfully call the same function if the required arguments/generated call structure is much simpler.

This suggests a potential issue specifically with gemini-2.5-pro-exp-03-25’s handling of function calling when the required arguments structure (based on the provided schema) becomes sufficiently complex.

Has anyone else experienced similar behavior with gemini-2.5-pro-exp-03-25 and complex function call schemas?

3 Likes

I encountered the same problem!

Hi @Bryan_Djafer , Welcome to the forum.

Thank you for sharing the code reproduction, it’s helpful.

I am escalating this to the product engineering team.

1 Like

Hi Gunand, alright thank you very much! Let me know if you need any additional information.
Looking forward to the updates.

1 Like

Hi,

I am also facing same issue.

I am also experiencing issues with function calling. For example, I was trying to run this multi-agent workflow from llamaIndex using gemini 2.5 pro and it either stops prematurely after the research agent has finished its work or it gets itself in a circular reference. Using gemini flash 2.0, the workflow executes flawlessly.
Below is the code I used to integrate the gemini llm into the llamaIndex example code mentioned above. I have tried various configurations for the gemini pro llm but nothing seems to work..

def get_llm(model="gemini-2.0-flash"):
    # Get credentials for Vertex AI
    credentials, _ = default(scopes=["https://www.googleapis.com/auth/cloud-platform"])
    auth_req = google.auth.transport.requests.Request()
    credentials.refresh(auth_req)
    if not credentials.valid:
        raise RuntimeError("Failed to refresh Google Cloud credentials.")

    # Base configuration
    llm_config = {
        "api_base": f"https://{region}-aiplatform.googleapis.com/v1/projects/{project_id}/locations/{region}/endpoints/openapi",
        "api_type": "open_ai",
        "model": model,
        "temperature": 0.1,
        "vertexai_config": {
            "project": project_id,
            "location": region,
            "credentials": credentials
        }
    }

    if "gemini-2.5" in model:
        llm_config["automatic_function_calling"] = {"disable": True}
        llm_config["tool_config"] = {"function_calling_config": {"mode": "any"}}

    return GoogleGenAI(**llm_config)

I am having the same issue here!! :frowning:

Hi @GUNAND_MAYANGLAMBAM any update on the matter ? :slight_smile:

Hi @GUNAND_MAYANGLAMBAM , we are facing the same issue with function calling via langchain. Is there any update on this?

Hello, I am having the same issue with 2.5-Flash . After lot of testing I am still not sure what is the problem but I managed to remedy the issue to certain degree:

  • The model could be overloaded so expect that you will have to send the request multiple times
  • It is needed to enhance the prompt so the model understand what output to produce. With 2.0-Flash the model used to return raw text if the schema failed. But now, with 2.5 it looks like if the schema fails one will get 500 error.

I can’t tell if it was just resolved, had the issue starting an hour ago, or if turning thinkingBudget to 0 actually fixed it for me for 2.5 flash: Gemini thinking  |  Gemini API  |  Google AI for Developers.

Hey @Damian_Pereira @Bryan_Djafer , Can you try using the new model gemini-2.5-pro-preview-05-06 and let me know if you are still facing the issue?

Thanks.

Hi @GUNAND_MAYANGLAMBAM , thank you for your update!

I just tried to run the Colab again multiple times with gemini-2.5-pro-preview-05-06 and it seems to work randomly half of the time. Unfortunately, we’re still getting some errors 500

1 Like

Hey @GUNAND_MAYANGLAMBAM. Same here.

The preview model keeps failing with a 500 error.

The experimental model responds now, but it seems to mimic the tool calls, but actually does not call them. See the example content response start below; and there are no tool_calls in the response.

Response content beginning:
“content='```python\nprint(default_api.create_models(files=[\n {\n…”

Hi everyone,

We’re adding another instance of the 500 Internal Server Error encountered with the gemini-2.5-pro-preview-05-06 model.

Context of Error:
The error occurred on June 4, 2025, around 9:08 AM (America/Denver time, UTC-6:00).
At the time, a user (Lou) was interacting with the LLM (gemini-2.5-pro-preview-05-06). The LLM was acting as an AI assistant within a development environment, tasked with general assistance (e.g., understanding issues, browsing documentation, formulating responses). The specific internal operation or user prompt that immediately preceded and triggered the internal error on Google’s side is not detailed in the error message itself, beyond it being an “INTERNAL” error. Lou captured the error message after it was produced by the LLM.

Error Message:

{
  "error": {
    "message": "{\n  \"error\": {\n    \"code\": 500,\n    \"message\": \"An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting\",\n    \"status\": \"INTERNAL\"\n  }\n}\n",
    "code": 500,
    "status": "Internal Server Error"
  }
}

For me, gemini-2.5-pro-preview-05-06 fails on random prompts when several tool are provided.
Some prompts produce 500 error persistently. Adding some random text in the prompt helps sometimes.

Would be great if API provided more details on the error. Instead of generic “An internal error has occurred”. Tool calling is practically unusable for me.
I’m trying to replace it with structured output where LLM provides function name and the arguments, but it works terrible, Gemini doesn’t understand that this is tool calling and enters infinite cycle sometimes.