pub struct ModelResponse {
pub id: Option<String>,
pub model: ModelRef,
pub content: Vec<ContentPart>,
pub finish_reason: FinishReason,
pub usage: ModelUsage,
pub warnings: Vec<ModelWarning>,
pub provider_metadata: BTreeMap<String, Value>,
pub provider_events: Vec<ProviderData>,
}Expand description
A complete canonical model response.
Fields§
§id: Option<String>Provider response identity.
model: ModelRefActual model that produced the response.
content: Vec<ContentPart>Ordered output content.
finish_reason: FinishReasonNormalized terminal reason.
usage: ModelUsageDetailed model usage.
warnings: Vec<ModelWarning>Explicit degradation and compatibility warnings.
provider_metadata: BTreeMap<String, Value>Namespaced response metadata.
provider_events: Vec<ProviderData>Provider stream events retained without normalization.
Implementations§
Source§impl ModelResponse
impl ModelResponse
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Collects model-visible text in canonical content order.
Reasoning, refusals, Tool calls, citations, and provider-specific
payloads remain available through Self::content and are not mixed
into the returned text.
Source§impl ModelResponse
impl ModelResponse
Sourcepub fn structured<T>(&self) -> Result<T, StructuredOutputError>where
T: DeserializeOwned,
pub fn structured<T>(&self) -> Result<T, StructuredOutputError>where
T: DeserializeOwned,
Decodes ordered textual output into a Rust type.
Reasoning, citations, and opaque provider metadata are deliberately not mixed into the JSON body. An explicit refusal fails closed.
§Errors
Returns StructuredOutputError when text is absent, the model
refused, or the assembled JSON does not deserialize as T.
Trait Implementations§
Source§impl Clone for ModelResponse
impl Clone for ModelResponse
Source§fn clone(&self) -> ModelResponse
fn clone(&self) -> ModelResponse
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more