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
nonefor a final summary turn stops the model from starting another tool round while keeping the same tool list. - Caching. Anthropic says changing
tool_choiceinvalidates 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
requiredmeans a specific tool. It means any tool.