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
typetag →ContentBlock::Otherpreserving the JSON byte-for-byte. - Known
typetag 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§
- Citation
Config - Per-document citation configuration on a
KnownBlock::Document.
Enums§
- Content
Block - One block of content within a message.
- Document
Source - Source of bytes for an
KnownBlock::Document. - Image
Source - Source of bytes for an
KnownBlock::Image. - Known
Block - All content block variants known to this SDK version.
- Tool
Result Content - Content payload of a
tool_resultblock.