technique

Function calling (tool use)

Function calling lets a language model emit a structured request to invoke a developer-defined tool, enabling reliable JSON output and agent workflows.

Function calling (sometimes called tool use) is the API feature where you give the model a JSON schema describing one or more tools, and the model responds with a tool name + arguments instead of free text. OpenAI, Anthropic, Google, and Mistral all support it. It is the foundation of every modern agent loop: the model decides which tool to call, your code runs it, the result is fed back, and the loop continues until the model emits a final answer. Done well, it replaces brittle string parsing and unlocks reliable structured output even when JSON-mode alone fails.

When to use function calling (tool use)

Common mistakes

FAQ

What is function calling (tool use)?

Function calling lets a language model emit a structured request to invoke a developer-defined tool, enabling reliable JSON output and agent workflows.

When should I use function calling (tool use)?

Any agent or workflow where the model needs to take external action (search, fetch, write to DB). Reliable structured output (more robust than "return JSON" prompting). Multi-step planning with tool routing.

What are the most common mistakes with function calling (tool use)?

Defining too many tools — models above ~30 tools start mis-routing. Vague descriptions in the schema — the model uses them as docstrings. Not validating the tool arguments against the schema on the server side.

Last updated: 2026-06-01. Raw markdown: https://promtable.com/glossary/function-calling.md.