Skip to content

Tool Calling в LLM

Коротко:

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.

Попробовать бесплатно →

Подробности

  • Tool schema: name, description, JSON Schema для args
  • LLM возвращает structured output { "tool": "name", "args": {...} }
  • Client executes tool → returns result to LLM
  • Parallel tool calls: LLM может invoke multiple tools одновременно (OpenAI 2023+)
  • Model Context Protocol (MCP) — Anthropic's 2024 spec для tools standardization

Пример

# 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}]

Смежные термины

Больше по теме

Часто задаваемые вопросы

Tool calling reliable?

Модели 2026 (GPT-5, Claude Opus 4.7) — 95%+ accuracy на simple tools. Complex tools (nested schemas) — тестируйте.

MCP — что?

Model Context Protocol от Anthropic (2024) — standard для exposing tools. Clients (Claude Desktop, Zed IDE) connect к MCP servers (file system, GitHub, Slack, etc).

Security?

LLM может вызвать не тот tool или с bad args. Authorization проверяйте на сервере, не trust LLM output. Sandbox tool execution.