Continuous 500 Internal Server Error - function calling mode ANY and gemini-1.5-flash-latest

I am using the Dart generative ai package and a paid Gemini API key but still getting 500 and unable to even launch my flutter application. I commented out all the function calls to reduce the token count to <100 (just says “Hello”) and that was the only time it worked. My token count if I include all my function calls and still have the “Hello” is around 1500. This is very frustrating and even though I am paying for it I can’t raise a support ticket because I have a basic account without an organization. I am using the gemini flash latest model, if I try the pro, the latency is crazy.

Any one else with the same issue?

The other similar topics seems to have mentioned that this is intermittent and should get resolved automatically but it’s been more than a day since I’ve been getting this issue, and unable to move forward.

if you guys had this issue before, how long did it take for it to work as expected?

Is it just the prompt that you’re sending? What other parameters are you using when you get the error? Can you show us a minimal example of code that demonstrates this?

Hello I was able to get it to working after I commented this code block (replaced the functions with dummy names), the “any” mode wasn’t working when using gemini Flash any way. If I uncomment the below code, I still see the issue, nothing to do with the functions because they still work when I comment this code block. I saw on an other thread that any mode wasn’t working in gemini flash model… not sure what the issue and I am not sure why this post was flagged. Thanks for the reply.

  // functionCallingConfig: FunctionCallingConfig(
              // mode: FunctionCallingMode.any,
              // allowedFunctionNames: {
              //   'function_1',
              //   'function_2',
              //   'function_3',
              //   'function_4',
              //   'function_5',
              //   'function_6',
              //   'function_7',
              //   'function_8',
              //   'function_9',
              //   'function_10',
              //   'function_11'
              // }
              // ),

I modified the topic heading to make it easier to find. That can help other people avoid the 500 errors. And someone at Google might decide to fix flash, there’s nothing in the documentation that says mode ANY shouldn’t work for flash and is a pro-only capability.

1 Like

+1. Same here, the weird part is that it was working like few days ago. Also with gemini-1.5-pro everything is working. I raised a ticket on troubleshooting page, but no reply yet.

I would say something like this is a breaking change and should be announces somewhere (especially if this is a stable version)

Yep; “ANY” Mode has suddenly broken things this week. This is a new issue, and many projects were working fine when using “ANY” mode previously.

This happened to me too.

They have impeccable timing to make a breaking change this close to things like the end of the Gemini competition.

For now, the only fix is to not pass any function calling configs when using Gemini 1.5 Flash. It sucks, it makes it worse, but there’s not really another fix I’ve been able to identify atm.

The ToolConfig part is not totally broken, it’s that ANY is broken. If you give gemini-1.5-flash-latest a useless (“do-nothing”) ToolConfig that specifies AUTO, the functionCall comes through.
This is an example - it can be copied and posted as is:


