Skip to content

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.

Paste it into your assistant. It tells you what it will send or change before it runs live.

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

  1. Every day, ClickRuntime fetches yesterday's Anthropic API costs for your organisation.

  2. It adds up the spend for each workspace.

  3. 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

RunsDaily
Get warned when API spend runs hightoday, 9:00Succeeded
Email · Claude API spendAnthropic API spend yesterday: $41.18 wrkspc_support-bot: $29.70 Default: $11.48

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
daily_claude_api_spend_alert.pyexample
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?
From Anthropic's usage and cost reporting API, which requires an Admin API key. ClickRuntime keeps it as a secret and uses it only to read costs. Organization admins can create one in the Anthropic Console.
Can I alert on a percentage of budget instead of a fixed amount?
Yes. For example, alert when a day is above 150% of the average of the last week, or when the month so far is above 80% of the monthly budget. Pick whichever matches how you plan your spend.
Does it show which model used the most?
The cost report can be broken down by model as well as workspace. Add that to the message, and you will see if a switch to a more expensive model caused a jump. A model breakdown is often the fastest route to the cause.
What permissions does it need?
Admin API key (org admin). Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (daily). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

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.