Skip to main content
Creates a reusable contract that validates LLM outputs against a schema and rules.

Signature

ContractConfig<T>

DefinedContract<T>

The returned contract object has two methods:

.accept(run, overrides?)

Executes your LLM call inside the contract boundary. Returns a ContractResult<T>. The optional overrides let you override any config option at call time. Definition-time options are the defaults; runtime options take precedence.

.describe()

Returns the schema and rule metadata Boundary derived from the contract. The SDK logger uses this metadata for dashboard attribution.

RetryOptions

RepairOverrides

Override or disable repair for specific failure categories:
Set to false to skip retrying for that category. Provide a function to generate custom repair messages.

Example

Runtime overrides

Override config per-call without changing the contract definition: