Working with LLM APIs · TRACK 04/05
Function Calling
The API mechanism that lets a model ask your code to do things.
// THE TRACK
01 · START HEREThe Function-Call LoopWalk the full loop — model asks, your code runs, results go back — and understand that the model never executes anything itself.BEGINNERBest PracticesLearn how to design schemas, write descriptions, handle errors, and know when to skip tools entirely so your LLM agent calls functions reliably.INTERMEDIATEFunction SchemasWrite tool definitions — names, descriptions, and JSON Schema parameters — that the model reads correctly and calls with valid arguments.BEGINNERReturning Tool ErrorsLearn how to feed a failed tool's result back to the model so it self-corrects — retrying, fixing bad arguments, or backing off — instead of looping forever.INTERMEDIATEForcing Tool UseControl whether and which tool the model calls using tool_choice — auto, required, none, or a named tool — and know when forcing a call helps or backfires.INTERMEDIATEParallel Tool CallingUnderstand how a model can emit several tool calls in one turn, how to execute and return them together, and when to switch parallel calling off.INTERMEDIATEOpenAI Structured OutputsYou will understand how OpenAI's native Structured Outputs feature constrains a model to return output that exactly matches your JSON Schema, and how it differs from older JSON mode.INTERMEDIATEXGrammarYou will understand how XGrammar acts as the low-level grammar engine that makes constrained, schema-valid decoding fast inside serving stacks like vLLM and SGLang.ADVANCED