Choosing Tools at Runtime
Let the model decide which tool to call, force a specific tool, or expose only the tools relevant to the current state.
Let the Model Pick
By default, you give the model a list of tools and it decides which one to call (or none). This is the standard mode and works well when:
- You have 5-15 tools
- Tools have clear, distinct descriptions
- The right tool depends on the user input
tool_choice: auto
The default — model decides:
response = client.chat.completions.create(
model='gpt-4o-mini',
messages=messages,
tools=tools,
tool_choice='auto', # default; can be omitted
)All lessons in this course
- How Function Calling Works
- Defining Tool Schemas (JSON Schema)
- Choosing Tools at Runtime
- Returning Results to the Model