{
    "contents": [
        {
            "parts": [
                {
                    "text": "Which prime number is larger than 277?"
                }
            ],
            "role": "user"
        },
        {
            "parts": [
                {
                    "text": "Here's how to find a prime number larger than 277:\n\n* **Understanding Prime Numbers:** A prime number is a whole number greater than 1 that has only two divisors: 1 and itself. \n* **Checking Numbers:**  Start by checking the numbers just larger than 277.  You can use a calculator or mental math to see if they are divisible by any smaller numbers. \n* **The Next Prime:**  The next prime number after 277 is **281**. \n\nLet me know if you'd like to find more prime numbers! \n"
                }
            ],
            "role": "model"
        },
        {
            "parts": [
                {
                    "text": "Which theaters in Mountain View, CA show Barbie movie?"
                }
            ],
            "role": "user"
        }
    ],
    "tools": [
        {
            "function_declarations": [
                {
                    "name": "find_theatersAPIToolModuleIPA",
                    "description": "\n    find theaters based on location and optionally movie title which is currently playing in theaters\n    ",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "movie": {
                                "type": "string",
                                "description": "Any movie title"
                            },
                            "location": {
                                "type": "string",
                                "description": "The city and state, e.g. San Francisco, CA"
                            },
                            "date": {
                                "type": "string",
                                "description": "When is the movie showing"
                            }
                        },
                        "required": [
                            "location"
                        ]
                    }
                },
                {
                    "name": "find_moviesAPIToolModuleIPA",
                    "description": "\n    find movie titles currently playing in theaters based on any description, genre or title words.\n    ",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "location": {
                                "type": "string",
                                "description": "The city and state, e.g. San Francisco, CA"
                            },
                            "description": {
                                "type": "string",
                                "description": "Any kind of description including category or genre or title words. Example: romantic comedy; Example: Star Wars; Example: Crime drama; Example: Science Fiction"
                            }
                        },
                        "required": [
                            "description"
                        ]
                    }
                }
            ]
        }
    ],
    "tool_config": {
        "function_calling_config": {
            "mode": "AUTO"
        }
    },
    "safetySettings": [
        {
            "category": "HARM_CATEGORY_HARASSMENT",
            "threshold": "BLOCK_LOW_AND_ABOVE"
        },
        {
            "category": "HARM_CATEGORY_HATE_SPEECH",
            "threshold": "BLOCK_LOW_AND_ABOVE"
        },
        {
            "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
            "threshold": "BLOCK_MEDIUM_AND_ABOVE"
        },
        {
            "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
            "threshold": "BLOCK_ONLY_HIGH"
        }
    ],
    "generationConfig": {
        "temperature": 1.0,
        "topP": 0.95,
        "topK": 40,
        "maxOutputTokens": 2048
    }
}

And yes, the timing for unadvertised breaking of the environment just before people present their code is a recurring annoyance; as I recall they broke everyone using Go one day before the submission deadline the last time around by introducing the usageMetadata in the response, which the Go library could not deserialize.

1 Like

Yeah, the reason why “ANY” mode was important was actually because it adhered to the necessary parameters I accept better. It still passes a function call, but it doesn’t give me the right parameters every time. It was one of those things where I don’t know why it worked better, but it did. Something about ANY mode just forced it to better adhere to the schema’s constraints in a way that was really easy for me to work with code-wise.

For example, “ability” as defined in my schema is a single string, but for some reason, when mode is set to AUTO, it wants to pass the parameter as a single-entity array, which breaks my code (as I spent the past three weeks having no issues getting passed a simple string value). Or it might just not pass a function at all, which also breaks things, and is why ANY mode was kind of important lol.

But I think they recognize this is a bug, and hopefully this is going to get fixed pretty soon. Fingers crossed lmao.

This was the most visible difference for most people. You still can tweak your prompt to make it more likely that flash will choose to use the tool function. If prompt driven, I had found I needed to remind the model every second prompt at the latest, or the influence of the prompt diminished and the model went back to its own devices and neglected the tool function.

For the competition, I am guessing most contestants will switch to using pro, since that’s working fine.

1 Like

Yeaah, we’ll see how things go and what happens when i wake up tomorrow lol. Even without ANY, I can still get a good 90-95% chance of hitting a function call. It isn’t as much of a problem for me until the player gives a prompt that’s looser / more vague, and that’s already outside of my control at that point. What I was also able to do was basically provide a specific “failure” function call Gemini could pass, which still adhered to my constraints. I’ve learned some tips and tricks over time that’s helped in the past, but this issue kind of blew everything out of the waters lol.

If it persists past the weekend, I’ll just switch to Pro. That being said though, if the code works otherwise without this bug, that shouldn’t affect the judging process too intensely, as it’s not technically our code that’s the problem atm. It’s mainly a problem for the demoing process, which can understandably force folks to switch.

If I could I would. But the latency is just too slow for gaming; it slows everything down way too much. After demoing my concept over the weekend, Flash seems to be just fast enough to where people are anticipating, but not confused if that makes sense. With Pro, it takes close to a minute, and players think they broke something lol. Also it turns a 2 minute battle into a 10 minute fight lol.