Function calling and tool calling
Practice this questionOverview
- Function calling lets a model propose a named function and structured arguments.
- Tool calling is the broader pattern that includes functions and capabilities such as search or code execution.
- A proposed tool call is an untrusted request that your application chooses whether and how to execute.
Why this matters
Models need current facts and access to approved actions outside their learned knowledge.
An everyday example
A support employee asks the claims team for status rather than making it up.
A technical example
Model proposes getClaimStatus({claimId: "C42"}); application validates arguments, authorizes C42, and returns a minimal result.
How it works
- Register tool schemas
- Receive call
- Check tool allowlist
- Parse arguments
- Authorize
- Execute with deadline
- Return result with matching call ID
- Ask model for the answer.
Architecture and flow
User → model → proposed tool → validation/authorization → service → observation → model → answer.
The insurance assistant example
A claim-status tool exposes read-only status. Creating a claim is a separate tool with approval and idempotency protections.
When to use it
For fresh account data, search, or explicit business actions.
When to avoid it
Do not expose raw SQL execution, arbitrary HTTP destinations, or unrestricted shell commands to a customer-facing agent.
Interview answer
“The model selects a tool and arguments; my backend validates and authorizes the call, executes business logic, and returns a result for the model to explain.”
Benefits, trade-offs, and production considerations
- Handle multiple calls, malformed arguments, timeouts, duplicates, and unknown tools.
- Tool-result text is also untrusted.
- Built-in provider tools and application functions can have different execution responsibilities.
- Official OpenAI function calling guide.