Gemini API: Function calling mode `ANY` is not enabled for api version v1beta

Running the example curl from docs مقدّمة عن استدعاء الدوال باستخدام Gemini API  |  Google AI for Developers

And receive this error - {
“error”: {
“code”: 400,
“message”: “Function calling mode ANY is not enabled for api version v1beta”,
“status”: “INVALID_ARGUMENT”
}
}


My curl:

curl -L -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=$GEMINI_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
    "contents": {
      "role": "user",
      "parts": {
        "text": "What movies are showing in North Seattle tonight?"
    }
  },
  "tools": [
    {
      "function_declarations": [
        {
          "name": "find_movies",
          "description": "find movie titles currently playing in theaters based on any description, genre, title words, etc.",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616"
              },
              "description": {
                "type": "string",
                "description": "Any kind of description including category or genre, title words, attributes, etc."
              }
            },
            "required": [
              "description"
            ]
          }
        },
        {
          "name": "find_theaters",
          "description": "find theaters based on location and optionally movie title which is currently playing in theaters",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616"
              },
              "movie": {
                "type": "string",
                "description": "Any movie title"
              }
            },
            "required": [
              "location"
            ]
          }
        },
        {
          "name": "get_showtimes",
          "description": "Find the start times for movies playing in a specific theater",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616"
              },
              "movie": {
                "type": "string",
                "description": "Any movie title"
              },
              "theater": {
                "type": "string",
                "description": "Name of the theater"
              },
              "date": {
                "type": "string",
                "description": "Date for requested showtime"
              }
            },
            "required": [
              "location",
              "movie",
              "theater",
              "date"
            ]
          }
        }
      ]
    }
  ],
  "tool_config": {
    "function_calling_config": {
      "mode": "ANY"
    }
  }
}'
1 Like

I’m also experiencing the same issue with gemini-1.5-pro.

No changes to our system, the API simply stopped working overnight.

We are using this API in a business setting and while the large context window is nice, this kind of instability isn’t acceptable in a paid API and I’m seriously having to consider moving to OpenAI as a result. Their models are not as ideal, but at least their API doesn’t cause failures for our own customers using our service. Please get this issue resolved and stop breaking the API outside of experimental models.

3 Likes

I’m experiencing the same issue. I have been using the ‘ANY’ function calling mode with the stable version of the gemini-1.5-pro model, but now I’m suddenly receiving the error message. Please fix this as soon as possible. Thank you.

OpenAI certainly has altered their API without announcement, causing breakage, tearing down developer applications until you write workarounds or plainly have to wait for a fix. Picture sending the wrong chat container tokens to the model for over a week, in production.

Then you have the models themselves also being hit with undisclosed changes despite the versioning.

While it is not nice to have no reason for the change from Google, and have it still documented the same but not operate correctly, we note:

" v1beta: This version includes early-access features that may be under development and is subject to rapid and breaking changes. There is also no guarantee that the features in the Beta version will move to the stable version. Due to this instability, you shouldn’t launch production applications with this version."

Here is a case where “ANY” should have close equivalent: a system message component “always send to the most appropriate function as response; do not reply to the user without first using functions.”

Jay it should be noted by that understanding that function calling in its entirety and system instructions are both under the v1beta and unavailable under stable, despite it being a widely advertised feature, thus your proposed solution of using a system message to recreate the ANY behavior is just as subject to instability. No thanks.

And regardless, v1beta may prescribe that features in Beta may not move to stable, that doesn’t excuse features being disabled without notification and without updating docs, which still indicate ANY is available. Unless the docs are also not accurate, this is a bug and not a product decision.

I’ll be monitoring this situation, but it sounds like officially Gemini isn’t stable and I should just use a different provider that does guarantee a stable API for these features.

2 Likes

Facing the same error. Terrible developer and customer experience. First, the API can’t be used with Cloud Functions in us-central1 and then this? One problem after the other. And they ship more experimental models with unusable rate limits instead of making the current experimental model production ready. And they’re preaching about how devs need to ship production grade applications. How can you even do that with these types of bugs and wrong focus?

After getting a proxy setup dealing with the first issue, now I have to deal with this.

As soon as I possibly can, I’m going to try and migrate off Google because my trust is absolutely rock bottom.

I’m not even going to be excited for releases next time. Just scared cause everything breaks and creates tons of headaches for everyone.

FYI - modifying the system message has not worked for me yet. I keep getting no function call and if I do manage it to call the function, the format and structure specified isn’t maintained.

API is unusable for function calling as-is for my use case. Going to keep trying a little longer and see how it goes, otherwise, will likely be switching providers unfortunately.

It’s a shame because Google has the highest potential in market IMO, but just poor execution. This last release by Google is disastrous for us and likely for many others as well.

Update: Changed implementation from function calling to JSON mode and now it works like how it did with function calling, before this issue started.

Ultimately, if you’re facing this issue, use JSON mode instead of function calling. It will likely require some modifications to your code, but you can reuse your schema.

This issue appears to have been resolved in the latest model update (August 30, 2024). The ‘ANY’ function calling mode has been re-enabled for API version v1beta, and, for now at least, it works again with gemini-1.5-pro.

1 Like