cayu.context.structured_output
Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.
NativeStructuredOutputUnsupported
Section titled “NativeStructuredOutputUnsupported”from cayu.context import NativeStructuredOutputUnsupportedstrategy=NATIVE was requested but the resolved provider does not
support native structured output.
Raised before any session is created or transitioned, so the caller can
retry with strategy="tool" (same JSON contract, provider-neutral
transport) or route to a provider that sets
supports_native_structured_output. Subclasses ValueError so
existing handlers (including the server’s 4xx mapping) keep working.
Bases: ValueError.
This type’s implementation and inherited behavior are available in the linked release source.
Release source · Runtime guarantees · Capability guides
StructuredOutputError
Section titled “StructuredOutputError”from cayu.context import StructuredOutputErrorBases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
path |
str |
required |
message |
str |
required |
schema_path |
str |
required |
validate_durable_text (method)
Section titled “validate_durable_text (method)”StructuredOutputError.validate_durable_text(value: str, info: ValidationInfo) -> strRelease source · Runtime guarantees · Capability guides
StructuredOutputSpec
Section titled “StructuredOutputSpec”from cayu.context import StructuredOutputSpecProvider-neutral JSON structured output requirement.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
json_schema |
dict[str, Any] |
required |
name |
str | None |
None |
max_retries |
StrictInt |
Field(default=2, ge=0, le=8) |
repair_prompt |
str | None |
None |
strategy |
StructuredOutputStrategy |
StructuredOutputStrategy.TOOL |
validate_strategy (method)
Section titled “validate_strategy (method)”StructuredOutputSpec.validate_strategy(value: object) -> StructuredOutputStrategycopy_and_validate_json_schema (method)
Section titled “copy_and_validate_json_schema (method)”StructuredOutputSpec.copy_and_validate_json_schema(value: dict[str, Any]) -> dict[str, Any]validate_optional_nonblank_strings (method)
Section titled “validate_optional_nonblank_strings (method)”StructuredOutputSpec.validate_optional_nonblank_strings(value: str | None, info: ValidationInfo) -> str | NoneRelease source · Runtime guarantees · Capability guides
StructuredOutputStrategy
Section titled “StructuredOutputStrategy”from cayu.context import StructuredOutputStrategyBases: StrEnum.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
TOOL |
class attribute |
'tool' |
NATIVE |
class attribute |
'native' |
Release source · Runtime guarantees · Capability guides
StructuredOutputValidation
Section titled “StructuredOutputValidation”from cayu.context import StructuredOutputValidationBases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
valid |
bool |
required |
output |
Any | None |
None |
errors |
list[StructuredOutputError] |
Field(default_factory=list) |
copy_output (method)
Section titled “copy_output (method)”StructuredOutputValidation.copy_output(value: Any) -> Anydetach_errors (method)
Section titled “detach_errors (method)”StructuredOutputValidation.detach_errors(value)