Skip to main content

Module content

Module content 

Source
Expand description

Content blocks: the building blocks of message bodies and stream deltas.

ContentBlock is the public, forward-compatible enum: it wraps a KnownBlock for any block type the SDK understands, or a raw serde_json::Value for any block type it doesn’t. This means an SDK older than the API will keep round-tripping payloads instead of panicking on a new variant.

§Forward-compat semantics

  • Unknown type tagContentBlock::Other preserving the JSON byte-for-byte.
  • Known type tag with malformed fields → deserialization error (we do not silently fall through, so genuine bugs surface).
use claude_api::messages::content::ContentBlock;

let json = serde_json::json!({"type": "text", "text": "hi"});
let block: ContentBlock = serde_json::from_value(json).unwrap();
assert_eq!(block.type_tag(), Some("text"));

Structs§

CitationConfig
Per-document citation configuration on a KnownBlock::Document.

Enums§

ContentBlock
One block of content within a message.
DocumentSource
Source of bytes for an KnownBlock::Document.
ImageSource
Source of bytes for an KnownBlock::Image.
KnownBlock
All content block variants known to this SDK version.
ToolResultContent
Content payload of a tool_result block.