Daily
Get warned when API spend runs high
If yesterday's Anthropic API cost went over your limit, you get an email showing which workspace spent it.
- Runs
- Daily
- Apps
- Anthropic API
- AI
- Not needed
- Access
- Admin API key (org admin)
Send this to your assistant
Create a ClickRuntime automation: every morning, check yesterday's Anthropic API cost and email me if it's over $25, broken down by workspace.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
API costs grow in a way that is easy to miss. A prompt that works in testing gets deployed on a loop, a retry bug sends the same request fifty times, or a customer finds a way to run long conversations, and the bill for a single day is several times the usual. The Anthropic Console shows usage, but nobody opens it daily, and the invoice at month end is a nasty surprise. By then the money is spent, and the cause has to be reconstructed from logs.
Each day, the automation calls the Anthropic cost report for the last day, groups the cost by workspace, compares each total with the limit you set and sends an email or Slack message when one is above it. Days below the limit produce nothing.
Startups and engineering leads who run Claude in production, and finance teams who own the budget, can use it as a cheap safety net.
What you get out of it
Runaway costs are stopped within a day
A loop or retry bug that would burn money for weeks is spotted the next morning, so the damage is a single day's spend rather than a month's. The difference between one bad day and one bad month is the size of the problem.
Budget owners get early warning
Finance sees when spend is running above plan, with a day's notice. That is time to talk to engineering, not an unpleasant discovery on the invoice. A conversation about the numbers can happen while there is still budget left to adjust.
Spend is traced to a workspace
Grouping by workspace shows which project or environment caused a spike. A test environment left running stands out from production traffic. A forgotten test environment is a common source of surprise costs, and it is easy to spot once costs are split by workspace.
Limits can differ by project
A research workspace may be allowed more than a customer-facing one. Setting separate limits keeps the alert meaningful for each team. Each team gets a fair threshold that matches how it uses the API.
A record for cost reviews
Alert emails document when spending crossed a line and what the totals were, which helps when you review pricing, model choice or caching with your team. Those emails make later cost conversations factual, and they show whether changes you made actually reduced spend.
How it works
What happens, step by step
Every day, ClickRuntime fetches yesterday's Anthropic API costs for your organisation.
It adds up the spend for each workspace.
If the total is over your limit, such as $25, you get an email with the total and each workspace's spend, biggest first. Otherwise nothing is sent.
Before it runs live
- Connect Anthropic API
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Anthropic API steps into one automation
Under the hood
The code that runs this automation
from collections import defaultdict
from datetime import datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, notify, http
LIMIT_USD = 25
@on_trigger
def run(event):
end = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0)
resp = http.get("https://api.anthropic.com/v1/organizations/cost_report",
headers={"x-api-key": credentials.secret("ANTHROPIC_ADMIN_KEY"), "anthropic-version": "2023-06-01"},
params={"starting_at": (end - timedelta(days=1)).isoformat(), "ending_at": end.isoformat(),
"group_by[]": "workspace_id"})
resp.raise_for_status()
by_ws = defaultdict(float)
for bucket in resp.json()["data"]:
for r in bucket["results"]:
by_ws[r.get("workspace_id") or "Default"] += float(r["amount"]) / 100 # amount is in cents
total = sum(by_ws.values())
if total > LIMIT_USD:
lines = [f"{ws}: ${usd:,.2f}" for ws, usd in sorted(by_ws.items(), key=lambda kv: -kv[1])]
notify.email_me(f"Anthropic API spend yesterday: ${total:,.2f}", "\n".join(lines))
return {"total_usd": round(total, 2)}FAQ
Common questions
Where does the cost data come from?
Can I alert on a percentage of budget instead of a fixed amount?
Does it show which model used the most?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Get a cited research brief every morning
Each weekday you get a few bullet points on what changed in your topic, each with a source link, and nothing you've already seen.
See how it worksGet a weekly token report by model
Every Monday you see how many tokens each model and each API key used, next to the week before.
See how it worksGet a daily digest of your feeds
Each morning, new posts from the sites you follow arrive as one short summary, written by the model you chose.
See how it worksKeep exploring
Set up “Get warned when API spend runs high” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.