Claude API Usage Analytics: Export to CSV
If you're searching for how to get Claude API usage analytics into a CSV file, you're probably trying to solve one of two problems: you need to report spend to finance, or you need to audit which keys, users, or features are driving token consumption. The short answer is that Anthropic's native console gives you usage totals in the dashboard, but it does not offer a one-click CSV export broken down by application, key, or team member. To get that level of detail, you either build your own logging layer around the API, or you use a proxy/gateway that already tracks per-request metadata and lets you export it.
This article covers both paths: how to build CSV export yourself if you're calling the Claude API directly, and how a tool like SubToAPI gives you that export without writing a logging pipeline.
Why CSV Export Matters for Claude API Usage
Raw token counts in a dashboard are fine for a sanity check, but they don't answer the questions finance, engineering leads, or founders actually ask:
- Which API key or integration consumed the most tokens last month?
- How much did a specific customer-facing feature cost in input vs. output tokens?
- Did usage spike on a specific day, and which request caused it?
- Can we attach this data to a spreadsheet for budget reconciliation?
CSV is the lowest-friction format for answering these because it drops straight into Excel, Google Sheets, or a BI tool without any transformation step. Pivot tables, SUMIFs, and chart wizards all expect rows and columns — not JSON blobs.
Option 1: Build Your Own Logging and Export Layer
If you're calling the Claude API directly, Anthropic's response headers and body already contain the usage data you need. Every message response includes a usage object with input_tokens and output_tokens. The pattern is:
- Wrap every API call in a logging function.
- Store each call's metadata (timestamp, model, input/output tokens, request ID, optional tags like user ID or feature name) in a database table or append-only log file.
- Write a scheduled export job (daily or weekly) that queries that table and writes a CSV.
A minimal Node.js example:
const fs = require("fs");
async function callClaudeAndLog(messages, tags = {}) {
const res = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": process.env.ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages,
}),
});
const data = await res.json();
logUsageRow({
timestamp: new Date().toISOString(),
model: data.model,
input_tokens: data.usage.input_tokens,
output_tokens: data.usage.output_tokens,
feature: tags.feature || "unknown",
user_id: tags.userId || "n/a",
});
return data;
}
function logUsageRow(row) {
const line = `${row.timestamp},${row.model},${row.input_tokens},${row.output_tokens},${row.feature},${row.user_id}\n`;
fs.appendFileSync("usage_log.csv", line);
}
This works, but it means every team that calls Claude has to maintain its own tagging convention, storage, and export script. It also doesn't give you per-key cost breakdowns unless you issue separate keys per feature or customer — which Anthropic's console doesn't make easy to manage at scale.
Option 2: Use a Proxy That Tracks Usage Per Key Automatically
The alternative is to put a thin API layer in front of Claude that already tracks usage per application key, and lets you export that data without building the logging pipeline yourself. This is one of the core reasons teams use SubToAPI: it turns your existing Claude access into an HTTPS API with its own sub_live_... keys, and every request made through those keys is logged with token counts, model, and timestamp automatically.
The practical difference: instead of instrumenting every call site in your codebase, you issue a separate SubToAPI key per app, per team, or per customer, and usage separates itself naturally. 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 PR"}]
}'
Because the key itself identifies the source, you don't need custom tagging logic to answer "how much did the internal Slack bot cost this month" versus "how much did the customer support widget cost." The dashboard shows usage metadata per key and per team seat, which you can pull into a spreadsheet for cost allocation, team seat planning, or customer billing review.
If you're evaluating this path, the quickstart walks through issuing your first key, and the messages docs and streaming docs cover request formats if you're migrating existing Claude API calls over.
Choosing Between the Two Approaches
Build your own logging layer if:
- You only call Claude from one service and don't need per-customer breakdowns.
- You already have a data warehouse and prefer raw event logs over a dashboard.
- You want full control over retention and schema.
Use a proxy with built-in export if:
- You have multiple apps, teams, or customers sharing one Claude subscription and need to know who's using what.
- You don't want to maintain a separate logging database just for cost tracking.
- You need team seat visibility — for example, confirming a Team or Scale plan's per-seat usage before renewal. See pricing for how seats map to plans.
Either way, the goal is the same: turn token usage into rows you can filter, sum, and chart, rather than a single dashboard number you have to trust blindly.
Getting Started
If you want usage analytics without building the logging pipeline yourself, sign up for a free trial at /signup, generate an API key, and route your Claude calls through it. Usage per key shows up in the dashboard immediately, ready to review or export for reporting.
questions
Does Anthropic's console support native CSV export of usage data? The console shows usage totals and charts, but it doesn't offer a granular, per-key or per-feature CSV export out of the box. For that level of detail you need your own logging or a proxy layer that tracks it for you.
Can I track usage per team member without issuing separate Anthropic accounts? Yes — using a proxy like SubToAPI, you issue separate application keys per team member or feature, and usage is tracked per key automatically without needing multiple Anthropic accounts.
What fields should a usage export include at minimum? Timestamp, model name, input tokens, output tokens, and a source identifier (key, user, or feature tag). These five fields are enough to build cost breakdowns and spot usage spikes in a spreadsheet or BI tool.