New API feature: forcing function calling via `tool_choice: "required"`

Yes, that is the expected behavior for tool_choice: "required", though I agree it’s somewhat confusing.

To provide a bit more context, before we introduced this new feature, when you set tool_choice: {"type": "function", "function": {"name": "my_function"}}, the finish_reason would always be stop rather than tool_calls. Only when you used the default tool_choice: "auto" option, and the model chose to use a tool, the finish_reason would be tool_use. So when we designed this new feature, we thought it made more sense to provide the consistent behavior as tool_choice: {"type": "function", "function": {"name": "my_function"}} as the two are more similar (i.e. model is forced to use a tool).

Fixing this now could potentially break some users’ integration, but we will almost certainly fix this when we release the next API version.

3 Likes