Skip to main content

FunctionSchema

Defines the JSON Schema for a tool or function used in LLM function calling.

Overview

FunctionSchema describes a callable function that an LLM can invoke, including its name, description, parameter schema, and optional strict validation mode. It is used inside ToolFunction definitions.

Import

Fields

name
str
required
Function name. Must match the pattern ^[a-zA-Z0-9_]{1,64}$ — alphanumeric characters and underscores only, between 1 and 64 characters.
description
str
required
A human-readable description of what the function does. Maximum 4096 characters. This is provided to the LLM to help it decide when and how to call the function.
parameters
dict[str, Any]
required
A JSON Schema object describing the function’s parameters. Must have "type": "object" at the top level with "properties" defining each parameter.
strict
bool | None
Whether to enforce strict schema validation. When True, the LLM must conform exactly to the parameter schema — no extra properties or missing required fields. When None or False, the LLM may produce approximate matches.

Usage

Basic function schema

Using within a ToolFunction


JSON Representation


Name Validation

The name field must match the regex pattern ^[a-zA-Z0-9_]{1,64}$:
  • ToolFunction — wraps FunctionSchema in a tool definition