> ## Documentation Index
> Fetch the complete documentation index at: https://docs.costory.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic Billing Setup

> Connect Anthropic Claude Console API usage and claude.ai Enterprise costs to Costory. Choose the right connector and key type.

Anthropic reports cost through two APIs. They use different keys and are not interchangeable. Pick the connector that matches where you pay, then paste the matching key.

If you call Claude through Amazon Bedrock instead of Anthropic's own APIs, that spend lands via the [AWS connector](https://docs.costory.io/setup/billing/aws.md). For team-level allocation after data is in, see [LLM cost allocation](https://docs.costory.io/use-cases/llm-ai-cost.md).

## Which connector to use

| Your organization | Connector in Costory | Key |
| - | - | - |
| Claude Console (Claude Platform) | **Anthropic Claude Code** | Admin API key (`sk-ant-admin01-…`) |
| Claude Enterprise ([claude.ai](https://claude.ai)) | **Anthropic Claude AI** | Analytics API key (`sk-ant-api01-…`, scope `read:analytics`) |

Claude Enterprise parent organizations do not appear in Claude Console and have no Admin API keys. A Console Admin key will not work on **Anthropic Claude AI**. An Analytics API key will not work on **Anthropic Claude Code**.

> [!NOTE]
>
> Connect both if you pay for Console API usage and a claude.ai Enterprise org. Each connector is a separate billing datasource.

## Connect Anthropic Claude Code

Use this connector for Claude Console (Claude Platform) API usage and subscription usage exposed by the [Usage and Cost Admin API](https://platform.claude.com/docs/en/build-with-claude/usage-cost-api).

> [tab] Manual setup
>
> **1. Create an Admin API key**
>
> In [Claude Console > Settings > Admin keys](https://platform.claude.com/settings/admin-keys), create an **Admin API key** with usage and cost access. You must be an organization **admin**. Copy it immediately (`sk-ant-admin01-…`). A standard Claude API key will not work.
>
> **2. Connect in Costory**
>
> Go to [Integrations](https://app.costory.io/integration), click **+ Add integration**, then choose **Anthropic Claude Code** under **Billing**.
>
> **3. Enter connection details**
>
> Fill **Connection name** (default **Anthropic**) and **Admin API key**. **Start date** is optional. Leave it empty to use Costory's default lookback.
>
> **4. Validate, then save**
>
> Click **Validate**. **Save** stays disabled until the Admin API key can read organization usage and cost. If this is the only billing source and it is demo data, Costory asks you to confirm before replacing it.
>
> On first sync, Costory backfills up to **12 months** of historical usage data. New data then follows the usual [data refresh](https://docs.costory.io/docs/data-refresh.md) cadence. SaaS sources typically appear in about **10 minutes**.

> [tab] Terraform
>
> To install and authenticate the provider, see [Terraform setup](https://docs.costory.io/setup/terraform.md).
>
> ```hcl theme={null}
> terraform {
>   required_providers {
>     costory = {
>       source  = "costory-io/costory"
>       version = ">= 0.1.0"
>     }
>   }
> }
>
> variable "costory_api_token" {
>   type        = string
>   description = "Costory API token."
>   sensitive   = true
> }
>
> variable "anthropic_admin_api_key" {
>   type        = string
>   description = "Anthropic admin API key used to fetch billing data."
>   sensitive   = true
> }
>
> provider "costory" {
>   token = var.costory_api_token
> }
>
> resource "costory_billing_datasource_anthropic" "main" {
>   name          = "Anthropic Billing"
>   admin_api_key = var.anthropic_admin_api_key
> }
> ```

### What Costory includes

* **API usage** and **subscription usage** from Anthropic billing exports.
* **Included plan usage** labeled as `Included<subscription_type>` in **Charge description** (for Business/Enterprise plans).
* **Per-model breakdown** (group by **Service name** = model).
* **Per-actor attribution** using user email or API key name.

**What Costory does not include**

* **Taxes, credits, and adjustments** outside usage line items.
* **Non-usage fees** that do not appear in the Anthropic billing export.
* **claude.ai Enterprise** seat or usage-credit costs. Use [Anthropic Claude AI](#connect-anthropic-claude-ai) for those.

**How to analyze Anthropic Claude Code costs**

* **Included vs API usage:** filter by **Charge description**:
  * `Included<subscription_type>` for subscription usage.
  * `API` for pay-as-you-go usage.
* **Per-user email spend:** group by **Resource name** or **Sub account id** (mapped to the actor email or API key name).
* **Per-model costs:** group by **Service name** (model) and break down by **SKU** (`input` vs `output` tokens).

> [!NOTE]
>
> Anthropic Console costs are attributed to **input tokens**. Output token rows are included for usage analysis but have \$0 cost.

## Connect Anthropic Claude AI

Use this connector for Claude Enterprise costs on [claude.ai](https://claude.ai). Costory reads per-user cost from the [Get Per-User Cost](https://platform.claude.com/docs/en/api/http/admin/analytics/cost/list_by_user) endpoint. See Anthropic's [Analytics API](https://platform.claude.com/docs/en/manage-claude/analytics-api) for how to enable access.

> [!WARNING]
>
> You must sign in as the organization **primary owner**. Only the primary owner can enable public API access and create the Analytics API key.

**1. Enable public API access**

Sign in to [claude.ai](https://claude.ai) as the **primary owner**. Open [claude.ai > Organization settings > API](https://platform.claude.com/docs/en/manage-claude/analytics-api) and enable public API access.

**2. Create an Analytics API key**

Create an Analytics API key with scope **read:analytics**. Copy it immediately (`sk-ant-api01-…`). A Console Admin key (`sk-ant-admin01-…`) will not work.

**3. Connect in Costory**

Go to [Integrations](https://app.costory.io/integration), click **+ Add integration**, then choose **Anthropic Claude AI** under **Billing**.

**4. Enter connection details**

Fill **Connection name** (default **Anthropic Claude AI**), **Account name**, and **Analytics API key**. **Start date** is optional. Leave it empty to use Costory's default lookback.

**5. Validate, then save**

Click **Validate**. **Save** stays disabled until the Analytics API key can read Claude Enterprise per-user cost. If this is the only billing source and it is demo data, Costory asks you to confirm before replacing it.

On first sync, Costory backfills up to **12 months** of historical usage data, depending on what Anthropic retains. New data then follows the usual [data refresh](https://docs.costory.io/docs/data-refresh.md) cadence.

### Field reference

| Field | Required | Description |
| - | - | - |
| **Connection name** | Yes | Label in **Integrations**. |
| **Account name** | Yes | Label for this Claude Enterprise org. Stored as **Sub account id**. Not sent to Anthropic. |
| **Analytics API key** | Yes | Primary-owner key with `read:analytics`. Stored in Costory's secret manager. |
| **Start date** | No | Optional start of the first sync. Leave empty for the default lookback. |

### What Costory includes

* **Per-user cost** from the Claude Enterprise Analytics API.
* Your **Account name** as **Sub account id**, so you can tell multiple Enterprise orgs apart.

**What Costory does not include**

* **Claude Console / API** usage. Use [Anthropic Claude Code](#connect-anthropic-claude-code) for that.
* **Unattributed org-wide API-key or automation traffic** (the org-wide cost report is out of scope).
* **Seat SKU** on seat-based Enterprise plans. Those plans only show usage credits.

> [!NOTE]
>
> Seat-based Enterprise plans only show usage credits, not the seat SKU. Cost and usage endpoints apply to usage-based Enterprise plans. For seat-based plans they reflect usage credits only.

> [!NOTE]
>
> Rotate the Analytics API key from **Integrations** when you need a new credential. **Account name** stays the same.

## Troubleshooting

| Issue | What to check |
| - | - |
| Admin key rejected on Claude AI | You pasted a Console Admin key (`sk-ant-admin01-…`). Use **Anthropic Claude Code** for that key, or create an Analytics key (`sk-ant-api01-…`) as primary owner. |
| Analytics key rejected on Claude Code | You pasted an Analytics API key. Use **Anthropic Claude AI** for claude.ai Enterprise costs. |
| Access denied (403) | Confirm you are the **primary owner**, public API access is enabled, and the key has `read:analytics`. |
| No cost data on a seat-based plan | Expected. Seat-based plans expose usage credits only, not the seat SKU. |
| Failed to authenticate | Recreate the key in the matching console: Admin keys in Claude Console, Analytics keys in claude.ai Organization settings > API. |

## Related

* [Billing Data](https://docs.costory.io/setup/billing)
* [LLM cost allocation](https://docs.costory.io/use-cases/llm-ai-cost.md)
* [OpenAI Billing Setup](https://docs.costory.io/setup/billing/openai.md)
* [OpenRouter Billing Setup](https://docs.costory.io/setup/billing/openrouter.md)
* [ElevenLabs Billing Setup](https://docs.costory.io/setup/billing/elevenlabs.md)
* [Kling AI Billing Setup](https://docs.costory.io/setup/billing/kling-ai.md)
* [Cursor Billing Setup](https://docs.costory.io/setup/billing/cursor.md)
* [Data Refresh](https://docs.costory.io/docs/data-refresh.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.