Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Forced function calling not working with Gemini Pro 1.5 and OpenAI library

Hey, 

 

I'm using the Openai library to do some function calling requests with the Gemini models. Based on the documentation (https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/call-gemini-using-openai-library#cl...) the Pro 1.5 model should support forced function calling, but whenever I try adding 'required' or 'any' as tool_choice I'm getting this error

 

Error code: 400 - [{'error': {'code': 400, 'message': "Expected a string 'tool_choice' to be one of 'none' or 'auto'; found 'required'.", 'status': 'INVALID_ARGUMENT'}}]

 

I've tried both  'google/gemini-1.5-pro-preview-0409' and 'google/gemini-1.5-pro-001' as models.  It does work with 'auto' so the rest of the call should be ok. 

 
5 4 1,907
4 REPLIES 4