pub enum AnthropicContentBlock {
Text {
text: String,
citations: Option<Vec<Value>>,
cache_control: Option<CacheControl>,
},
Image {
source: AnthropicImageSource,
},
ToolUse {
id: String,
name: String,
input: Value,
cache_control: Option<CacheControl>,
},
ToolResult {
tool_use_id: String,
content: Option<ToolResultContent>,
is_error: Option<bool>,
cache_control: Option<CacheControl>,
},
Thinking {
thinking: String,
signature: String,
cache_control: Option<CacheControl>,
},
RedactedThinking {
data: String,
},
ServerToolUse {
id: String,
name: String,
input: Value,
},
WebSearchToolResult {
tool_use_id: String,
content: Value,
},
Other(Value),
}Expand description
A single content block within a message.
Uses a custom deserializer so that unknown block types (e.g. citations,
server_tool_use, redacted_thinking) are captured as Other(Value) instead
of causing a hard deserialization failure. This is important because Claude
Code may send block types that we don’t yet handle.
Variants§
Text
Text content block. May optionally include citations – references to
source documents that support the text content. Citations are generated
by the model when document/PDF content is provided and citation mode is enabled.
Image
Image content block.
Fields
source: AnthropicImageSourceToolUse
Tool use request from assistant.
ToolResult
Tool result from user.
Thinking
Thinking content block from assistant (extended thinking / reasoning).
RedactedThinking
Redacted thinking block from assistant. Contains encrypted reasoning data that is opaque to the client but must be passed back verbatim in multi-turn conversations so the model can maintain its chain of thought.
ServerToolUse
Server-initiated tool use block. Represents a tool call that the API
executes server-side (e.g., web search). The client receives the result
via a corresponding web_search_tool_result or similar block.
WebSearchToolResult
Result from a server-initiated tool (e.g., web search results). Contains structured content returned by the server-side tool execution.
Other(Value)
Catch-all for unrecognized block types. Preserves the full JSON value so that new Anthropic features don’t break the endpoint and can be round-tripped or inspected.
Trait Implementations§
Source§impl Clone for AnthropicContentBlock
impl Clone for AnthropicContentBlock
Source§fn clone(&self) -> AnthropicContentBlock
fn clone(&self) -> AnthropicContentBlock
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 AnthropicContentBlock
impl Debug for AnthropicContentBlock
Source§impl<'de> Deserialize<'de> for AnthropicContentBlock
Custom deserializer for AnthropicContentBlock that handles unknown types
gracefully. Since serde’s #[serde(other)] is not supported on internally
tagged enums, we deserialize as Value first and dispatch manually.
impl<'de> Deserialize<'de> for AnthropicContentBlock
Custom deserializer for AnthropicContentBlock that handles unknown types
gracefully. Since serde’s #[serde(other)] is not supported on internally
tagged enums, we deserialize as Value first and dispatch manually.