AI Tool Use Tutorial: Function Calling

TL;DRTool use (function calling) lets a model invoke functions you define, with structured arguments.

You describe available functions (name, purpose, parameters as a schema); the model, when useful, outputs a structured call (which function + JSON arguments) instead of text; your code runs it and returns the result. This is the mechanism behind agents and integrations — it lets the LLM reach real systems (databases, APIs, calculators) while you keep control over what can actually run.

Key points

Common mistakes

Try it: Sketch a function schema and the structured call a model would emit.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>tool: get_weather(city: string)
model emits: {"name":"get_weather","args":{"city":"NYC"}}
your code runs it → returns 21°C → model continues</pre></body></html>
Open the interactive lesson →
Agents · LLMS with Tools Multi-Agent Systems · Roles + Handoffs