Expand description
Rust client for the Anthropic API.
Modules§
- tools
- Type definitions for built-in tool use
Structs§
- Anthropic
- Client for interacting with the Anthropic API. Manages authentication and default parameters for requests.
- ApiError
- Contains detailed information about an error returned by the Anthropic API.
- ApiError
Response - The top-level error structure returned by the Anthropic API. Includes a nested ApiError with more details.
- Image
- An image with its source information in a message.
- Message
- A single message in a conversation, with a role and content.
- Message
Delta - Incremental update to a message in a streaming response. Contains changes to the stop reason and stop sequence.
- Messages
Request - A request to the Anthropic API for message generation.
- Messages
Response - The response from the Anthropic API for a message request. Contains generated content, message metadata, and usage statistics.
- Metadata
- Metadata for tracking user interactions.
- Source
- Metadata for an image in a message.
- Stream
Error - An error that has occurred as part of a stream.
- Streamed
Response - Manages a streamed response from the Anthropic API for message generation.
- Text
- Textual content in a message.
- Thinking
- Configuration for enabling Claude’s extended thinking mode.
- Thinking
Content - Thinking content in a message.
- Tool
Result - A response to a tool used by the AI model during a conversation. Should be supplied in a user message.
- ToolUse
- A tool used by the AI model during a conversation. Should be supplied in an assistant message.
- Usage
- Token usage statistics for a message.
Enums§
- ApiError
Type - Represents the types of errors that can be returned by the Anthropic API.
- Cache
Control - Represents cache control options for conversation blocks.
- Content
- A piece of content in a message.
- Content
Block Delta - An incremental update to a content block in a streaming response. Can be either a text delta or a partial JSON update.
- Error
- Errors encountered during Anthropic API interactions. Covers API responses, HTTP issues, parsing failures, and client-side problems.
- Role
- The role of a participant in a conversation. Can be either a user or an assistant.
- Stop
Reason - Represents the reason why the model stopped generating content.
- Stream
Event - An event in the streaming response from the Anthropic API.
- Tool
- Represents a tool that can be used by the AI model in a conversation.
- Tool
Choice - Specifies how the AI model should choose and use tools in a conversation. Can be set to automatic, any tool, or a specific tool.
Constants§
- ANTHROPIC_
API_ KEY_ ENV - Environment variable name for the Anthropic API key.
- ANTHROPIC_
API_ VERSION - Version of the Anthropic API used in requests.
- DEFAULT_
MAX_ TOKENS - Default maximum number of tokens for AI model responses.
- DEFAULT_
MODEL - Default Anthropic AI model identifier used for API requests.
- TEXT_
EDITOR_ 4 - Name of the built-in text editor tool for Claude 4
- TEXT_
EDITOR_ 35 - Name of the built-in text editor tool for Claude 3.5
- TEXT_
EDITOR_ 37 - Name of the built-in text editor tool for Claude 3.7
- TEXT_
EDITOR_ NAME_ 3 - Name of the built-in text editor tool for Claude 3.x
- TEXT_
EDITOR_ NAME_ 4 - Name of the built-in text editor tool for Claude 4.x
Type Aliases§
- Result
- Convenience type alias for Results using the crate’s Error type.