Tool use and function calling in LLM apps
How function calling lets a model request structured actions, and the security and reliability rules you need before you connect real systems.
Overview
Function calling (tool use) lets an LLM return a structured request — “call create_ticket with these fields” — instead of only prose. Your application then runs the function and may send the result back for a final answer.
This is the core of most AI agents. The model chooses; your code still executes.
Why it exists
Models are bad at live data, arithmetic and side effects. Tools give them a clock, a database lookup, or a calculator. Keep tools narrow: get_order_status(order_id) is safer than run_sql(query).
Reliability rules
- Validate every argument against a schema before execution.
- Treat the model as untrusted input. It can ask for the wrong id or a destructive action.
- Idempotency: retries will happen. See idempotency for APIs.
- Timeouts and a maximum hop count. Agents loop.
Security
Do not expose admin tools to an unauthenticated chat. Scope tools to the signed-in user’s data. Log every call. Never let the model supply a shell command or raw SQL. See AI privacy considerations and secrets management.
Related
Last verified: August 2026. Technology and pricing change — always confirm current details with the vendor.