tool_choice
A parameter that controls tool use: "auto" (model decides), "none" (no tools), "required" (must call one), or a specific function.
Last updated
Analogy
Feature flags for tools. Usually "auto", but you can force or forbid them per call.
Code example
await client.chat.completions.create({ model: "gpt-4o-mini", messages, tools, tool_choice: { type: "function", function: { name: "getOrder" } },});In an agent
Forcing a tool is handy for the first step of a workflow, like always classifying before routing.
Questions people ask
What does tool_choice do?
It controls tool use for one call. auto lets the model decide, none forbids tools, required makes it call at least one, and naming a specific function forces that function. Most calls use auto. The other values are for steps where you already know what must happen.
When should I force a specific tool?
When a step must always happen, for example classifying every request before routing it, or always running a search before answering. Forcing the tool makes that step predictable and skips a wasted round where the model might answer without it. Use auto again for the steps after.