pub struct AnthropicApiClient { /* private fields */ }
Expand description
Anthropic API client for Claude Code usage statistics
Note: This client provides a wrapper around Anthropic’s API with mock implementations for usage statistics, billing, and rate limit endpoints that are not publicly available. The client can still be used for actual API calls to supported endpoints.
Implementations§
Source§impl AnthropicApiClient
impl AnthropicApiClient
Sourcepub fn new(config: AnthropicConfig) -> Result<Self>
pub fn new(config: AnthropicConfig) -> Result<Self>
Create a new Anthropic API client
Sourcepub fn with_cache(self, cache: Arc<FileCache>) -> Self
pub fn with_cache(self, cache: Arc<FileCache>) -> Self
Enable caching with the specified cache instance
Sourcepub fn with_usage_tracking(self) -> Self
pub fn with_usage_tracking(self) -> Self
Enable local usage tracking
Sourcepub fn usage_tracker(&self) -> Option<&Arc<LocalUsageTracker>>
pub fn usage_tracker(&self) -> Option<&Arc<LocalUsageTracker>>
Get the usage tracker if enabled
Sourcepub async fn fetch_usage_stats(
&self,
start_time: DateTime<Utc>,
end_time: DateTime<Utc>,
) -> Result<AnthropicUsageStats>
pub async fn fetch_usage_stats( &self, start_time: DateTime<Utc>, end_time: DateTime<Utc>, ) -> Result<AnthropicUsageStats>
Fetch usage statistics for the specified period
Note: Anthropic’s API does not provide public usage statistics endpoints. If local usage tracking is enabled, this returns tracked data. Otherwise, it returns mock data explaining the limitation.
Sourcepub async fn fetch_rate_limit_info(&self) -> Result<RateLimitInfo>
pub async fn fetch_rate_limit_info(&self) -> Result<RateLimitInfo>
Fetch current rate limit information
Note: Anthropic’s API does not provide public rate limit endpoints. This method returns estimated rate limits based on known service tier limits. Rate limits are enforced through response headers and HTTP 429 responses.
Sourcepub async fn fetch_billing_info(
&self,
start_time: DateTime<Utc>,
end_time: DateTime<Utc>,
) -> Result<CostBreakdown>
pub async fn fetch_billing_info( &self, start_time: DateTime<Utc>, end_time: DateTime<Utc>, ) -> Result<CostBreakdown>
Fetch billing information
Note: Anthropic’s API does not provide public billing endpoints. This method returns a mock implementation that explains the limitation. For actual billing information, use the Anthropic Console at console.anthropic.com.
Sourcepub async fn health_check(&self) -> Result<bool>
pub async fn health_check(&self) -> Result<bool>
Test API connectivity by making a minimal API call
Note: Anthropic’s API does not have a dedicated health endpoint. This method tests connectivity by making a token counting request.
Trait Implementations§
Source§impl Clone for AnthropicApiClient
impl Clone for AnthropicApiClient
Source§fn clone(&self) -> AnthropicApiClient
fn clone(&self) -> AnthropicApiClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more