StructuredOutputConfig

data class StructuredOutputConfig<T>(val default: StructuredOutput<T>? = null, val byProvider: Map<LLMProvider, StructuredOutput<T>> = emptyMap(), val fixingParser: StructureFixingParser? = null)(source)

Configures structured output behavior. Defines which structures in which modes should be used for each provider when requesting a structured output.

Constructors

Link copied to clipboard
constructor(default: StructuredOutput<T>? = null, byProvider: Map<LLMProvider, StructuredOutput<T>> = emptyMap(), fixingParser: StructureFixingParser? = null)

Properties

Link copied to clipboard

A map matching LLMProvider to compatible StructuredOutput definitions. Each provider may require different schema formats. E.g. for JsonStructuredData this means you have to use the appropriate JsonSchemaGenerator implementation for each provider for StructuredOutput.Native, or fallback to StructuredOutput.Manual

Link copied to clipboard
val default: StructuredOutput<T>? = null

Fallback StructuredOutput to be used when there's no suitable structure found in byProvider for a requested LLMProvider. Defaults to null, meaning structured output would fail with error in such a case.

Link copied to clipboard

Optional parser that handles malformed responses by using an auxiliary LLM to intelligently fix parsing errors. When specified, parsing errors trigger additional LLM calls with error context to attempt correction of the structure format.