Skip to main content

Module types

Module types 

Source
Expand description

Claude API Types - Complete request/response model for the Messages API

Every struct here maps 1:1 to the Claude API JSON schema. Optional fields use skip_serializing_if to keep payloads clean.

Key design: ContentBlock is a tagged enum that handles ALL content types (text, image, thinking, tool_use, tool_result) in both requests and responses.

Modules§

models
Current Claude model IDs (as of 2026-03)

Structs§

CacheControl
Prompt caching directive - attach to system blocks, messages, or tools
Message
A single message in the conversation (user or assistant)
MessagesRequest
The main request body sent to POST /v1/messages
MessagesResponse
Full response from POST /v1/messages (non-streaming)
Metadata
Optional metadata for tracking/billing purposes
OutputConfig
Controls output behavior: thinking effort and structured format
SystemBlock
A system block with optional cache_control for prompt caching
Tool
A tool definition telling Claude what functions are available
Usage
Token usage statistics from the API

Enums§

ContentBlock
All possible content block types in request AND response messages.
Effort
How hard Claude should think. Default is High. Max is Opus 4.6 only.
ImageSource
How an image is provided: inline base64 or external URL
MessageContent
Content can be a simple string or an array of typed blocks. The API accepts both forms; responses always use Blocks.
MessageRole
OutputFormat
Structured output format constraint
StopReason
Why Claude stopped generating
SystemContent
System prompt - either a plain string or structured blocks with cache_control. Serde’s untagged tries String first, then Vec.
ThinkingConfig
Controls Claude’s internal reasoning.
ToolChoice
Controls whether/how Claude selects tools
ToolResultContent
Content of a tool result - either a plain string or structured blocks