pub enum ContentPart {
Text {
text: String,
provider_options: Option<Value>,
},
Image {
image: Vec<u8>,
media_type: String,
provider_options: Option<Value>,
},
File {
data: Vec<u8>,
media_type: String,
filename: Option<String>,
provider_options: Option<Value>,
},
FileBase64 {
data: String,
media_type: String,
filename: Option<String>,
provider_options: Option<Value>,
},
FileUrl {
url: String,
media_type: String,
provider_options: Option<Value>,
},
FileReference {
media_type: String,
reference: Value,
filename: Option<String>,
provider_options: Option<Value>,
},
Reasoning {
text: String,
signature: Option<String>,
provider_options: Option<Value>,
},
ToolCall {
tool_call_id: String,
tool_name: String,
input: Value,
provider_executed: Option<bool>,
thought_signature: Option<String>,
provider_options: Option<Value>,
},
ToolResult {
tool_call_id: String,
result: Value,
tool_name: Option<String>,
is_error: Option<bool>,
preliminary: Option<bool>,
dynamic: Option<bool>,
provider_options: Option<Value>,
},
}Expand description
A part of a multi-part message.
Shared between ModelMessage (user-facing) and LanguageModelPrompt (provider-facing).
Variants§
Text
A text segment.
Fields
Image
An image (raw bytes + MIME type).
File
A file (raw bytes + MIME type).
FileBase64
A file whose inline data is an already-base64-encoded string.
Mirrors the Vercel AI SDK file part with data: { type: 'data', data: '<base64>' }: the data field holds the raw base64 string verbatim
(it is NOT decoded into bytes), so it round-trips through providers that
emit a base64 source unchanged.
FileUrl
A file referenced by URL.
Mirrors the Vercel AI SDK file part with data: { type: 'url', url }.
FileReference
A file referenced by a provider-specific reference (e.g. an OpenAI file ID).
Mirrors the Vercel AI SDK file part with data: { type: 'reference', reference: { openai: 'file-xxx' } }. The reference field is a JSON
object keyed by provider name.
Reasoning
A reasoning / thinking segment produced by the model.
Mirrors the Vercel AI SDK reasoning part. signature is the Anthropic
thinking-block signature (from providerOptions.anthropic.signature);
when absent the part is treated as having unsupported metadata (unless
providerOptions.anthropic.redactedData is present, in which case a
redacted_thinking block is emitted).
Fields
ToolCall
A tool call requested by the model.
Fields
provider_executed: Option<bool>Whether the tool call is executed by the provider rather than by the client. This is part of the prompt contract because providers need it to replay server tool calls on a later turn.
ToolResult
The result of executing a tool call.
Fields
result: ValueThe tool’s output (usually a JSON value or plain text).
Accepts the legacy output field name (used by the Vercel AI SDK
and the 0.1.0 TypeScript bindings) as an alias during deserialization,
so multi-part tool messages constructed either way round-trip
correctly. Serialization always emits result.
Implementations§
Source§impl ContentPart
impl ContentPart
Sourcepub fn text(text: impl Into<String>) -> Self
pub fn text(text: impl Into<String>) -> Self
Convenience constructor for a text part (no provider options).
Sourcepub fn tool_call(
tool_call_id: impl Into<String>,
tool_name: impl Into<String>,
input: Value,
) -> Self
pub fn tool_call( tool_call_id: impl Into<String>, tool_name: impl Into<String>, input: Value, ) -> Self
Convenience constructor for a tool-call part (no provider options).
Sourcepub fn tool_result(tool_call_id: impl Into<String>, result: Value) -> Self
pub fn tool_result(tool_call_id: impl Into<String>, result: Value) -> Self
Convenience constructor for a tool-result part (no provider options).
Sourcepub fn reasoning(text: impl Into<String>) -> Self
pub fn reasoning(text: impl Into<String>) -> Self
Convenience constructor for a reasoning/thinking part (no provider options, no signature).
Sourcepub fn image(image: Vec<u8>, media_type: impl Into<String>) -> Self
pub fn image(image: Vec<u8>, media_type: impl Into<String>) -> Self
Convenience constructor for an image part (no provider options).
Sourcepub fn file(data: Vec<u8>, media_type: impl Into<String>) -> Self
pub fn file(data: Vec<u8>, media_type: impl Into<String>) -> Self
Convenience constructor for a file part (no provider options, no filename).
Sourcepub fn file_base64(
data: impl Into<String>,
media_type: impl Into<String>,
) -> Self
pub fn file_base64( data: impl Into<String>, media_type: impl Into<String>, ) -> Self
Convenience constructor for a base64-encoded file part (no provider options, no filename).
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
Convenience constructor for a URL-referenced file part (no provider options).
Sourcepub fn file_reference(media_type: impl Into<String>, reference: Value) -> Self
pub fn file_reference(media_type: impl Into<String>, reference: Value) -> Self
Convenience constructor for a provider-referenced file part (no provider options, no filename).
Trait Implementations§
Source§impl Clone for ContentPart
impl Clone for ContentPart
Source§impl Debug for ContentPart
impl Debug for ContentPart
Source§impl<'de> Deserialize<'de> for ContentPart
impl<'de> Deserialize<'de> for ContentPart
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 ContentPart
impl PartialEq for ContentPart
Source§impl Serialize for ContentPart
impl Serialize for ContentPart
impl StructuralPartialEq for ContentPart
Source§impl TS for ContentPart
impl TS for ContentPart
Source§type WithoutGenerics = ContentPart
type WithoutGenerics = ContentPart
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or (). The only requirement for these dummy types is that
EXPORT_TO must be None. Read moreSource§type OptionInnerType = ContentPart
type OptionInnerType = ContentPart
std::option::Option<T>, then this associated type is set to T.
All other implementations of TS should set this type to Self instead.Source§fn docs() -> Option<String>
fn docs() -> Option<String>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§fn decl_concrete(cfg: &Config) -> String
fn decl_concrete(cfg: &Config) -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl(cfg: &Config) -> String
fn decl(cfg: &Config) -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline(cfg: &Config) -> String
fn inline(cfg: &Config) -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened(cfg: &Config) -> String
fn inline_flattened(cfg: &Config) -> String
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<PathBuf>
fn output_path() -> Option<PathBuf>
T should be exported, relative to the output directory.
The returned path does not include any base directory. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
Source§fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export_all. Read moreSource§fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export. Read more