pub enum ContentPart {
CachePoint {
ttl: Option<CachePointTtl>,
},
Text {
text: String,
},
ImageUrl {
url: String,
},
FileUrl {
url: String,
media_type: String,
},
Binary {
data: Vec<u8>,
media_type: String,
},
ResourceRef {
uri: String,
media_type: String,
resource_type: String,
metadata: Metadata,
},
DataUrl {
data_url: String,
media_type: String,
},
}Expand description
Multimodal content in user requests.
Variants§
CachePoint
Prompt-cache boundary after the preceding content block.
The marker is not model-visible content. A TTL is optional because
providers such as Anthropic use per-point 5m/1h TTLs, while OpenAI
GPT-5.6 uses a request-wide 30m policy.
Fields
ttl: Option<CachePointTtl>Optional provider-compatible per-point TTL.
Text
Plain text.
ImageUrl
Image by URL.
FileUrl
Generic file by URL and media type.
Binary
Inline binary media bytes.
ResourceRef
Resource-backed media reference.
Fields
DataUrl
Inline data URL for adapters that accept data URLs.
Implementations§
Source§impl ContentPart
impl ContentPart
Sourcepub const fn cache_point() -> Self
pub const fn cache_point() -> Self
Build a provider-neutral prompt-cache boundary.
Sourcepub const fn cache_point_with_ttl(ttl: CachePointTtl) -> Self
pub const fn cache_point_with_ttl(ttl: CachePointTtl) -> Self
Build a prompt-cache boundary with a per-point TTL.
Sourcepub fn file_url(url: impl Into<String>, media_type: impl Into<String>) -> Self
pub fn file_url(url: impl Into<String>, media_type: impl Into<String>) -> Self
Build a generic file URL content part with an explicit media type.
Sourcepub fn binary(data: impl Into<Vec<u8>>, media_type: impl Into<String>) -> Self
pub fn binary(data: impl Into<Vec<u8>>, media_type: impl Into<String>) -> Self
Build an inline binary content part with an explicit media type.
Sourcepub fn image_bytes(
data: impl Into<Vec<u8>>,
media_type: impl Into<String>,
) -> Self
pub fn image_bytes( data: impl Into<Vec<u8>>, media_type: impl Into<String>, ) -> Self
Build an inline image content part.
Sourcepub fn audio_bytes(
data: impl Into<Vec<u8>>,
media_type: impl Into<String>,
) -> Self
pub fn audio_bytes( data: impl Into<Vec<u8>>, media_type: impl Into<String>, ) -> Self
Build an inline audio content part.
Sourcepub fn video_bytes(
data: impl Into<Vec<u8>>,
media_type: impl Into<String>,
) -> Self
pub fn video_bytes( data: impl Into<Vec<u8>>, media_type: impl Into<String>, ) -> Self
Build an inline video content part.
Sourcepub fn data_url(
data_url: impl Into<String>,
media_type: impl Into<String>,
) -> Self
pub fn data_url( data_url: impl Into<String>, media_type: impl Into<String>, ) -> Self
Build an inline data URL content part with an explicit media type.
Sourcepub fn resource_ref(
uri: impl Into<String>,
media_type: impl Into<String>,
resource_type: impl Into<String>,
) -> Self
pub fn resource_ref( uri: impl Into<String>, media_type: impl Into<String>, resource_type: impl Into<String>, ) -> Self
Build a resource-backed media reference.
Sourcepub fn with_resource_metadata(self, metadata: Metadata) -> Self
pub fn with_resource_metadata(self, metadata: Metadata) -> Self
Attach resource metadata to a resource-backed content part.
Trait Implementations§
Source§impl Clone for ContentPart
impl Clone for ContentPart
Source§fn clone(&self) -> ContentPart
fn clone(&self) -> ContentPart
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more