Skip to main content
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.
How to analyze Anthropic 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).
Anthropic costs are attributed to input tokens. Output token rows are included for usage analysis but have $0 cost.
Last modified on March 18, 2026