Skip to main content

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.
Key settings:

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:
  1. Locality — each request can use a different provider or different retry settings without affecting other requests.
  2. Testability — configuration objects are plain value objects that can be constructed in tests without touching global state.
  3. Composability — the same LLMConfig can be shared across the structured-output package, the Polyglot inference layer, and other companions without coupling them together.
  4. Immutability — both LLMConfig and StructuredOutputConfig are immutable. Mutation methods return new instances, making configuration safe to share across concurrent or reentrant code paths.