Skip to main content

Module content

Module content 

Source
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§

Base64ImageSource
Inline base64 image data.
ImageBlock
An image content block, supporting both base64-encoded and URL sources.
TextBlock
A plain-text content block.
ThinkingBlock
Extended thinking produced by the model (chain-of-thought).
ToolResultBlock
The result of a tool invocation, returned as part of a user turn.
ToolUseBlock
A tool invocation requested by the model.
UrlImageSource
A URL-referenced image.

Enums§

ContentBlock
A single block of content within an assistant message.
ImageSource
The source of an image — either inline base64 data or a remote URL.
ToolResultContent
Either a plain string or a list of content blocks — both are valid in the protocol.
UserContent
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).