Expand description
§adk-anthropic
Dedicated Anthropic API client for ADK-Rust.
This crate provides the HTTP client, type system, SSE streaming, error handling, and backoff logic for interacting with the Anthropic API. Agent framework, CLI tools, chat session management, and observability are handled by other ADK crates.
Modules§
- pricing
- Token pricing for Anthropic models.
Structs§
- Accumulating
Stream - A stream wrapper that accumulates
MessageStreamEvents into a completeMessage. - Anthropic
- Client for the Anthropic API with performance optimizations.
- ApiError
- An API error object for stream error events.
- Auto
Cache Control - Automatic cache control configuration.
- Base64
Image Source - Represents a base64-encoded image source.
- Base64
PdfSource - Represents a base64-encoded PDF source.
- Batch
Error - An error object returned in batch results.
- Batch
Request - A batch request to be submitted.
- Batch
Request Counts - Counts of batch requests in each processing state.
- Batch
Result Item - A single result item from a completed batch.
- Cache
Control Ephemeral - CacheControlEphemeral specifies that content should be cached ephemerally.
- Cache
Ttl - TTL configuration for cache control.
- 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
- Code
Execution Result Block - Code execution tool output block.
- Compaction
Metadata - Metadata about a compaction event (emitted during SSE streaming).
- Container
Info - Container information returned in message responses.
- 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.
- Context
Management - Server-side context management configuration.
- Context
Management Response - Response field showing which edits were applied.
- Document
Block - Parameters for a document block.
- Exponential
Backoff - File
Object - A file object returned by the Files API.
- File
Source - A file source referencing a server-side file by ID.
- Image
Block - Parameters for an image block.
- Input
Json Delta - A JSON delta, representing a piece of JSON in a streaming response.
- Logging
Stream - A stream wrapper that logs events and the final message through a
ClientLogger. - Message
- A message generated by the assistant.
- Message
Batch - A message batch object returned by the Batches API.
- Message
Count Tokens Params - Parameters for counting tokens in messages.
- Message
Create Params - Parameters for creating messages.
- Message
Create Template - A template for creating message parameters.
- 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
Capabilities - Per-model capability flags.
- Model
Info - Information about a specific model.
- Model
List Params - Parameters for listing models.
- Model
List Response - Response from the list models API endpoint.
- Output
Config - Wrapper for structured output configuration.
- Paginated
List - A generic paginated list response.
- Plain
Text Source - A plain text source parameter for content blocks.
- Programmatic
Tool UseBlock - Programmatic tool invocation from code execution.
- 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.
- Skill
Object - A skill object returned by the Skills API.
- Skill
Ref - A reference to a skill for use in message requests.
- 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.
- Token
Threshold - Threshold specification used in trigger / keep / clear_at_least.
- 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 Config - Provider-level configuration for regex-based dynamic tool discovery.
- 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§
- Applied
Edit - A single applied edit in the response.
- Batch
Result - The result of a single batch request.
- 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.
- Context
Edit - A single context editing strategy.
- Document
Source - The source type for a document block, which can be one of several types.
- Effort
Level - Effort parameter controlling response thoroughness.
Passed via
output_config.effort. GA, no beta header required. - Error
- The main error type for the adk-anthropic client.
- Image
Media Type - Supported image media types
- Image
Source - The source type for an image block, which can be either Base64 encoded, a URL, or a file reference.
- 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.
- Output
Format - Output format configuration for structured outputs.
- Server
Tool - Built-in server tool types with forward-compatible Unknown catch-all.
- Speed
Mode - Speed mode for latency-critical workloads (research preview).
- 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 - Unified thinking configuration covering all modes.
- Thinking
Display - Controls whether thinking content appears in the response.
- Thinking
Keep - How many thinking turns to keep.
- 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.
Constants§
- MAX_
CACHE_ BREAKPOINTS - Maximum number of cache control breakpoints allowed by the API.
Traits§
- Client
Logger - A trait for logging Anthropic client operations.
- Json
Schema - Implement JsonSchema to derive the schema for GenerateRequest automatically.
Functions§
- apply_
cache_ control_ to_ messages - Applies cache_control markers to the last content block of up to N user messages.
- count_
system_ cache_ controls - Count cache_control markers present in the system prompt.
- merge_
message_ content - Merges new message content into existing message content.
- prune_
cache_ controls_ in_ messages - Remove cache_control markers so the latest N remain in the request.
- 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 adk-anthropic operations.