#[non_exhaustive]pub struct GenerationOptions {
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub reasoning_effort: Option<String>,
pub extra_body: Map<String, Value>,
pub output_schema: Option<Value>,
}Expand description
Generation knobs a caller may pin for the invocation. None leaves the
provider default in force.
Protocol adapters reject options they cannot faithfully render. Hosts own
model-specific capability validation, defaults, and aggregate budgets;
reasoning_effort and extra_body are sent as given for that reason.
Serializable for logs and tests; the serialized form is not part of the stable set and may change in any release.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.temperature: Option<f32>Sampling temperature; None leaves the provider default in force.
max_tokens: Option<u32>Upper bound on generated tokens, including reasoning tokens where the
provider counts them. None leaves the limit unconstrained by the caller.
reasoning_effort: Option<String>Reasoning effort, written to the protocol’s effort key exactly as
given: Chat reasoning_effort, Responses reasoning.effort, Anthropic
output_config.effort. None omits the key. The value is not checked
or mapped; which values a model accepts is the host’s knowledge, and a
value the provider refuses comes back as the provider’s error.
extra_body: Map<String, Value>Further request fields, merged into the request body exactly as
given. This is where protocol- or model-specific settings go, such as
an Anthropic thinking object. Where the adapter wrote an object and
the same key here is an object too, the two are merged key by key, so
{"reasoning": {"summary": "auto"}} joins the effort the adapter
wrote. Any other value the adapter writes itself (model, the
messages, tools, the options above) is kept and the value given
here is dropped without an error. output_schema is kept whole: a
key beside the schema is merged, a key inside it is not. Every other
key is sent unchecked, a null included.
“Kept” goes by the key the adapter wrote, not by meaning: a key the protocol also understands under another name is sent beside the adapter’s own. An adapter may write further keys by default, and on a streaming call it sets the keys that turn streaming on whatever is given here; the adapter’s documentation lists them. A field that changes the shape of the response can make it unreadable to the adapter.
A serialized null reads as empty.
output_schema: Option<Value>JSON Schema the final response should satisfy, rendered natively
where the underlying protocol supports it. Schema validation and
corrective retry stay host-side. None omits it.
Implementations§
Source§impl GenerationOptions
impl GenerationOptions
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Sets the sampling temperature.
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
Sets the upper bound on generated tokens.
Sourcepub fn with_reasoning_effort(self, reasoning_effort: impl Into<String>) -> Self
pub fn with_reasoning_effort(self, reasoning_effort: impl Into<String>) -> Self
Sets the reasoning effort.
Sourcepub fn with_extra_body(self, extra_body: Map<String, Value>) -> Self
pub fn with_extra_body(self, extra_body: Map<String, Value>) -> Self
Replaces the extra request body fields.
Sourcepub fn with_output_schema(self, output_schema: Value) -> Self
pub fn with_output_schema(self, output_schema: Value) -> Self
Sets the JSON Schema the final response should satisfy.