SchemaGenerationSettings
Settings for SchemaGeneration. Values fall back through three levels: document → SDK → built-in default. Writes target the document only when set on a document’s settings, otherwise the SDK globally when set on SdkSettings.
Tags: Vision
from nutrient_sdk import SchemaGenerationSettingsConstruction
SchemaGenerationSettings is accessed through a Document instance for per-document overrides, or via SdkSettings for SDK-wide defaults.
# Per-document overridewith Document.open("input.pdf") as doc: settings = doc.settings.schema_generation_settings settings.some_field = new_value # mutate fields directly
# SDK-wide default (applies to all documents)SdkSettings.schema_generation_settings.some_field = new_valueSettings are configured by writing to fields on the returned object. The settings property itself cannot be reassigned — doc.settings.schema_generation_settings = other_settings is rejected.
Properties
allow_discriminated_unions
@propertydef allow_discriminated_unions(self) -> bool
@allow_discriminated_unions.setterdef allow_discriminated_unions(self, value: bool) -> NoneEnable discriminated unions: variant object types expressed as anyOf with a shared constant discriminator field per variant. oneOf is never used — it is rejected by OpenAI strict mode and silently ignored by Gemini. When false (default), the schema contains no union types beyond null unions.
Type: bool
Default: false
allow_enums
@propertydef allow_enums(self) -> bool
@allow_enums.setterdef allow_enums(self, value: bool) -> NoneEnable enum constraints for fields with a small closed set of known values. Default is true.
Type: bool
Default: true
allow_nullable
@propertydef allow_nullable(self) -> bool
@allow_nullable.setterdef allow_nullable(self, value: bool) -> NoneEnable nullable fields in the generated schema. Nullability is expressed as a type union with null (for example, "type": ["string", "null"]) — the only form accepted across the major structured-output modes. When false, every field is non-nullable. Default is true.
Type: bool
Default: true
allow_patterns
@propertydef allow_patterns(self) -> bool
@allow_patterns.setterdef allow_patterns(self, value: bool) -> NoneEnable regex pattern constraints on string fields. Off by default: pattern support differs widely between structured-output modes (several reject common shorthand classes such as \d), so patterns are only generated when explicitly enabled.
Type: bool
Default: false
allow_string_formats
@propertydef allow_string_formats(self) -> bool
@allow_string_formats.setterdef allow_string_formats(self, value: bool) -> NoneEnable string format annotations (for example, date-time or uuid), restricted to the formats the target dialect documents as supported. Default is true.
Type: bool
Default: true
compatibility
@propertydef compatibility(self) -> SchemaCompatibility
@compatibility.setterdef compatibility(self, value: SchemaCompatibility) -> NoneTarget dialect preset applied on top of the individual knobs. The effective rule is always the stricter of the knob and the dialect limit; features the selected dialect documents as rejected are never emitted. Default is Portable — the intersection accepted by all major structured-output modes.
Type: SchemaCompatibility
Default: SchemaCompatibility.Portable
include_constraints
@propertydef include_constraints(self) -> bool
@include_constraints.setterdef include_constraints(self, value: bool) -> NoneAlso generate cross-field constraint rules encoding the logical relationships of the document type (for example, a subtotal equaling the sum of line item amounts), as standard JsonLogic expressions (jsonlogic.com). The result is always an envelope object with a schema property (the JSON Schema) and a constraints array; this knob only controls whether constraints are generated — when false (default), the array is empty. Rules referencing fields that don’t exist in the generated schema are dropped, so the constraints always validate against the schema they ship with.
Type: bool
Default: false
max_array_items
@propertydef max_array_items(self) -> int
@max_array_items.setterdef max_array_items(self, value: int) -> NoneWhen greater than zero, bounds the number of items of arrays in the generated schema. Emitted as a maxItems constraint when the target dialect supports it, and as description text otherwise (the portable and Anthropic dialects reject maxItems). Zero (default) leaves arrays unbounded.
Type: int
Default: 0
max_fields
@propertydef max_fields(self) -> int
@max_fields.setterdef max_fields(self, value: int) -> NoneMaximum total number of properties across the whole generated schema, counting nested objects and union variants. Schemas exceeding the bound are truncated, keeping the most relevant fields first. Values above 200 are clamped to 200. Default is 50.
Type: int
Default: 50
max_nesting_depth
@propertydef max_nesting_depth(self) -> int
@max_nesting_depth.setterdef max_nesting_depth(self, value: int) -> NoneMaximum object nesting depth of the generated schema. Structures deeper than the bound are flattened. The root object is depth one. Dialect presets may cap this further (OpenAI strict mode and the portable intersection allow at most five levels). Default is three.
Type: int
Default: 3
max_retries
@propertydef max_retries(self) -> int
@max_retries.setterdef max_retries(self, value: int) -> NoneHow many times to retry the vision model when its output is invalid — unparseable JSON or a draft that fails meta-schema validation. Each retry feeds the specific validation errors back to the model. Zero disables retries; there is no upper bound (each retry is a full model call, so the cost is yours to choose). Default is one.
Type: int
Default: 1