Crate misanthropy

Crate misanthropy 

Source
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.
ApiErrorResponse
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.
MessageDelta
Incremental update to a message in a streaming response. Contains changes to the stop reason and stop sequence.
MessagesRequest
A request to the Anthropic API for message generation.
MessagesResponse
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.
StreamError
An error that has occurred as part of a stream.
StreamedResponse
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.
ThinkingContent
Thinking content in a message.
ToolResult
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§

ApiErrorType
Represents the types of errors that can be returned by the Anthropic API.
CacheControl
Represents cache control options for conversation blocks.
Content
A piece of content in a message.
ContentBlockDelta
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.
StopReason
Represents the reason why the model stopped generating content.
StreamEvent
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.
ToolChoice
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.