Usage and Cost API
Programmatically access your organization’s API usage and cost data with the Usage & Cost Admin API.
The Admin API is unavailable for individual accounts. To collaborate with teammates and add members, set up your organization in Console → Settings → Organization.
The Usage & Cost Admin API provides programmatic and granular access to historical API usage and cost data for your organization. This data is similar to the information available in the Usage and Cost pages of the Anthropic Console.
This API enables you to better monitor, analyze, and optimize your Claude implementations:
- Accurate Usage Tracking: Get precise token counts and usage patterns instead of relying soley on response token counting
- Cost Reconciliation: Match internal records with Anthropic billing for finance and accounting teams
- Product performance and improvement: Monitor product performance while measuring if changes to the system have improved it, or setup alerting
- Rate limit and Priority Tier optimization: Optimize features like prompt caching or specific prompts to make the most of one’s allocated capacity, or purchase dedicated capacity.
- Advanced Analysis: Perform deeper data analysis than what’s available in Console
Admin API key required
This API is part of the Admin API. These endpoints require an Admin API key (starting with sk-ant-admin...
) that differs from standard API keys. Only organization members with the admin role can provision Admin API keys through the Anthropic Console.
Partner solutions
Leading observability platforms offer ready-to-use integrations for monitoring your Claude API usage and cost, without writing custom code. These integrations provide dashboards, alerting, and analytics to help you manage your API usage effectively.
Datadog
LLM Observability with automatic tracing and monitoring
Grafana
Dashboard creation and incident management via MCP (Coming soon)
Honeycomb
Advanced querying and visualization through OpenTelemetry
Quick start
Get your organization’s daily usage for the last 7 days:
Set a User-Agent header for integrations
If you’re building an integration, set your User-Agent header to help us understand usage patterns:
Usage API
Track token consumption across your organization with detailed breakdowns by model, workspace, and service tier with the /v1/organizations/usage_report/messages
endpoint.
Key concepts
- Time buckets: Aggregate usage data in fixed intervals (
1m
,1h
, or1d
) - Token tracking: Measure uncached input, cached input, cache creation, and output tokens
- Filtering & grouping: Filter by API key, workspace, model, service tier, or context window, and group results by these dimensions
- Server tool usage: Track usage of server-side tools like web search
For complete parameter details and response schemas, see the Usage API reference.
Basic examples
Daily usage by model
Hourly usage with filtering
Time granularity limits
Granularity | Default Limit | Maximum Limit | Use Case |
---|---|---|---|
1m | 60 buckets | 1440 buckets | Real-time monitoring |
1h | 24 buckets | 168 buckets | Daily patterns |
1d | 7 buckets | 31 buckets | Weekly/monthly reports |
Cost API
Retrieve service-level cost breakdowns in USD with the /v1/organizations/cost_report
endpoint.
Key concepts
- Currency: All costs in USD, reported as decimal strings in lowest units (cents)
- Cost types: Track token usage, web search, and code execution costs
- Grouping: Group costs by workspace or description for detailed breakdowns
- Time buckets: Daily granularity only (
1d
)
For complete parameter details and response schemas, see the Cost API reference.
Priority Tier costs use a different billing model and are not included in the cost endpoint. Track Priority Tier usage through the usage endpoint instead.
Basic example
Pagination
Both endpoints support pagination for large datasets:
- Make your initial request
- If
has_more
istrue
, use thenext_page
value in your next request - Continue until
has_more
isfalse
Common use cases
Explore detailed implementations in anthropic-cookbook:
- Daily usage reports: Track token consumption trends
- Cost attribution: Allocate expenses by workspace for chargebacks
- Cache efficiency: Measure and optimize prompt caching
- Budget monitoring: Set up alerts for spending thresholds
- CSV export: Generate reports for finance teams
Frequently asked questions
How fresh is the data?
Usage and cost data typically appears within 5 minutes of API request completion, though delays may occasionally be longer.
What’s the recommended polling frequency?
The API supports polling once per minute for sustained use. For short bursts (e.g., downloading paginated data), more frequent polling is acceptable. Cache results for dashboards that need frequent updates.
How do I track code execution usage?
Code execution costs appear in the cost endpoint grouped under Code Execution Usage
in the description field. Code execution is not included in the usage endpoint.
How do I track Priority Tier usage?
Filter or group by service_tier
in the usage endpoint and look for the priority
value. Priority Tier costs are not available in the cost endpoint.
What happens with Workbench usage?
API usage from the Workbench is not associated with an API key, so api_key_id
will be null
even when grouping by that dimension.
How is the default workspace represented?
Usage and costs attributed to the default workspace have a null
value for workspace_id
.
See also
The Usage and Cost APIs can be used to help you deliver a better experience for your users, help you manage costs, and preserve your rate limit. Learn more about some of these other features:
- Admin API overview
- Admin API reference
- Pricing
- Prompt caching - Optimize costs with caching
- Batch processing - 50% discount on batch requests
- Rate limits - Understand usage tiers