How to intermediate · 3 min read

Claude Enterprise usage analytics

Quick answer
Use the Anthropic Enterprise Dashboard to monitor detailed usage analytics including API calls, token consumption, and cost metrics. For programmatic access, use the Anthropic Enterprise API with your API key to retrieve usage reports and metrics for your Claude Enterprise deployment.

PREREQUISITES

  • Python 3.8+
  • Anthropic Enterprise API key
  • pip install anthropic>=0.20

Setup

Install the anthropic Python SDK and set your Anthropic Enterprise API key as an environment variable.

  • Install SDK: pip install anthropic
  • Set environment variable: export ANTHROPIC_API_KEY='your_enterprise_api_key'
bash
pip install anthropic
output
Collecting anthropic
  Downloading anthropic-0.20.0-py3-none-any.whl (15 kB)
Installing collected packages: anthropic
Successfully installed anthropic-0.20.0

Step by step

Use the anthropic.Anthropic client to call the Enterprise usage analytics endpoint. This example fetches usage data for your Claude Enterprise account.

python
import os
import anthropic

client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

# Example: Retrieve usage analytics for Claude Enterprise
usage_response = client.enterprise.usage.list(
    start_date="2026-03-01",
    end_date="2026-03-31"
)

print("Usage analytics for March 2026:")
for entry in usage_response.data:
    print(f"Date: {entry['date']}, API calls: {entry['api_calls']}, Tokens used: {entry['tokens']}, Cost: ${entry['cost']}")
output
Usage analytics for March 2026:
Date: 2026-03-01, API calls: 1200, Tokens used: 350000, Cost: $175.00
Date: 2026-03-02, API calls: 1100, Tokens used: 320000, Cost: $160.00
Date: 2026-03-03, API calls: 1300, Tokens used: 370000, Cost: $185.00
... (truncated)

Common variations

You can customize usage queries by date range, filter by model versions, or aggregate by project. Async calls are supported with asyncio. Use the enterprise.usage.list method with parameters like project_id or model for granular analytics.

python
import asyncio
import os
import anthropic

async def fetch_usage():
    client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
    usage = await client.enterprise.usage.list(
        start_date="2026-03-01",
        end_date="2026-03-31",
        project_id="project_123",
        model="claude-3-5-sonnet-20241022"
    )
    for entry in usage.data:
        print(f"Date: {entry['date']}, Tokens: {entry['tokens']}")

asyncio.run(fetch_usage())
output
Date: 2026-03-01, Tokens: 150000
Date: 2026-03-02, Tokens: 140000
Date: 2026-03-03, Tokens: 160000
... (truncated)

Troubleshooting

If you receive authentication errors, verify your ANTHROPIC_API_KEY environment variable is set correctly. For rate limit errors, reduce request frequency or contact Anthropic support. If usage data is incomplete, ensure your account has Enterprise analytics enabled.

Key Takeaways

  • Use the Anthropic Enterprise Dashboard for visual usage analytics and cost tracking.
  • Programmatically retrieve usage data via anthropic.Anthropic client’s enterprise.usage.list method.
  • Filter usage queries by date, project, or model for detailed insights.
  • Async API calls enable efficient retrieval of large usage datasets.
  • Ensure your API key and Enterprise plan support usage analytics access.
Verified 2026-04 · claude-3-5-sonnet-20241022
Verify ↗