NEW
Also known as: Tool Use, Function Tooling
LLM-triggered structured invocations of functions with typed arguments and outputs.
DESCRIPTION
Function calling lets language models return structured arguments to invoke external tools, APIs, or procedures. It enables deterministic integration between free-form generation and programmable systems by constraining outputs to schemas. Typical uses include database lookups, retrieval, transactional updates, and workflow orchestration. Strong schema design, authentication, and input/output validation are critical to ensure safety and reliability. It underpins modern agent frameworks where the model chooses when and how to call tools. Vendors often support JSON Schema-like interfaces, enabling typed argument validation and robust error handling. Observability, retries, and circuit breakers help manage production reliability. It reduces prompt engineering complexity by shifting control to explicit interfaces.
ALTERNATIVE DEFINITIONS
OpenAI
Function calling allows you to describe functions to the model, and have the model intelligently choose to output a JSON object containing arguments to call those functions.
Emphasizes JSON arguments and the model’s autonomous decision to call functions.
Anthropic
Tool use lets Claude call external tools and APIs to complete tasks, by sending and receiving structured data.
Highlights external tool/API invocation and structured I/O for task completion.
RELATED TERMS
Agent Autonomous Agent API JSON Schema Retrieval-Augmented Generation Orchestration Model Context Protocol Plugin Webhooks
COMPETING TERMS
Structured Output Direct Prompting
RELATIONS
- Referenced by: AgentBench Berkeley Function-Calling Leaderboard
KNOWLEDGE AREAS
AI MLOps Software Engineering Platform & Tooling Data Engineering
TARGET AUDIENCE
AI Engineer MLOps Engineer Software Developer Data Engineer AI Product Manager
EXTERNAL SOURCES
- Wikipedia - Application programming interface
- OpenAI - Official function calling guide
- Anthropic - Claude tool use documentation
- Microsoft Learn - Azure OpenAI function calling
- LangChain - Tools and tool calling in LangChain
TOP QUESTIONS
What is Function Calling in LLMs?
Function Calling is a way for models to output structured arguments that trigger external functions or APIs. It bridges free-form text with deterministic programmatic actions.
Category: Definition
Why use Function Calling instead of pure prompting?
It guarantees structured I/O and lets you validate arguments against schemas. This improves reliability, safety, and composability compared to unstructured natural language responses.
Category: Relevancy
How is Function Calling typically implemented?
You register function schemas, let the model propose arguments, validate them, and then execute the function. The results can be fed back to the model for follow-up reasoning.
Category: How-to
What are common mistakes with Function Calling?
Overly broad schemas, weak validation, and missing authentication are typical pitfalls. Another mistake is calling too many tools per turn without cost or latency controls.
Category: Mistakes
What risks come with Function Calling?
Poorly validated arguments can cause injection or unintended actions. Excessive tool calls may raise costs, latency, and error rates without proper safeguards.
Category: Risk
How does Function Calling relate to agents?
Agents often rely on Function Calling to perceive, reason, and act through tools. It provides the action mechanism inside the agent loop.
Category: Relationship
When should I prefer Structured Output over Function Calling?
If you only need validated JSON without invoking external side effects, Structured Output suffices. Use Function Calling when actions or API calls must be executed.
Category: Alternatives
How do I secure Function Calling?
Implement schema validation, least-privilege credentials, input sanitization, rate limits, and audit logging. Add human-in-the-loop or policy checks for sensitive actions.
Category: Security
What metrics matter for Function Calling in production?
Track tool call success rate, latency, error categories, retry rate, and cost per action. Monitor argument validation failures and security policy denials.
Category: Operations
How do I test Function Calling?
Use unit tests for schema validation, integration tests for tool invocation, and golden tests for prompt-tool interactions. Add chaos testing for tool timeouts.
Category: Testing