Per-Request Options
The simplest way to control the model and options is to pass them directly in the request. This is ideal for one-off adjustments.options array is passed directly to the LLM provider. Common options include temperature, max_tokens, and top_p, though available options vary by provider and model.
Using LLMConfig
When you need consistent settings across multiple requests — such as a custom API key, base URL, or organization — useLLMConfig to construct a configured StructuredOutput instance.
model and options values override the corresponding LLMConfig defaults, so you can set sensible defaults in the config and adjust individual requests as needed.
Using Presets
If you have named LLM configurations defined in a configuration file, you can load them by name.LLMConfig::fromPreset(), which loads the connection details from your configuration.
Using StructuredOutputRuntime
For the highest level of control, create aStructuredOutputRuntime directly. This gives you access to output mode, retry settings, custom validators, transformers, deserializers, and extractors.
Common Options
These options are widely supported across providers, though exact behavior may vary.| Option | Type | Description |
|---|---|---|
temperature | float | Controls randomness. Lower values (e.g. 0) produce more deterministic output. |
max_tokens | int | Maximum number of tokens in the response. |
top_p | float | Nucleus sampling threshold. |
stop | array | Stop sequences that end generation. |
stream | bool | Enable streaming (prefer withStreaming() instead). |
response_format for OpenAI or thinking for Anthropic) can also be passed through the options array. Consult your provider’s API documentation for details.