Tool use — sometimes called function calling — is the mechanism that gives agents the ability to interact with the world beyond generating text.
Tool use — also called function calling — is the mechanism that gives agents the ability to interact with the world beyond generating text.
1. Define tools as JSON schema: You declare available tools in your API request. Each tool has a name, description, and input schema. The description is critical — the model uses it to decide when to call the tool.
2. Model outputs a structured tool call: When the model needs a tool, it returns stop_reason: "tool_use" and a structured block with the tool name and arguments — not free text.
3. Host executes and returns results: Your application receives the tool call, executes it, and appends the result as a tool_result message. The model continues reasoning with that new information.
This loop repeats until stop_reason: "end_turn".
Anthropic: Tools in the tools array. Results as tool_result content blocks in a user message. Supports parallel tool calls.
OpenAI: tools array with function type objects. Results via tool role messages. Responses API adds built-in tools (web search, code interpreter) without host-side execution.
Google: "Function declarations" in the tools config. Results use functionResponse parts.
Have a follow-up question about this topic?
Ask AI