pub struct AnthropicClient { /* private fields */ }models only.Expand description
Anthropic client for Claude models.
Implementations§
Source§impl AnthropicClient
impl AnthropicClient
Sourcepub fn new(config: AnthropicConfig) -> Result<AnthropicClient, AdkError>
Available on crate feature anthropic only.
pub fn new(config: AnthropicConfig) -> Result<AnthropicClient, AdkError>
anthropic only.Create a new Anthropic client.
Sourcepub fn from_api_key(
api_key: impl Into<String>,
) -> Result<AnthropicClient, AdkError>
Available on crate feature anthropic only.
pub fn from_api_key( api_key: impl Into<String>, ) -> Result<AnthropicClient, AdkError>
anthropic only.Create a client with just an API key (uses default model).
Sourcepub fn inner(&self) -> &Anthropic
Available on crate feature anthropic only.
pub fn inner(&self) -> &Anthropic
anthropic only.Access the underlying adk_anthropic::Anthropic HTTP client.
Use this for direct API access to endpoints not covered by the Llm trait:
batches, files, skills, models, token counting, and pricing.
let inner = anthropic_client.inner();
let models = inner.list_models(None).await?;
let batch = inner.create_batch(requests).await?;Sourcepub fn anthropic_config(&self) -> &AnthropicConfig
Available on crate feature anthropic only.
pub fn anthropic_config(&self) -> &AnthropicConfig
anthropic only.Access the current Anthropic configuration.
pub fn with_retry_config(self, retry_config: RetryConfig) -> AnthropicClient
anthropic only.pub fn set_retry_config(&mut self, retry_config: RetryConfig)
anthropic only.pub fn retry_config(&self) -> &RetryConfig
anthropic only.Sourcepub async fn latest_rate_limit_info(&self) -> RateLimitInfo
Available on crate feature anthropic only.
pub async fn latest_rate_limit_info(&self) -> RateLimitInfo
anthropic only.Returns the latest rate-limit information from the most recent API response.
Updated after each API call when the server provides rate-limit headers
via adk_anthropic::Error::RateLimit or adk_anthropic::Error::ServiceUnavailable.
Returns the default (all None) if no rate-limit info has been received.
Source§impl AnthropicClient
impl AnthropicClient
Sourcepub async fn list_models(&self) -> Result<Vec<ModelInfo>, AdkError>
Available on crate feature anthropic only.
pub async fn list_models(&self) -> Result<Vec<ModelInfo>, AdkError>
anthropic only.List available Claude models.
Calls GET /v1/models and returns all model descriptors from the
first page. For paginated access, use list_models_paginated.
§Errors
Returns AdkError::Model with structured error context if the
API returns an error.
Sourcepub async fn get_model(&self, model_id: &str) -> Result<ModelInfo, AdkError>
Available on crate feature anthropic only.
pub async fn get_model(&self, model_id: &str) -> Result<ModelInfo, AdkError>
anthropic only.Get details for a specific model.
Calls GET /v1/models/{model_id} and returns the model descriptor.
§Errors
Returns AdkError::Model with structured error context if the
API returns an error (e.g., model not found).
Source§impl AnthropicClient
impl AnthropicClient
Sourcepub async fn count_tokens(
&self,
request: &LlmRequest,
) -> Result<TokenCount, AdkError>
Available on crate feature anthropic only.
pub async fn count_tokens( &self, request: &LlmRequest, ) -> Result<TokenCount, AdkError>
anthropic only.Count tokens for a request without generating a response.
Calls POST /v1/messages/count_tokens using the same request
construction as generate_content, so system prompt extraction,
multimodal mapping, and tool conversion all apply.
§Errors
Returns AdkError::Model with structured error context if the
API returns an error, consistent with the messages API.