BroadRouter
Get started

tool_choice

Updated

tool_choice is a request parameter that controls tool use. In OpenAI's Chat Completions it can be auto (the model decides), required (it must call one or more tools), none (no tools), or a named function to force. Anthropic's equivalent options are auto, any, tool and none.

Also called: tool choice, forced tool call, forced function call

Tool calling lets a model ask your code to run a function. tool_choice decides whether that is optional, mandatory or off.

How it works

You send tools (function names, descriptions and JSON Schema parameters) and optionally tool_choice.

OpenAI value Meaning Anthropic equivalent
"auto" Model chooses a message or one or more calls; default when tools are sent {"type": "auto"}
"required" “The model must call one or more tools” {"type": "any"}
{"type": "function", "function": {"name": "get_weather"}} Forces that one tool {"type": "tool", "name": "get_weather"}
"none" No tool calls; default with no tools {"type": "none"}

OpenAI’s function calling guide also describes an allowed-tools option that restricts calls to a subset while keeping the full tool list unchanged, which it suggests for prompt caching.

{"model": "broadnet/glm-5.3",
 "messages": [{"role": "user", "content": "Weather in Riyadh?"}],
 "tools": [{"type": "function", "function": {"name": "get_weather",
   "parameters": {"type": "object", "properties": {"city": {"type": "string"}},
                  "required": ["city"]}}}],
 "tool_choice": {"type": "function", "function": {"name": "get_weather"}}}

Anthropic’s docs note that with any or tool the API prefills the reply, so the model writes no text before the call, and that some Claude models reject forced tool use and return a 400 error.

Why it matters

  • Reliable pipelines. An extraction step that must end in a call should not get a chatty text reply. Forcing the call removes that branch.
  • Safe turns. Setting none for a final summary turn stops the model from starting another tool round while keeping the same tool list.
  • Caching. Anthropic says changing tool_choice invalidates cached message blocks, so keep it stable across turns where you can.

On BroadNet Inference

BroadNet’s API reference documents tool calling for GLM 5.3 and Qwen3.8 27B only, and does not document tool_choice. Test each value you plan to use: send required or a named function and confirm the reply contains tool_calls. If forcing does not behave, use auto with a clear instruction and validate the result, or use structured output on the same models. The open-model tool calling post has a validate-and-retry loop.

Common mistakes

  • Forcing a tool on every turn of an agent loop, so it can never give a final answer.
  • Assuming required means a specific tool. It means any tool.

Questions

What is the default tool_choice?

In OpenAI's API, none when no tools are sent and auto when tools are present. Anthropic uses the same defaults.

When should I force a tool call?

When the only acceptable answer is a call, such as a classifier that must call submit_label. For a fixed JSON reply, structured output is often simpler.

Does BroadNet Inference support tool_choice?

BroadNet documents tool calling for GLM 5.3 and Qwen3.8 27B, but its API reference does not document tool_choice. Test each value before relying on it.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity