0PricingLogin
AI Agents · Lesson

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

  1. How Function Calling Works
  2. Defining Tool Schemas (JSON Schema)
  3. Choosing Tools at Runtime
  4. Returning Results to the Model
← Back to AI Agents