AI Function Calling Tutorial: Tools as Schemas

TL;DRFunction calling exposes tools as schemas so the model returns structured calls to run.

The production pattern (also in ai-072): you give the model a list of functions with typed parameters; it decides when to call one and returns the function name + JSON arguments; your code executes and returns results, which the model uses to continue. It's structured output applied to actions — the reliable bridge between an LLM and real systems, and the foundation of agents and integrations.

Key points

Common mistakes

Try it: Trace one function-calling round-trip from schema to result.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>schemas → model picks: {"name":"search","args":{"q":"x"}}
your code runs search("x") → returns results
→ model continues with the data</pre></body></html>
Open the interactive lesson →
Structured Outputs · JSON Mode · Constrained Computer Use · Operating the Desktop