Tools are functions the model can invoke: search, calculator, run code, call a REST API, read a file. The model doesn’t run them itself — it outputs a tool call (name + arguments). Your app executes the function, gets the result, and sends that result back to the LLM as context. The LLM then either calls another tool or replies to the user. This is how agents get real-time data, run code, or change state. Most LLM APIs support this via function calling: you declare the list of tools (name, description, parameters); the model returns a structured choice (e.g. JSON) indicating which tool and with what arguments. You must validate and run the tool safely (rate limits, auth, sandboxing).
Conversation flow: one tool use
User
What's the weather in Berlin?
App → LLM
Sends message + list of tools (e.g. get_weather)
LLM → App
Returns tool_call: get_weather(city: Berlin)
App
Calls weather API, gets { temp: 14, unit: °C }
App → LLM
Sends observation: 'Tool result: 14°C, cloudy'
LLM → User
It's 14°C in Berlin, a bit chilly — bring a jacket.
Function calling: what the model and app exchange
1. LLM returns (instead of plain text):
{
"tool": "get_weather",
"arguments": { "city": "London", "unit": "celsius" }
}2. Your app runs the function and gets:
{ "temp": 12, "conditions": "Cloudy" }3. You send that back to the LLM as context; it then replies to the user in natural language.
Example: End-to-end flow
User: "What’s the weather in Berlin?" → LLM returns get_weather(city=Berlin) → your app calls the weather API → gets { temp: 14, unit: "celsius" } → you append "Tool result: 14°C" to the conversation → LLM replies: "It’s 14°C in Berlin."