AISuffer
llm

Function Calling

An LLM capability that lets the model produce structured JSON describing a function to call, so your application can execute it and return results.

What Is Function Calling

Function calling — also called tool use — is the mechanism that lets an LLM trigger code in the outside world. You describe a set of available functions to the model as JSON schemas. When the model decides one is needed, it stops generating prose and instead outputs a structured call: function name plus arguments. Your application runs it, sends the result back, and the model continues. Use it whenever a task needs current data, side effects, or computation the model cannot do reliably from memory.

How It Works

  1. Declare tools — pass a list of function schemas (name, description, parameter types) with the request
  2. Model decides — instead of normal text output, the model emits a tool-use block with arguments
  3. You execute — your code runs the function with those arguments
  4. Return result — you append the function’s output to the conversation
  5. Continue — the model uses the result to produce the final answer or call another tool

Provider Support

  • OpenAItools parameter in Chat Completions and Responses API
  • Anthropic Claudetools block in the Messages API
  • Google Geminifunction_declarations in the GenerateContent API
  • Open-weight models — Llama 3.1+, Mistral, and Qwen support native tool use; older models need a structured-output wrapper

Why It Matters

Function calling is the foundation of agents. Without it, an LLM can only produce text. With it, the same model can search the web, query databases, send emails, run code, and orchestrate workflows. The Model Context Protocol (MCP) is a standardized layer on top of function calling that makes tools portable across hosts.