Expand description
Content block types used within Claude messages.
Claude’s protocol carries heterogeneous content as a tagged union. This
module provides the ContentBlock enum (used inside assistant messages)
and UserContent (used when constructing user turns).
§Serde representation
Both enums use an externally-tagged representation via
#[serde(tag = "type", rename_all = "snake_case")], matching the
NDJSON format produced by the Claude Code CLI.
§Example
use claude_cli_sdk::types::content::{UserContent, ContentBlock};
let msg = UserContent::text("Hello, Claude!");
let with_image = UserContent::image_url("https://example.com/img.png", "image/png");Structs§
- Base64
Image Source - Inline base64 image data.
- Image
Block - An image content block, supporting both base64-encoded and URL sources.
- Text
Block - A plain-text content block.
- Thinking
Block - Extended thinking produced by the model (chain-of-thought).
- Tool
Result Block - The result of a tool invocation, returned as part of a user turn.
- Tool
UseBlock - A tool invocation requested by the model.
- UrlImage
Source - A URL-referenced image.
Enums§
- Content
Block - A single block of content within an assistant message.
- Image
Source - The source of an image — either inline base64 data or a remote URL.
- Tool
Result Content - Either a plain string or a list of content blocks — both are valid in the protocol.
- User
Content - Content that can be sent as part of a user turn.
Constants§
- ALLOWED_
IMAGE_ MIME_ TYPES - MIME types accepted by the Claude API for image inputs.
- MAX_
IMAGE_ BASE64_ BYTES - Maximum allowed size for a base64-encoded image payload (15 MiB).