Beyond chat completion, models can emit tool calls (function names + JSON args) your backend executes—calculators, SQL, ticket APIs.
Tool loop
- Send tools schema to model
- Model returns tool_call
- Your server runs function with auth checks
- Send tool result message back
- Model produces final natural language answer
Safety
Allow-list tools, validate args, cap row limits on SQL, never pass raw user SQL to production databases.
Alternatives
LangChain, LlamaIndex, and custom orchestrators wrap retrieval + tools—understand the raw API first to debug failures.
Important interview questions and answers
- Q: Who executes tools?
A: Your backend—not the model vendor—so you enforce authorization.
Self-check
- List the tool loop steps.
- One SQL safety rule?
Tip: Execute tools server-side with the same auth as your REST API—never trust model arg strings.
Interview prep
- Tool execution?
Your backend runs tools with same authorization as APIs.
- SQL safety?
Parameterized queries, row limits, read-only roles—never raw user SQL.