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.
- Base64
Image Source - Represents a base64-encoded image source.
- Base64
PdfSource - Represents a base64-encoded PDF source.
- Budget
- Token budget manager for controlling API usage.
- Cache
Control Ephemeral - CacheControlEphemeral specifies that content should be ephemeral, meaning it should not be cached or persisted beyond the immediate request.
- Citation
Char Location - Represents a character-based location citation.
- Citation
Content Block Location - Represents a content block-based location citation.
- Citation
Page Location - Represents a page-based location citation.
- Citation
WebSearch Result Location - Represents a web search result location citation.
- Citations
Config - Configuration for enabling or disabling citations in the response.
- Citations
Delta - A delta representing a new citation in a streaming response
- Content
Block Delta Event - An event that represents a delta update to a content block in a streaming response.
- Content
Block Source Param - Parameter for a content block source.
- Content
Block Start Event - An event that represents the start of a content block in a streaming response.
- Content
Block Stop Event - An event that represents the end of a content block in a streaming response.
- Document
Block - Parameters for a document block.
- Image
Block - Parameters for an image block.
- Input
Json Delta - A JSON delta, representing a piece of JSON in a streaming response.
- Message
- A message generated by the assistant.
- Message
Count Tokens Params - Parameters for counting tokens in messages.
- Message
Create Params - Parameters for creating messages.
- Message
Delta - The delta information for a message delta event.
- Message
Delta Event - An event that represents a delta update to a message in a streaming response.
- Message
Delta Usage - Message delta usage information.
- Message
Param - Parameters for a message.
- Message
Start Event - An event that represents the start of a message in a streaming response.
- Message
Stop Event - An event that represents the end of a message in a streaming response.
- Message
Tokens Count - Count of tokens in a message.
- Metadata
- Metadata that can be included with requests.
- Model
Info - Information about a specific model.
- Model
List Params - Parameters for listing models.
- Model
List Response - Response from the list models API endpoint.
- Mount
- A filesystem mount point with associated permissions.
- Mount
Hierarchy - Manages a hierarchy of filesystem mount points.
- Plain
Text Source - A plain text source parameter for content blocks.
- Redacted
Thinking Block - A redacted thinking block that contains encoded/obscured thinking data.
- Server
Tool Usage - Information about server tool usage for a message.
- Server
Tool UseBlock - A block representing a server-side tool use request from the model.
- Signature
Delta - A signature delta, representing a piece of a signature in a streaming response.
- Text
Block - A block of text content in a message.
- Text
Delta - A text delta, representing a piece of text in a streaming response.
- Thinking
Block - A block containing model thinking details.
- Thinking
Delta - A thinking delta, representing a piece of thinking in a streaming response.
- Tool
Bash20241022 - Parameters for the Bash tool type, version 20241022.
- Tool
Bash20250124 - Parameters for the Bash tool type, version 20250124.
- Tool
Param - Common parameters for a custom tool.
- Tool
Result Block - A block containing the result of a tool execution.
- Tool
Search File System - Tool for searching the local filesystem.
- Tool
Text Editor20250124 - Parameters for the Text Editor tool type, version 20250124.
- Tool
Text Editor20250429 - Parameters for the Text Editor tool type, version 20250429.
- Tool
Text Editor20250728 - Parameters for the Text Editor tool type, version 20250728.
- Tool
UseBlock - A block representing a tool use request from the model.
- UrlImage
Source - A source for an image from a URL.
- UrlPdf
Source - A source for a PDF from a URL.
- Usage
- Usage information for API calls.
- User
Location - Parameters for the user’s location.
- WebSearch
Result Block - A block containing a web search result.
- WebSearch
Tool20250305 - Parameters for the web search tool.
- WebSearch
Tool Result Block - A block containing the results of a web search tool operation.
- WebSearch
Tool Result Error - 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.
- Content
Block - A block of content in a message.
- Content
Block Delta - A raw content block delta, representing a streaming update to a content block.
- Content
Block Source Content - The content of a content block source, which can be either a string or an array of content items.
- Document
Source - The source type for a document block, which can be one of several types.
- Error
- The main error type for the Claudius SDK.
- Image
Media Type - Supported image media types
- Image
Source - The source type for an image block, which can be either Base64 encoded or a URL.
- Known
Model - Known Anthropic model versions
- Message
Param Content - The content of a message, which can be either a string or an array of content blocks.
- Message
Role - Role type for a message parameter.
- Message
Stream Event - An event in a message stream.
- Model
- Represents an Anthropic model identifier.
- Model
Type - Type of the model object.
- Stop
Reason - Reasons why the model stopped generating a response.
- System
Prompt - Represents either a string or an array of TextBlockParam for system prompts.
- Text
Citation - A citation reference in a TextBlock.
- Thinking
Config - Configuration for enabling Claude’s extended thinking capabilities.
- Tool
Choice - Configuration for Claude’s tool choice behavior.
- Tool
Result Block Content - The content of a tool result block, which can be either a string or an array of content items.
- Tool
Union Param - Union type for different tool parameter types.
- WebSearch
Error Code - Error codes that can be returned when a web search tool operation fails.
- WebSearch
Tool Result Block Content - Content of a web search tool result.
Traits§
- Agent
- Trait for implementing agents that interact with the Anthropic API.
- File
System - Trait for implementing filesystem operations.
- Intermediate
Tool Result - Trait for intermediate tool results that can be passed between compute and apply phases.
- Json
Schema - Implement JsonSchema to derive the schema for GenerateRequest automatically.
- Tool
- Trait for tools that can be used by agents.
- Tool
Callback - 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.
- Tool
Result - Result type for tool execution, using ControlFlow for early returns.