Usage

Usage statistics, request logs, and dashboards.

Track your usage, costs, and performance across all providers.

Get Usage Summary

summary = client.usage.get(period="month")  # "day" | "week" | "month" | "year"
 
print(f"Total requests: {summary.total_requests}")
print(f"Cache hit rate: {summary.cache_hit_rate:.1f}%")
print(f"Total cost: ${summary.total_billed_cost:.6f}")
print(f"By provider: {summary.by_provider}")

UsageSummary Properties

PropertyPythonJavaScriptDescription
Period startperiod_startperiodStartStart of the period
Period endperiod_endperiodEndEnd of the period
Total requeststotal_requeststotalRequestsTotal number of requests
Successfulsuccessful_requestssuccessfulRequestsSuccessful requests
Failedfailed_requestsfailedRequestsFailed requests
Cachedcached_requestscachedRequestsRequests served from cache
Provider costtotal_provider_costtotalProviderCostTotal cost paid to providers
Billed costtotal_billed_costtotalBilledCostTotal cost billed to you
Savingstotal_savingstotalSavingsSavings from cache hits
Cache hit ratecache_hit_ratecacheHitRateCache hit rate (%)
By providerby_providerbyProviderRequest counts by provider
By modelby_modelbyModelRequest counts by model

Request Logs

logs = client.usage.logs(limit=50)

Dashboard

dashboard = client.usage.dashboard(period="week")

Track Downloads (JavaScript)

await client.usage.trackDownload("request-id", "https://...", {
  mediaType: "image",
});

On this page