Claude API Invoice Billing: Export to CSV for Accounting
Why Claude API billing data is hard to export
If you've gone looking for a "download CSV" button in the Anthropic Console, you've probably noticed there isn't one for raw usage line items tied to invoices. You can see monthly totals and download PDF invoices, but there's no built-in way to export per-day, per-model, or per-project token usage as a CSV file you can drop into QuickBooks, Xero, or a spreadsheet for your finance team.
This matters because most companies don't just need "we spent €340 this month" — they need to know who spent it, on what, and when, broken down in a format accounting software can ingest. This article covers the two realistic ways to get Claude API costs into CSV: pulling usage data yourself and reconstructing it, or using a layer like SubToAPI that gives you structured usage metadata per request so CSV export is trivial.
What the Anthropic Console actually gives you
As of now, the Anthropic Console provides:
- A billing/usage dashboard with aggregated spend by day and by model
- PDF invoices for each billing period
- Usage shown in tokens, not always broken down by team member or project in a way that maps cleanly to cost centers
What it doesn't give you out of the box is a per-request or per-API-key CSV export that you can filter by date range, project, or user. If you're billing clients per project, allocating costs across teams, or just want clean monthly expense reports, you end up doing manual work: screenshotting dashboard numbers, copying totals into spreadsheets, or asking engineering to pull logs.
Option 1: Build your own usage log and export it
If you're calling the Claude API directly, the most reliable way to get exportable billing data is to log usage yourself at the application layer, since the API response includes token counts per request.
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this report."}]
}'
The response includes a usage object with input_tokens and output_tokens. To build a CSV export, you need to:
- Log every request with timestamp, model, input tokens, output tokens, and whatever metadata identifies the caller (user ID, project, feature flag)
- Apply Anthropic's per-model pricing to compute cost per request
- Store these rows in a database or append them to a file
- Write a script that queries by date range and dumps to CSV
A minimal logging + export pattern in Node.js:
const fs = require("fs");
function logUsage(row) {
fs.appendFileSync("usage.csv",
`${row.date},${row.model},${row.inputTokens},${row.outputTokens},${row.cost}\n`
);
}
// after each Claude API call
logUsage({
date: new Date().toISOString(),
model: "claude-sonnet-4-5",
inputTokens: response.usage.input_tokens,
outputTokens: response.usage.output_tokens,
cost: calculateCost(response.usage)
});
This works, but it's extra infrastructure you have to maintain: pricing changes when Anthropic updates rates, you need to handle streaming responses differently, and multi-service setups mean reconciling logs from several codebases.
Option 2: Use a layer that already tracks usage metadata
This is the gap SubToAPI fills. Instead of calling Claude directly and building your own logging pipeline, you route requests through SubToAPI's HTTPS API using an application key (sub_live_...). Every request through that key is already tracked with usage metadata — tokens, model, timestamp, and which key made the call — visible in your dashboard.
Example request:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this report."}]
}'
Because SubToAPI issues separate application keys per project or team member, your usage is already segmented at the source. That means when it's time to do expense reports, you're not reconstructing who-spent-what from a single shared API key's logs — each key's usage is already isolated.
This is particularly useful if:
- You're on a Team or Scale plan with multiple seats and need to see spend per person
- You bill clients for AI usage and need per-project breakdowns
- Your finance team wants monthly numbers without asking engineering for a custom script every time
See the quickstart for setup and the Messages API docs for request/response details. Pricing and seat structure is on the pricing page.
A practical export workflow
Whichever approach you use, a clean billing CSV workflow looks like this:
- Tag every request with a project or user identifier at the source (either in your own logging or via separate application keys)
- Aggregate daily, not per-request, if you're dealing with high volume — daily rows are usually enough for accounting
- Normalize currency if your team spans multiple billing regions
- Export on a schedule — a monthly cron job or scheduled script that dumps the previous month's rows to CSV and emails or uploads it automatically
- Reconcile against the invoice — your CSV totals should match Anthropic's (or SubToAPI's) invoice for the period; if they don't, check for failed requests being logged as zero-cost or double-logged retries
Getting started
If you're already deep into custom logging infrastructure just to answer "how much did this feature cost us last month," it's worth evaluating whether a usage-tracked API layer saves more engineering time than it costs. You can try SubToAPI with a free trial at signup and see the per-key usage breakdown in the dashboard before deciding whether to migrate.
questions
Does the Anthropic Console let me export usage as CSV directly? Not currently for granular per-request data. You get aggregated dashboard views and PDF invoices, but no native CSV export of per-day or per-key usage.
Can I get Claude API costs broken down by team member? Only if you structure your API keys or logging to separate callers. A single shared key makes per-person breakdowns impossible without extra tagging; separate keys per person (as with SubToAPI's per-seat setup) solve this natively.
What's the easiest way to automate monthly billing exports? Log token usage and cost per request (or per key) into a database, then run a scheduled script that queries the prior month's rows and writes them to CSV. If you use SubToAPI, usage metadata is already tracked per key, which removes the need to build that logging layer yourself.