Tool Calling (aka Function Calling) — способ, которым LLM invokes external functions через structured output (обычно JSON). Client передаёт schema tools → LLM decides which to call with what args → client executes → result обратно LLM → LLM synthesizes final answer. Standard в OpenAI, Anthropic, Gemini APIs. Нужно для agents, RAG-on-demand, database queries, external integrations.
Ниже: подробности, пример, смежные термины, FAQ.
# OpenAI tool calling
tools = [{
'type': 'function',
'function': {
'name': 'get_weather',
'description': 'Get current weather',
'parameters': {
'type': 'object',
'properties': {'location': {'type': 'string'}},
'required': ['location']
}
}
}]
response = openai.chat.completions.create(
model='gpt-5',
messages=[{'role':'user','content':'Weather в Moscow?'}],
tools=tools
)
# response.choices[0].message.tool_calls → [{name, arguments}]Модели 2026 (GPT-5, Claude Opus 4.7) — 95%+ accuracy на simple tools. Complex tools (nested schemas) — тестируйте.
Model Context Protocol от Anthropic (2024) — standard для exposing tools. Clients (Claude Desktop, Zed IDE) connect к MCP servers (file system, GitHub, Slack, etc).
LLM может вызвать не тот tool или с bad args. Authorization проверяйте на сервере, не trust LLM output. Sandbox tool execution.