Expand description
Typed per-provider request options and reply extras. A provider’s
ProviderExtension marker names its key, its serialize-only Options
and its Extras view of a reply. ProviderOptions holds entries for
several providers at once, and each wire reads only the entry named by
its own provider.
An entry is an object of sections: SHARED ("*") for fields every
route of the provider spells the same, and one section per route, named
by its API ("openai.chat", "openai.responses"). A wire merges "*",
then the section of the route it encodes, at the top level of the body,
above the mapped generation options and below additional_params. A
section for another route is skipped.
Each Options type names its provider (ExtensionOptions::Ext), so
ProviderOptions::set and CompletionRequest::provider_option take
the options by value, with no provider type and no ?. Options that do
not serialize fail the request’s encode.
use rig_core::completion::{CompletionRequest, ProviderOptions};
use rig_core::providers::openrouter::extension::{OpenRouterExt, OpenRouterOptions};
let request =
CompletionRequest::new("hi").provider_option(OpenRouterOptions::new().session_id("s-1"));
assert!(request.provider_options.contains::<OpenRouterExt>());Structs§
- Provider
Options - Typed options for several providers, one entry per provider key. Each wire reads only the entry named by its own provider. Equality and the serialized form are the entries’ sections. A deserialized entry has no typed options behind it, so its fields are sent as written: inserting the typed options again restores their refusal check.
Enums§
- Options
Error - Why a provider’s options cannot be stored.
Constants§
- SHARED
- The section every route of a provider reads.
Traits§
- Extension
Options - A provider’s request options. Serialize-only: the body keys they write
are their only output. They are plain data,
Send + Syncon every target, since a request carrying them may be held in shared host state, and unwind safe, so a request holding them stays unwind safe. - Provider
Extension - A provider’s typed request options and reply extras.
- Reply
Extras - A typed view of a reply’s provider document.