Glossary · Agent architecture

Function calling (LLMs)

A model API feature: you describe functions, the model returns a structured call to one with arguments, and your code runs it and sends back the result.

Function calling is a model API feature in which you describe functions to the model, the model returns a structured request to call one of them with specific arguments, and your code runs the function and sends back the result.

The loop. The flow is the same across providers:

  1. Send the request with tool definitions: a name, a description and a JSON Schema for the arguments.
  2. The model returns a call instead of, or before, a final answer.
  3. Your code executes the function.
  4. You send the result back, and the model answers or calls another function.

Provider shapes. There is no shared specification, and field names differ. OpenAI returns a function_call item with a call_id, a name and JSON-encoded arguments, and expects a function_call_output carrying the same call_id. Anthropic returns a tool_use block with id, name and input, and expects a tool_result with the matching tool_use_id. Gemini returns a function call with a name and arguments and expects a function response. An illustrative function definition in OpenAI’s format:

{
  "type": "function",
  "name": "get_order_status",
  "description": "Look up the current status of an order by its order number.",
  "parameters": {
    "type": "object",
    "properties": {
      "order_number": { "type": "string", "description": "The order number printed on the receipt" }
    },
    "required": ["order_number"],
    "additionalProperties": false
  },
  "strict": true
}

With strict: true, OpenAI constrains the model’s arguments to the schema, which requires additionalProperties: false and every field listed as required. Anthropic also offers strict tool use, and Gemini a VALIDATED mode. Models can return several calls in one turn, which your code can run in parallel.

Who executes. For your own functions, the model only produces the call. Execution, permissions and side effects belong to your code, so arguments generated by the model deserve the same validation as any user input.

Neighbouring terms. Tool use is the broader term, which also covers tools the provider runs itself. MCP standardizes where tools come from and how they are invoked, while function calling is how the model picks one. The MCP vs function calling comparison covers both layers.

Sources

  1. OpenAI API documentation: Function calling (accessed )
  2. Anthropic documentation: Tool use with Claude (accessed )
  3. Google AI for Developers: Function calling with the Gemini API (accessed )