> For the complete documentation index, see [llms.txt](https://integrations.drivetrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://integrations.drivetrain.ai/integration-guide/readme/ai-and-llm-cost/integrating-with-anthropic.md).

# Integrating with Anthropic

When you connect [Anthropic](https://www.anthropic.com/) to Drivetrain, your API key usage, token use, cost breakdown, and Claude Code activity sync for each workspace. You can then track and forecast AI spend next to the rest of your financials.

This guide walks you through creating an Anthropic Admin API key and adding Anthropic as a data source in Drivetrain.

{% hint style="info" %}
The Anthropic connector is **read-only**. Drivetrain only pulls usage and cost data from Anthropic and never writes anything back.
{% endhint %}

{% hint style="info" %}
This guide covers bringing your Claude API usage and token cost **into Drivetrain as a dataset**. To use Drivetrain from inside Claude instead, see [Using the Drivetrain MCP Server](/extending-drivetrain/using-the-drivetrain-mcp-server.md).
{% endhint %}

## Prerequisites

To connect Anthropic to Drivetrain, you need:

* A Claude Console (formerly Anthropic Console) organization at [platform.claude.com](https://platform.claude.com/). Admin API keys aren't available for individual accounts.
* Organization admin access. Only organization admins can create Admin API keys.
* Access to your Drivetrain workspace with permission to add data sources.

## What Drivetrain syncs from Anthropic

Once connected, Drivetrain pulls the following for each Anthropic workspace:

* **API key usage**: activity for each API key in your organization.
* **Token usage**: input and output tokens consumed.
* **Cost breakdown**: what your organization is spending on the Claude API.
* **Claude Code activity**: usage from Claude Code across your organization.

This data lands in Drivetrain as the following tables:

| Table             | What it contains                                                             | One row per                                     |
| ----------------- | ---------------------------------------------------------------------------- | ----------------------------------------------- |
| Cost Report       | Billed cost in USD                                                           | Day, workspace, model, cost type and token type |
| Messages Usage    | Input, output, cache write and cache read tokens                             | Day, API key, workspace and model               |
| API Key Costs     | Estimated cost in USD, calculated from token counts at Anthropic list prices | Day, API key, workspace and model               |
| Claude Code Usage | Sessions, lines of code, commits, pull requests, tokens and estimated cost   | Day, user or API key, terminal and model        |
| API Keys          | Name, status, workspace and creator of each API key                          | API key                                         |
| Workspaces        | Workspaces in your organization                                              | Workspace                                       |
| Users             | Members of your organization and their roles                                 | User                                            |

{% hint style="info" %}
**Cost Report** matches what Anthropic bills you, so use it for actuals. Anthropic's billed cost isn't broken down by API key, so use **API Key Costs** to allocate spend by key, team, or product.
{% endhint %}

Usage and cost history syncs from January 1, 2024, and Claude Code history from February 1, 2025. After the first sync, Drivetrain pulls new data incrementally.

## Anthropic Setup: Create an Admin API key

Drivetrain connects with an Admin API key, which starts with `sk-ant-admin01-`. A standard Claude API key (`sk-ant-api03-...`) doesn't have access to usage and cost data, so it won't work.

### Step 1: Open Admin keys

1. Sign in to the [Claude Console](https://platform.claude.com/) as an organization admin.
2. Click your profile in the bottom-left corner of the sidebar and select **Organization settings**.
3. In the **Organization settings** sidebar, click **Admin keys**.

### Step 2: Create the key

1. Click **+ Create admin key** to open the key creation dialog.
2. Enter a descriptive name, such as **Drivetrain Integration**.
3. Click **Add** to confirm.

### Step 3: Copy and store the key

The Console shows the key only once. Copy it right away and store it somewhere secure. You'll paste it into Drivetrain in the next section.

{% hint style="warning" %}
Admin API keys carry organization-wide admin access. Treat the key like a password, never share it publicly or commit it to source control, and delete it from **Admin keys** if it's ever compromised.
{% endhint %}

## Drivetrain Setup: Add Anthropic as a data source

### Step 1: Open Data and add a source

In Drivetrain, go to **Data** in the left navigation, then click the **+** button to add a new data source.

### Step 2: Select the Anthropic connector

In the **Connect a data source** window, search for **Anthropic** and select it under **AI & LLM Cost**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-8f7ad26bd1a66098b67d700b07bf5ed5a912ffb9%2Fai-llm-cost-connect-a-data-source.webp?alt=media" alt="The Connect a data source window with Anthropic and OpenAI listed under AI &#x26; LLM Cost"><figcaption></figcaption></figure>

### Step 3: Enter your Admin API key

On the **Connect your Anthropic account** screen, paste the key you copied into the **Admin API Key** field, then click **Submit**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-7347523eb76ad0e0df296a03b12723f34ca7ad18%2Fanthropic-connect-your-account.webp?alt=media" alt="The Connect your Anthropic account screen with the Admin API Key field"><figcaption></figcaption></figure>

### Step 4: Confirm the connection

Anthropic now shows as a connected data source and starts syncing. Your usage and cost data appears in Drivetrain once the first sync finishes.

{% hint style="info" %}
If you have trouble connecting Anthropic or don't see your data after the sync, contact your Drivetrain CSM.
{% endhint %}

## FAQ

**Can I use a regular Claude API key instead of an Admin API key?**

No. Only Admin API keys (starting with `sk-ant-admin01-`) can read your organization's usage and cost data. Standard API keys can't.

**Does this connector include Claude.ai subscription costs?**

No. The connector syncs Claude API usage and cost from your Claude Console organization. Claude.ai Pro, Team, and Enterprise seat costs aren't included.

**Why do Claude Code session and line counts look too high when I add them up?**

Claude Code Usage has one row per model, and each user's daily sessions, lines of code, commits, and pull requests repeat on every model row for that day. Take the maximum per user per day instead of the sum. Token and cost columns are per model, so you can add those up.

**Can I connect more than one Anthropic organization?**

Yes. Add a separate Anthropic data source for each organization, each with its own Admin API key.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://integrations.drivetrain.ai/integration-guide/readme/ai-and-llm-cost/integrating-with-anthropic.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
