Crate claudius

Crate claudius 

Source
Expand description

Claudius: A Rust client for the Anthropic API.

This crate provides a comprehensive client implementation for interacting with Anthropic’s Claude AI models, including support for streaming responses, tool use, and agent-based interactions.

Structs§

Anthropic
Client for the Anthropic API with performance optimizations.
Base64ImageSource
Represents a base64-encoded image source.
Base64PdfSource
Represents a base64-encoded PDF source.
Budget
Token budget manager for controlling API usage.
CacheControlEphemeral
CacheControlEphemeral specifies that content should be ephemeral, meaning it should not be cached or persisted beyond the immediate request.
CitationCharLocation
Represents a character-based location citation.
CitationContentBlockLocation
Represents a content block-based location citation.
CitationPageLocation
Represents a page-based location citation.
CitationWebSearchResultLocation
Represents a web search result location citation.
CitationsConfig
Configuration for enabling or disabling citations in the response.
CitationsDelta
A delta representing a new citation in a streaming response
ContentBlockDeltaEvent
An event that represents a delta update to a content block in a streaming response.
ContentBlockSourceParam
Parameter for a content block source.
ContentBlockStartEvent
An event that represents the start of a content block in a streaming response.
ContentBlockStopEvent
An event that represents the end of a content block in a streaming response.
DocumentBlock
Parameters for a document block.
ImageBlock
Parameters for an image block.
InputJsonDelta
A JSON delta, representing a piece of JSON in a streaming response.
Message
A message generated by the assistant.
MessageCountTokensParams
Parameters for counting tokens in messages.
MessageCreateParams
Parameters for creating messages.
MessageDelta
The delta information for a message delta event.
MessageDeltaEvent
An event that represents a delta update to a message in a streaming response.
MessageDeltaUsage
Message delta usage information.
MessageParam
Parameters for a message.
MessageStartEvent
An event that represents the start of a message in a streaming response.
MessageStopEvent
An event that represents the end of a message in a streaming response.
MessageTokensCount
Count of tokens in a message.
Metadata
Metadata that can be included with requests.
ModelInfo
Information about a specific model.
ModelListParams
Parameters for listing models.
ModelListResponse
Response from the list models API endpoint.
Mount
A filesystem mount point with associated permissions.
MountHierarchy
Manages a hierarchy of filesystem mount points.
PlainTextSource
A plain text source parameter for content blocks.
RedactedThinkingBlock
A redacted thinking block that contains encoded/obscured thinking data.
ServerToolUsage
Information about server tool usage for a message.
ServerToolUseBlock
A block representing a server-side tool use request from the model.
SignatureDelta
A signature delta, representing a piece of a signature in a streaming response.
TextBlock
A block of text content in a message.
TextDelta
A text delta, representing a piece of text in a streaming response.
ThinkingBlock
A block containing model thinking details.
ThinkingDelta
A thinking delta, representing a piece of thinking in a streaming response.
ToolBash20241022
Parameters for the Bash tool type, version 20241022.
ToolBash20250124
Parameters for the Bash tool type, version 20250124.
ToolParam
Common parameters for a custom tool.
ToolResultBlock
A block containing the result of a tool execution.
ToolSearchFileSystem
Tool for searching the local filesystem.
ToolTextEditor20250124
Parameters for the Text Editor tool type, version 20250124.
ToolTextEditor20250429
Parameters for the Text Editor tool type, version 20250429.
ToolTextEditor20250728
Parameters for the Text Editor tool type, version 20250728.
ToolUseBlock
A block representing a tool use request from the model.
UrlImageSource
A source for an image from a URL.
UrlPdfSource
A source for a PDF from a URL.
Usage
Usage information for API calls.
UserLocation
Parameters for the user’s location.
WebSearchResultBlock
A block containing a web search result.
WebSearchTool20250305
Parameters for the web search tool.
WebSearchToolResultBlock
A block containing the results of a web search tool operation.
WebSearchToolResultError
An error that occurred when using the web search tool.

Enums§

Citation
Represents a citation object that could be any of the supported citation types
Content
A content type that can be either a text block or an image block.
ContentBlock
A block of content in a message.
ContentBlockDelta
A raw content block delta, representing a streaming update to a content block.
ContentBlockSourceContent
The content of a content block source, which can be either a string or an array of content items.
DocumentSource
The source type for a document block, which can be one of several types.
Error
The main error type for the Claudius SDK.
ImageMediaType
Supported image media types
ImageSource
The source type for an image block, which can be either Base64 encoded or a URL.
KnownModel
Known Anthropic model versions
MessageParamContent
The content of a message, which can be either a string or an array of content blocks.
MessageRole
Role type for a message parameter.
MessageStreamEvent
An event in a message stream.
Model
Represents an Anthropic model identifier.
ModelType
Type of the model object.
StopReason
Reasons why the model stopped generating a response.
SystemPrompt
Represents either a string or an array of TextBlockParam for system prompts.
TextCitation
A citation reference in a TextBlock.
ThinkingConfig
Configuration for enabling Claude’s extended thinking capabilities.
ToolChoice
Configuration for Claude’s tool choice behavior.
ToolResultBlockContent
The content of a tool result block, which can be either a string or an array of content items.
ToolUnionParam
Union type for different tool parameter types.
WebSearchErrorCode
Error codes that can be returned when a web search tool operation fails.
WebSearchToolResultBlockContent
Content of a web search tool result.

Traits§

Agent
Trait for implementing agents that interact with the Anthropic API.
FileSystem
Trait for implementing filesystem operations.
IntermediateToolResult
Trait for intermediate tool results that can be passed between compute and apply phases.
JsonSchema
Implement JsonSchema to derive the schema for GenerateRequest automatically.
Tool
Trait for tools that can be used by agents.
ToolCallback
Callback trait for implementing tool execution logic.

Functions§

merge_message_content
Merges new message content into existing message content.
push_or_merge_message
Pushes a message to the messages vector, or merges it with the last message if they have the same role.

Type Aliases§

Result
A specialized Result type for Claudius operations.
ToolResult
Result type for tool execution, using ControlFlow for early returns.