Overview
The structured-output package deliberately avoids a single global settings object. Configuration is split across purpose-specific classes, keeping request configuration local and shared behavior reusable.Configuration Classes
LLMConfig
Holds provider connection settings: API URL, API key, model name, driver, token
limits, and provider-specific options.
StructuredOutputConfig
Controls the structured-output behavior: output mode, retry settings, prompt
templates, schema naming, and response caching.
| Setting | Default | Purpose |
|---|---|---|
outputMode | Tools | How the schema is delivered to the LLM (Tools, Json, JsonSchema, MdJson, Text, Unrestricted) |
maxRetries | 0 | Maximum retry attempts after the first call |
retryPrompt | "JSON generated incorrectly..." | Template for retry feedback messages |
toolName | "extracted_data" | Function name used in tool-call mode |
toolDescription | "Function call based on..." | Description sent with the tool definition |
schemaName | "default_schema" | Name used in JSON Schema mode |
useObjectReferences | false | Enable $ref usage in generated schemas |
defaultToStdClass | false | Return stdClass instead of arrays for untyped schemas |
responseCachePolicy | None | Whether to cache streaming response snapshots for replay |
StructuredOutputRuntime
Assembles the runtime by combining an inference provider, event dispatcher,
structured-output config, and optional pipeline customizations:
Why No Global Settings?
Splitting configuration serves several goals:- Locality — each request can use a different provider or different retry settings without affecting other requests.
- Testability — configuration objects are plain value objects that can be constructed in tests without touching global state.
- Composability — the same
LLMConfigcan be shared across the structured-output package, the Polyglot inference layer, and other companions without coupling them together. - Immutability — both
LLMConfigandStructuredOutputConfigare immutable. Mutation methods return new instances, making configuration safe to share across concurrent or reentrant code paths.