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

# harnest.structured

> Public Python signatures, fields, and methods.

[All Python modules](https://usefused.com/docs/harnest/reference/api/overview.md) · [Import and compatibility guidance](https://usefused.com/docs/harnest/build/python-imports.md)

## Exports

| Name | Kind |
| - | - |
| [`FrameworkMetadata`](#frameworkmetadata) | Class |
| [`PydanticModel`](#pydanticmodel) | Value or type alias |
| [`StructuredOutputError`](#structuredoutputerror) | Class |
| [`callable_output_schema`](#callable_output_schema) | Function |
| [`framework_metadata_field`](#framework_metadata_field) | Function |
| [`provider_output_schema`](#provider_output_schema) | Function |
| [`validate_output_schema`](#validate_output_schema) | Function |
| [`validate_output_value`](#validate_output_value) | Function |
| [`validate_runtime_output`](#validate_runtime_output) | Function |

## FrameworkMetadata

Mark an explicit output-model field as runtime-owned metadata.

`FrameworkMetadata[Details]` remains a normal Pydantic `Details` field in
the application's public result. Harnest omits it from provider-facing
structured output and supplies it after the framework turn completes.

```python theme={null}
FrameworkMetadata()
```

> [accordion] Example
>
> ```python theme={null}
> from harnest.structured import FrameworkMetadata
>
> metadata = FrameworkMetadata()
> ```

## PydanticModel

```python theme={null}
PydanticModel = type[pydantic.main.BaseModel]
```

> [accordion] Example
>
> ```python theme={null}
> from harnest.structured import PydanticModel
> ```

## StructuredOutputError

A configured Pydantic output contract was not satisfied.

> [accordion] Example
>
> ```python theme={null}
> from harnest.structured import StructuredOutputError
>
> try:
>     ...
> except StructuredOutputError as error:
>     ...
> ```

## callable\_output\_schema

Return a directly or postponed-annotated Pydantic result model.

```python theme={null}
callable_output_schema(function: Callable[..., Any]) -> PydanticModel | None
```

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `function` | `Callable[..., Any]` | Required |
>
> ```python theme={null}
> from harnest.structured import callable_output_schema
>
> result = callable_output_schema(function=...)
> ```

## framework\_metadata\_field

Return the single explicit runtime-owned field on an output model.

```python theme={null}
framework_metadata_field(schema: PydanticModel) -> str | None
```

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `schema` | `PydanticModel` | Required |
>
> ```python theme={null}
> from harnest.structured import framework_metadata_field
>
> result = framework_metadata_field(schema=...)
> ```

## provider\_output\_schema

Derive the output contract a provider may generate for Harnest.

```python theme={null}
provider_output_schema(schema: PydanticModel) -> PydanticModel
```

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `schema` | `PydanticModel` | Required |
>
> ```python theme={null}
> from harnest.structured import provider_output_schema
>
> result = provider_output_schema(schema=...)
> ```

## validate\_output\_schema

Require a Pydantic model class at an authored schema boundary.

```python theme={null}
validate_output_schema(value: Any, *, field_name: str) -> PydanticModel | None
```

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `value` | `Any` | Required |
> | `field_name` | `str` | Required |
>
> ```python theme={null}
> from harnest.structured import validate_output_schema
>
> result = validate_output_schema(value=..., field_name=...)
> ```

## validate\_output\_value

Validate Python or JSON text output and redact input values from failures.

```python theme={null}
validate_output_value(schema: PydanticModel, value: Any, *, boundary: str) -> BaseModel
```

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `schema` | `PydanticModel` | Required |
> | `value` | `Any` | Required |
> | `boundary` | `str` | Required |
>
> ```python theme={null}
> from harnest.structured import validate_output_value
>
> result = validate_output_value(schema=..., value=..., boundary=...)
> ```

## validate\_runtime\_output

Validate provider output, inject declared metadata, then validate fully.

```python theme={null}
validate_runtime_output(schema: PydanticModel, value: Any, *, metadata: Any, boundary: str) -> BaseModel
```

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `schema` | `PydanticModel` | Required |
> | `value` | `Any` | Required |
> | `metadata` | `Any` | Required |
> | `boundary` | `str` | Required |
>
> ```python theme={null}
> from harnest.structured import validate_runtime_output
>
> result = validate_runtime_output(schema=..., value=..., metadata=..., boundary=...)
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.