Back to Prompt Engineering and Patterns

Tool Use and Function Calling

Where LLMs become genuinely useful: when they can call functions, query databases, browse the web. FIND_VIDEO: search 'LLM tool use function calling agents' — recommended channel: Anthropic / Sam Witteveen / James Briggs. Aim for 11 min or under.

18 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Function Calling Architecture — Introduces function calling as a structured bridge between LLMs and external systems to eliminate hallucinations and power agentic workflows.
  2. Environment & Mock Setup — Configures the API client for gpt-3.5-turbo-1106 and defines a local mock weather function returning serialized JSON.
  3. Schema Definition & Argument Extraction — Builds a JSON Schema tool specification, submits a weather query, and deserializes the returned function arguments to run local code.
  4. Controlling Tool Behavior — Tests conversational queries against default tool_choice settings to verify how the model handles non-tool interactions.
PDF notes

Frequently asked questions

Does OpenAI execute the function on its remote servers?

No. The model only generates the function name and parsed JSON arguments; your local application code must execute the actual function.

Why does the model sometimes infer default values not explicitly provided in the prompt?

The model uses contextual knowledge and schema descriptions to infer reasonable defaults, such as selecting Celsius for European locations.

What happens if a user submits a prompt that doesn't need external data?

Under default auto settings, the model bypasses tool calling, leaves tool_calls as None, and populates the content field with standard text.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.