Add Anthropic API billing
This page shows you how to let Prism read what your organisation spends on the Anthropic API (Claude).
Anthropic reports two things for each day: what you were billed, broken down by model and by kind of token, and how many tokens each API key used. Prism copies both, and the list of your API keys, so it can name the key behind the tokens.
When you finish, people can ask Prism questions like these:
- "What did we spend on the Anthropic API per day over the last 14 days?"
- "Which models did we spend the most on in the last 30 days?"
- "Which API keys used the most output tokens in the last 30 days?"
It takes about 15 minutes. You do it once.
Before you start
You need three things.
1. You must be a Prism admin. If you can see Admin in Prism's menu, you are one.
2. An admin of your Anthropic organisation. This is someone who can open
Settings in the Claude Console (console.anthropic.com) and make keys for
the whole organisation. Prism reads the Claude Console organisation only: see
"What Prism reads, and what it does not" below.
3. An Admin API key. This is a key for the whole organisation, not for one
workspace. It starts with sk-ant-admin01-. To make one, the Anthropic admin:
- Opens the Claude Console.
- Goes to Settings, then Admin keys.
- Clicks Create admin key, and names it something like
prism-billing. - Copies the key. The Console shows it only once.
An ordinary API key that belongs to one workspace does not work. Anthropic refuses it for billing reports.
What the key can do. An Admin API key can also manage your organisation's members and keys. Prism only reads with it, and keeps it encrypted. Treat it like any other admin password.
Step 1: Open the page
- Open Prism.
- Click Admin.
- Click Context streams.
A context stream is one kind of data Prism can answer questions about.
Step 2: Choose Anthropic API billing
- Click Add a context stream.
- Find the tile called Anthropic API billing.
- Click Use on that tile.
A form opens. Its title is Register "Anthropic API billing".
Step 3: Fill in the form
name. Type:
anthropic_billing
label. This is the name people see in answers. Type:
Anthropic API billing
api_url. Leave it as it is. It already says https://api.anthropic.com.
backfill_days. This is how many days of past billing Prism reads the first
time. Leave it as 90.
usage_group_by. Leave it as it is.
max_requests_per_minute. Leave it as 30.
secret. This is the Admin API key. Paste it into this box. The box hides what you type. That is normal.
Step 4: Register
- Click Register.
- Wait a few seconds. Prism checks the key with Anthropic.
If it worked, you see Anthropic API billing in the list of context streams.
If the key is wrong, you see a message, and a button that says Store the credential for anthropic_billing. Check that you pasted the whole key, and that it is an Admin API key rather than a workspace key. Then paste it again and click that button.
Step 5: Turn it on
Find Anthropic API billing in the list. Then:
- Click Approve.
- Click Enable.
Prism starts reading within 15 minutes. The first read of 90 days takes a few minutes.
Step 6: Check that it worked
Wait about half an hour. Then ask Prism this question, exactly as written:
What did we spend on the Anthropic API per day over the last 14 days?
It worked if you get an amount for each day up to yesterday.
To be sure, compare it with Anthropic:
- In the Claude Console, open Usage or Cost.
- Pick the same 14 days.
- Prism's amount for each day should match the Console's.
If you use Anthropic's Priority Tier, it does not. Anthropic's cost report leaves Priority Tier out, so Prism's amount is lower by what Priority Tier cost that day.
Today is never in the answer. Anthropic reports a day only once it has ended, in UTC. So yesterday is the newest day Prism has.
It did not work if Prism says it has no data. Go to "If something is wrong" below.
How to undo it
To stop reading, but keep everything:
- Go to Admin, then Context streams.
- Find Anthropic API billing.
- Click Disable.
Prism stops reading new days and stops answering questions about them. The key and the settings stay. To start again, click Enable.
To remove it completely:
- Go to Admin, then Context streams.
- Find Anthropic API billing.
- Click Delete….
- Type
anthropic_billingin the box. - Click Delete anthropic_billing.
This removes the source and the stored key. Nothing at Anthropic changes. To be sure the key can never be used again, the Anthropic admin can also delete it in Settings → Admin keys.
If something is wrong
"Store the credential" keeps failing. The key is probably a workspace key. Make an Admin API key as described in "Before you start".
Prism has no data. Check the source's page in Admin → Context streams. If it says the last read failed, the key may have been deleted or disabled in the Console. Make a new one and store it on the source's page.
The amounts are a little different from the Console for the last few days. Anthropic revises recent days as late usage is counted. Prism reads the last three days again every time it runs, so the difference closes by itself within a day.
What Prism reads, and what it does not
- Prism reads, for each UTC day: each billed line item (a model and a kind of token, or a tool such as web search) and its cost in US dollars, and each API key's tokens per model.
- Usage made in the Claude Console (the Workbench) has no API key. Prism
counts it under the key name
(console). - It reads the name, workspace and status of each API key, so an answer can name a key. A key's name is whatever its creator typed. It does not say who uses the key.
- It does not read prompts, responses, or anything sent to Claude.
- The billed amounts do not include Priority Tier, because Anthropic's cost report leaves it out. Priority Tier tokens are in the token figures.
- It reads the Claude Console organisation only. Claude Enterprise or Team seats, and Claude used through Amazon Bedrock or Google Vertex, are billed elsewhere and are not in these figures.
- Spend that also went through Agent Router appears in both. Never add the two together.
For your technical team
- The recipe is
components/source-manifest/manifests/preview/anthropic_billing.yaml(recipe keyanthropic_billing). It reads the Usage and Cost Admin API:GET /v1/organizations/cost_report,/v1/organizations/usage_report/messagesand/v1/organizations/api_keys. - Every Admin API endpoint refuses a request without the
anthropic-versionheader. The recipe sends it fromconnection.headers. To change the version, edit that header on the source's Manifest tab and Save. Prism removes the stored key, clears the probe result and switches the source off. Enter the key again, then approve the source and enable it. - An organisation-scoped Console key also works where an Admin API key does. A workspace-scoped key is refused.
- Cost is read per line item for the whole organisation, and tokens per API key. The default workspace is reported with no workspace id, and a key column cannot hold an empty value, so the workspace is not part of either key. Each key's workspace is in the API key list.
- Both reports serve whole UTC days only. The day in progress is not served
until it ends. A day is served only by a request that covers all of it.
The walk reads 31-day slices, which start at the run's time of day, so each
request is widened to the midnight before and after its slice
(
{{ window.start_day }}/{{ window.end_day }}). The day a slice boundary falls inside is read by both slices, not by neither. - A request for the day in progress alone is refused, not answered empty.
finished_days_only: trueon both reports stops each request at the last midnight, and the run records the midnight it started on as how far it has read. A run with no finished day left to read asks nothing and still completes, so the three-day re-read below still runs. The first run after midnight UTC reads the day that ended. Keep it on both reports: without it, every run after the first past midnight fails. - Answers measure this stream's age from the last midnight it read up to,
not from the last run. A stale threshold under 36 hours (
PT36H) on this stream marks its answers stale for part of every day. Leave it at the recipe's two days. - A key column cannot be empty. Console usage has a null
api_key_idand is stored as(console). Any other key dimension Anthropic leaves out is stored as(none)(null_asin the recipe). - The API key list is read as one page of up to 1,000 keys, the endpoint's limit. An organisation with more keys has only the first 1,000 named.
- It ingests every 6 hours (
schedule: PT6H), and re-reads the last three days each time (lookback: P3D). - To read days again that Anthropic revised more than three days back, set
ingest.anthropic_billing.rewalkFromto the first such date (YYYY-MM-DD) and upgrade. The next run re-reads from that date, once. It applies only to a source namedanthropic_billing.