pub struct ModelRequest {
pub model: String,
pub max_output_tokens: Option<u32>,
pub thinking_level: ThinkingLevel,
/* private fields */
}Expand description
A complete, attributed model request. Constructed only via ModelRequestBuilder.
Fields§
§model: String§max_output_tokens: Option<u32>§thinking_level: ThinkingLevelImplementations§
Source§impl ModelRequest
impl ModelRequest
pub fn builder(model: impl Into<String>) -> ModelRequestBuilder
pub fn fragments(&self) -> &[PromptFragment]
pub fn tools(&self) -> &[ToolDefinition]
Sourcepub fn bytes_by_source(&self) -> BTreeMap<ContentSource, usize>
pub fn bytes_by_source(&self) -> BTreeMap<ContentSource, usize>
Byte attribution by source category, including tool definitions. The heart of the attribution invariant: this is derivable for every request because no content can bypass fragment construction.
Sourcepub fn estimate(&self) -> RequestEstimate
pub fn estimate(&self) -> RequestEstimate
Categorized heuristic estimate. Tokenizer counts and provider-reported usage are separate measurements; this does not count wire framing.
pub fn total_bytes(&self) -> usize
Sourcepub fn with_suffix_instruction(
&self,
source: ContentSource,
instruction: &str,
) -> Self
pub fn with_suffix_instruction( &self, source: ContentSource, instruction: &str, ) -> Self
Prefix-cache pattern: the live request, unchanged, with one instruction appended as a suffix (compaction summaries, titles). Tool definitions are dropped — suffix requests want plain text back.
Sourcepub fn with_warm_probe(&self) -> Self
pub fn with_warm_probe(&self) -> Self
Cache-warm probe: the request unchanged — tool definitions kept,
they are part of the provider’s cached prefix (Anthropic caches
tools → system → messages) — plus one throwaway user fragment
(providers reject empty message lists). The fragment sits after the
system-block cache breakpoint, so its content never affects the
cached prefix. max_output_tokens: 1 caps waste if the caller’s
first-event abort is slow.
Sourcepub fn without_image_blocks(&self) -> Self
pub fn without_image_blocks(&self) -> Self
The request with every image block replaced by a text note, for models whose endpoint accepts text content only — sending the image block would fail the whole request at the provider. The session log is untouched: history keeps the real image parts, so switching to an image-capable model replays them as images again. Attribution is preserved per fragment; only the image bytes become the note’s text.
Trait Implementations§
Source§impl Clone for ModelRequest
impl Clone for ModelRequest
Source§fn clone(&self) -> ModelRequest
fn clone(&self) -> ModelRequest
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 ModelRequest
impl Debug for ModelRequest
Source§impl JsonSchema for ModelRequest
impl JsonSchema for ModelRequest
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for ModelRequest
impl PartialEq for ModelRequest
Source§fn eq(&self, other: &ModelRequest) -> bool
fn eq(&self, other: &ModelRequest) -> bool
self and other values to be equal, and is used by ==.