> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# FunctionSchema

# 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](/docs/reference/sdk/v2/python/types/ToolFunction) definitions.

***

## Import

```python theme={null}
from adaline_api.models.function_schema import FunctionSchema
```

## Fields

<ParamField body="name" type="str" required>
  Function name. Must match the pattern `^[a-zA-Z0-9_]{1,64}$` — alphanumeric characters and underscores only, between 1 and 64 characters.
</ParamField>

<ParamField body="description" type="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.
</ParamField>

<ParamField body="parameters" type="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.
</ParamField>

<ParamField body="strict" type="bool | None" optional>
  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.
</ParamField>

***

## Usage

### Basic function schema

```python theme={null}
from adaline_api.models.function_schema import FunctionSchema

schema = FunctionSchema(
    name="get_weather",
    description="Get the current weather for a given city",
    parameters={
        "type": "object",
        "properties": {
            "city": {
                "type": "string",
                "description": "The city name, e.g. 'San Francisco'"
            },
            "units": {
                "type": "string",
                "enum": ["celsius", "fahrenheit"],
                "default": "celsius",
                "description": "Temperature units"
            }
        },
        "required": ["city"]
    },
    strict=True
)
```

### Using within a ToolFunction

```python theme={null}
from adaline_api.models.function_schema import FunctionSchema
from adaline_api.models.tool_function_definition import ToolFunctionDefinition
from adaline_api.models.tool_function import ToolFunction

schema = FunctionSchema(
    name="search_database",
    description="Search the internal knowledge base for relevant documents",
    parameters={
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "The search query"
            },
            "limit": {
                "type": "integer",
                "default": 10,
                "description": "Maximum number of results to return"
            },
            "filters": {
                "type": "object",
                "properties": {
                    "category": {"type": "string"},
                    "date_after": {"type": "string", "format": "date"}
                },
                "description": "Optional filters to narrow results"
            }
        },
        "required": ["query"]
    },
    strict=False
)

tool = ToolFunction(
    type="function",
    definition=ToolFunctionDefinition(var_schema=schema)
)
```

***

## JSON Representation

```json theme={null}
{
  "name": "get_weather",
  "description": "Get the current weather for a given city",
  "parameters": {
    "type": "object",
    "properties": {
      "city": {
        "type": "string",
        "description": "The city name"
      }
    },
    "required": ["city"]
  },
  "strict": true
}
```

***

## Name Validation

The `name` field must match the regex pattern `^[a-zA-Z0-9_]{1,64}$`:

| Example            |                 Valid                 |
| ------------------ | :-----------------------------------: |
| `"get_weather"`    |                  Yes                  |
| `"searchDB"`       |                  Yes                  |
| `"my_function_v2"` |                  Yes                  |
| `"get-weather"`    |      **No** — hyphens not allowed     |
| `"get weather"`    |      **No** — spaces not allowed      |
| `""`               | **No** — must be at least 1 character |

***

## Related

* [ToolFunction](/docs/reference/sdk/v2/python/types/ToolFunction) — wraps `FunctionSchema` in a tool definition
