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.
Trait Implementations§
Source§impl Llm for AnthropicClient
impl Llm for AnthropicClient
fn name(&self) -> &str
fn generate_content<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
stream: bool,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<LlmResponse, AdkError>> + Send>>, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
AnthropicClient: 'async_trait,
Auto Trait Implementations§
impl Freeze for AnthropicClient
impl !RefUnwindSafe for AnthropicClient
impl Send for AnthropicClient
impl Sync for AnthropicClient
impl Unpin for AnthropicClient
impl UnsafeUnpin for AnthropicClient
impl !UnwindSafe for AnthropicClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request