pub enum ContentBlock {
Show 14 variants
Text {
text: String,
cache_control: Option<CacheControl>,
citations: Option<Vec<Citation>>,
},
Image {
source: ImageSource,
cache_control: Option<CacheControl>,
},
Document {
source: DocumentSource,
title: Option<String>,
context: Option<String>,
citations: Option<CitationConfig>,
cache_control: Option<CacheControl>,
},
ToolUse {
id: String,
name: String,
input: Value,
caller: Option<String>,
cache_control: Option<CacheControl>,
},
ToolResult {
tool_use_id: String,
content: Option<ToolResultContent>,
is_error: Option<bool>,
},
Thinking {
thinking: String,
signature: Option<String>,
},
RedactedThinking {
data: String,
},
SearchResult {
source: String,
title: String,
content: Vec<TextBlock>,
citations: Option<CitationConfig>,
cache_control: Option<CacheControl>,
},
ServerToolUse {
id: String,
name: String,
input: Value,
cache_control: Option<CacheControl>,
},
WebSearchToolResult {
tool_use_id: String,
content: Value,
cache_control: Option<CacheControl>,
},
CodeExecutionToolResult {
tool_use_id: String,
content: Value,
cache_control: Option<CacheControl>,
},
ContainerUpload {
file_id: String,
cache_control: Option<CacheControl>,
},
MidConvSystem {
content: Vec<TextBlock>,
cache_control: Option<CacheControl>,
},
Unknown {
block_type: String,
data: Value,
},
}Expand description
Content block in a message
Known content block types are deserialized into their respective variants.
Unrecognized types (e.g., new API features) are captured in ContentBlock::Unknown
instead of causing a deserialization error.
Variants§
Text
Text content
Fields
cache_control: Option<CacheControl>Image
Image content
Document
Document content (PDFs, text files)
Requires beta header: anthropic-beta: files-api-2025-04-14
ToolUse
Tool use request from the assistant
Fields
cache_control: Option<CacheControl>ToolResult
Tool result from the user
Thinking
Thinking block from extended thinking
Contains Claude’s step-by-step reasoning process. Appears when extended thinking is enabled.
RedactedThinking
Redacted thinking block
Contains encrypted thinking that was flagged by safety systems. Must be passed back unmodified in multi-turn conversations.
SearchResult
Search result for RAG with automatic citations
Supported in: Opus 4.5, Opus 4.1, Opus 4, Sonnet 4.5, Sonnet 4, Haiku 3.5
ServerToolUse
Server-side tool invocation
WebSearchToolResult
Web search tool result
CodeExecutionToolResult
Code execution tool result
ContainerUpload
File uploaded to a container during code execution
MidConvSystem
System instruction injected mid-conversation
Unknown
Unknown content block type (forward compatibility)
When the API returns a content block type this SDK doesn’t recognize, it’s captured here rather than causing a deserialization error.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
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 ContentBlock
impl Debug for ContentBlock
Source§impl<'de> Deserialize<'de> for ContentBlock
impl<'de> Deserialize<'de> for ContentBlock
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>,
Auto Trait Implementations§
impl Freeze for ContentBlock
impl RefUnwindSafe for ContentBlock
impl Send for ContentBlock
impl Sync for ContentBlock
impl Unpin for ContentBlock
impl UnsafeUnpin for ContentBlock
impl UnwindSafe for ContentBlock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more