pub enum ReasoningItem {
Text {
id: Option<String>,
format: ReasoningFormat,
index: Option<u32>,
text: String,
signature: Option<String>,
},
Summary {
id: Option<String>,
format: ReasoningFormat,
index: Option<u32>,
summary: String,
},
Encrypted {
id: Option<String>,
format: ReasoningFormat,
index: Option<u32>,
data: String,
},
}Expand description
One provider-emitted reasoning element.
Three variants cover every shape known across the major providers:
readable reasoning text (with optional Anthropic-style signature),
summary blurbs (OpenAI/Anthropic summaries), and fully-encrypted
blobs (Gemini thoughtSignature, OpenAI encrypted_content,
Anthropic redacted_thinking). Round-trip identity is the contract:
every byte the provider emitted must come back unchanged on the
next assistant message.
Variants§
Text
reasoning.text — visible reasoning content. The
signature field is opaque and mandatory round-trip on
providers that emit it (Anthropic).
Fields
format: ReasoningFormatSummary
reasoning.summary — provider-emitted summary of internal
reasoning; carries no signature, but still must replay
verbatim to preserve token-cache continuity on some
providers.
Encrypted
reasoning.encrypted — opaque base64 blob. Gemini’s
thoughtSignature is delivered in this shape via
OpenRouter; OpenAI’s encrypted_content and Anthropic’s
redacted_thinking.data likewise. The bridge stores
data byte-for-byte and the codec attaches it back to the
right wire location for the originating provider.
Implementations§
Source§impl ReasoningItem
impl ReasoningItem
Sourcepub fn format(&self) -> ReasoningFormat
pub fn format(&self) -> ReasoningFormat
Originating-provider tag.
Sourcepub fn index(&self) -> Option<u32>
pub fn index(&self) -> Option<u32>
index if the provider supplied one. OpenRouter uses this
to preserve order across heterogeneous variants when the
provider emits text and encrypted blobs interleaved.
Sourcepub fn carries_signed_payload(&self) -> bool
pub fn carries_signed_payload(&self) -> bool
True iff this item carries a signature/encrypted payload
the provider will reject if missing on replay. Used by
ReasoningCodec to validate “did we receive what we need
for the next turn?” without having to inspect the inner
fields.
Sourcepub fn from_openrouter_value(value: &Value) -> Option<Self>
pub fn from_openrouter_value(value: &Value) -> Option<Self>
Round-trip from a Value shaped exactly as OpenRouter’s
reasoning_details[] item. Returns None if the input is
not an object with a recognized type discriminator.
Sourcepub fn to_openrouter_value(&self) -> Value
pub fn to_openrouter_value(&self) -> Value
Serialize back to the OpenRouter wire shape. Round-trip
fidelity: from_openrouter_value(v).unwrap().to_openrouter_value() == v
for any well-formed input.
Trait Implementations§
Source§impl Clone for ReasoningItem
impl Clone for ReasoningItem
Source§fn clone(&self) -> ReasoningItem
fn clone(&self) -> ReasoningItem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReasoningItem
impl Debug for ReasoningItem
Source§impl<'de> Deserialize<'de> for ReasoningItem
impl<'de> Deserialize<'de> for ReasoningItem
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ReasoningItem
impl PartialEq for ReasoningItem
Source§fn eq(&self, other: &ReasoningItem) -> bool
fn eq(&self, other: &ReasoningItem) -> bool
self and other values to be equal, and is used by ==.