Anthropic Integration

Connect your Anthropic account to track Claude model costs and token usage in Grafient.

Overview

Grafient uses an Admin API key to ingest cost and usage data through the Anthropic Cost Report API. This integration allows you to track Claude model usage and costs directly in Grafient, with up to 365 days of historical data on the Pro plan.

This integration is for direct Anthropic API usage only. If you access Claude through Amazon Bedrock or Google Cloud Vertex AI, those costs are billed through your cloud provider instead.

Prerequisites

Before you begin, make sure you have:

  • An Anthropic Organization account — individual accounts do not have access to the Admin API. You can set up an organization in the Anthropic Console under Settings > Organization.
  • Organization Admin role — only admins can create Admin API keys.
  • A Grafient account on the Free, Pro, or Ultimate plan.

Permissions and Security

Anthropic requires an Admin API key to access the Cost Report API. This key type has broad permissions across your organization. Grafient only uses this key to read the following data:

  • Daily cost reports grouped by model
  • Token consumption metadata (input, output, cached)

Grafient will never perform any cost-incurring operations, modify your organization settings, or access prompt/completion content. Your API key is encrypted with AES-256-GCM before storage and is never exposed after the initial connection.

If you need finer-grained API key permissions, you can request scoped access from Anthropic. For now, the Admin API key is the only way to access the Cost Report endpoint.

Create a Connection

Step 1: Create an Admin API Key in Anthropic

  1. Log in to the Anthropic Console.
  2. Click the Settings gear icon in the left sidebar.
  3. Select Admin API Keys from the settings menu.
  4. Click Create Admin Key.
  5. Give your key a descriptive name, such as Grafient Integration.
  6. Click Create and copy the generated key immediately.

The key starts with sk-ant-admin and is only shown once. If you lose it, you will need to create a new one. Store it securely until you complete the next step.

Step 2: Add the Key to Grafient

  1. In Grafient, navigate to the Integrations page from the sidebar.
  2. Click Add Integration.
  3. Select Anthropic as the provider.
  4. Enter a label to identify this integration (e.g., Production — Anthropic). If left blank, a default label is generated for you.
  5. Paste the Admin API key you copied in Step 1.
  6. Click Test Connection — a green checkmark confirms the key is valid.
  7. Click Add Integration to save.

What Happens Next

Once you add the integration, Grafient will:

  1. Validate your API key against the Anthropic Cost Report endpoint.
  2. Backfill historical costs — up to 30 days on Free, or 365 days on Pro/Ultimate.
  3. Sync daily via an automated job at 6 AM UTC to pull the previous day's finalized cost data.

Your costs will appear on the Dashboard within a few seconds of the initial sync. You can also click Force Sync on the integration card at any time to pull the latest data.

Data Collected

Data PointDescription
Daily cost (USD)Total spend per day, broken down by model
Model breakdownCost attributed to each Claude model (e.g., Claude Sonnet 4, Opus, Haiku)
Input tokensStandard (uncached) input token consumption
Output tokensOutput token consumption
Cached tokensCache read and cache creation token consumption

API Endpoint Used

Grafient calls a single endpoint:

EndpointPurpose
GET /v1/organizations/cost_reportDaily cost data grouped by model, with 1-day bucket width

Requests are paginated and batched to stay within Anthropic's rate limits.

Rate Limits

The Anthropic Admin API allows approximately 1 request per minute for sustained polling. Grafient batches requests to stay well within these limits during both initial backfill and daily sync.

Data Freshness

Anthropic cost data is typically available within 5 minutes of API request completion. The daily cron sync at 6 AM UTC captures the previous day's finalized data, which is authoritative for billing reconciliation.

Troubleshooting

"Test Connection" fails

  • Verify the key prefix: The key must start with sk-ant-admin. Regular API keys (sk-ant-api) do not have access to the Cost Report endpoint.
  • Check your role: Only Organization Admins can create and use Admin API keys. Ask your org admin if you are unsure.
  • Confirm organization setup: Individual Anthropic accounts cannot access the Admin API. Go to Settings > Organization in the Anthropic Console to verify you are part of an organization.

No cost data appears after sync

  • Check for recent usage: If there has been no API usage in the sync window, there will be no cost data to display.
  • Wait for data availability: Anthropic cost data may take up to 5 minutes to become available after API calls are made.
  • Try Force Sync: Click the refresh icon on your integration card to trigger a manual sync.

Integration shows an error status

  • Revoked key: If the Admin API key was deleted or rotated in the Anthropic Console, the integration will fail. Remove the integration and add a new one with the updated key.
  • Rate limiting: If many integrations sync simultaneously, rate limits may cause temporary errors. The next daily sync will retry automatically.