Back to Glossary
LLM

Tool Use

Definition

Tool use enables LLMs to interact with external systems (APIs, databases, code interpreters) by generating structured requests that your application executes, extending the model's capabilities beyond text generation.

Why It Matters

LLMs are powerful reasoners but fundamentally limited to text. They can’t browse the web, query your database, or execute code directly. Tool use bridges this gap by letting the model request actions that your application performs on its behalf.

This transforms LLMs from isolated text generators into capable assistants that can take real actions. A customer service bot can check inventory, create support tickets, and process refunds. A coding assistant can run tests, search codebases, and commit changes. A research agent can search the web, read documents, and synthesize findings.

For AI engineers, tool use is where you add real value. The tools you expose (and how you implement them) determine what your AI system can actually do. Good tool design means clear documentation for the model, robust error handling, and appropriate permission boundaries.

Implementation Basics

Tool use follows a consistent pattern across providers:

1. Tool Definition You describe available tools in a structured format, typically JSON schemas defining the function name, description, and parameters. The quality of these descriptions directly impacts how well the model uses the tools.

2. Model Decision Given a user request and tool definitions, the model decides whether to use a tool and generates the structured call. Modern models are trained specifically for this task and can handle complex tool selection.

3. Execution Your application receives the tool call, validates it, executes the actual function, and returns results. Never trust model-generated parameters blindly. Validate inputs and sanitize for security.

4. Response Integration The tool result goes back to the model, which incorporates it into its response. This may trigger additional tool calls for multi-step tasks.

Design tools with clear, single purposes. A tool called search_and_update_database is harder for the model to use correctly than separate search_database and update_record tools. Start with read-only tools before adding write operations.

Source

Toolformer demonstrates that language models can learn to use external tools through self-supervised learning, calling APIs for calculations, search, and other tasks.

https://arxiv.org/abs/2302.04761