Glossary
What is Function calling?
Also known as: tool calling, tool use, structured output
Function calling (sometimes "tool calling" or "tool use") is the language-model feature that lets an LLM decide when to invoke an external function with structured arguments instead of producing free text. The developer registers a list of available functions (book_appointment, create_clio_matter, search_documents), each with an input schema. The model decides during a conversation which function to call and produces a structured JSON object matching the schema. The function executes; its result is fed back into the conversation; the model continues. Function calling is what turns a plain chatbot into a useful agent.
How function calling works
In a function-calling-enabled LLM API call, the developer passes the available functions as part of the request, alongside the conversation messages. Each function has a name, description, and JSON schema for inputs. The model reads the conversation, decides whether to respond with text or call a function, and if it calls a function, produces a JSON object that matches the schema. The application executes the function, gets a result, appends a tool-result message to the conversation, and calls the API again. The model uses the result to continue (and may call more functions in sequence).
OpenAI, Anthropic, and Google all expose function-calling APIs in their flagship models. The schemas and message formats differ slightly per provider, but the pattern is the same.
Why function calling matters for production agents
Without function calling, an LLM can only produce text. With function calling, it can take actions: book appointments, look up customer records, create CRM contacts, send emails, query databases. This is the dividing line between "AI chatbot that talks" and "AI agent that does work."
For an AI legal-intake voice agent specifically, function calls handle: creating the Clio matter, booking the consult on the right attorney’s calendar, running a conflict check against existing clients, sending the consult-confirmation SMS, and transferring the call to a human when the caller asks.
Function-calling failure modes
Function calls are not perfect. Models occasionally call the wrong function, pass malformed arguments that don’t quite match the schema, or call a function when the right answer was a text response. Production agents wrap function calls in schema validation, retry logic, and explicit fallback paths. We also write the function descriptions like instructions ("Use book_appointment ONLY when the caller has confirmed a specific time slot"), because those descriptions become part of the model’s decision-making.