Skip to content

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.

from cayu.context import NativeStructuredOutputUnsupported

strategy=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

from cayu.context import StructuredOutputError

Bases: BaseModel.

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
StructuredOutputError.validate_durable_text(value: str, info: ValidationInfo) -> str

Release source · Runtime guarantees · Capability guides

from cayu.context import StructuredOutputSpec

Provider-neutral JSON structured output requirement.

Bases: BaseModel.

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
StructuredOutputSpec.validate_strategy(value: object) -> StructuredOutputStrategy
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 | None

Release source · Runtime guarantees · Capability guides

from cayu.context import StructuredOutputStrategy

Bases: StrEnum.

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

from cayu.context import StructuredOutputValidation

Bases: BaseModel.

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)
StructuredOutputValidation.copy_output(value: Any) -> Any
StructuredOutputValidation.detach_errors(value)

Release source · Runtime guarantees · Capability guides