Skip to content

Weekly

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

Runs
Weekly
Apps
Anthropic API
AI
Not needed
Access
Admin API key

Send this to your assistant

Create a ClickRuntime automation: every Monday at 9am, email me last week's Anthropic API token usage per model and per API key, compared with the previous week.

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

A developer team ships a support bot on Claude Sonnet, then adds a summarizer, a classifier and a nightly batch job, all sharing a handful of API keys. The monthly Anthropic invoice rises, and nobody can say whether the cause is the new feature, a runaway loop or one engineer who left the most expensive model as the default. The Console shows totals, but nobody opens it until finance asks a question.

Each week, ClickRuntime queries the Anthropic usage report in daily buckets, grouped by model and API key. It compares the totals with the figures it stored the week before and emails you a table. The table shows tokens per model, tokens per key and the change since last week, so a jump is easy to spot.

It suits engineering leads and founders who pay the API bill but do not want another dashboard to check.

What you get out of it

  • Cheaper models get used where they fit

    When the table shows a classifier burning most of its tokens on the largest model, you have a concrete reason to test a smaller one. The saving comes from a specific change, not a vague plan to optimize.

  • A runaway loop shows up within days

    A retry bug can multiply token use tenfold on one key. The week-over-week column makes that spike obvious in the next email instead of on the following invoice. Catching it early limits the damage to a few thousand tokens.

  • Costs trace back to one key

    Each API key usually maps to a service or a person. Seeing tokens per key tells you which project is driving spend before you have to argue about how to split the bill.

  • Budget talks start from numbers

    When finance asks why the API line grew 40 percent, you can answer with a model-level breakdown from the last several Mondays rather than a guess pieced together after the fact.

  • Model migrations get measured

    After you move a workload to a newer model, the next table shows whether token volume on the old model actually fell. Finished migrations stop quietly costing money on leftover traffic.

How it works

What happens, step by step

  1. Every Monday, ClickRuntime fetches the last 7 days of Anthropic API usage.

  2. It adds up the tokens used for each model and API key.

  3. It compares each figure with the previous week, which it saved last time.

  4. You get an email listing each model and key with this week's tokens next to last week's, biggest first.

Before it runs live

  • Connect Anthropic API

What you get

RunsWeekly
Get a weekly token report by modeltoday, 9:00Succeeded
Email · Weekly token usageclaude-sonnet-5-5 / apikey_01Ab: 4,210,880 tokens (previous week 3,902,114)

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.
weekly_token_usage_by_model.pyexample
from collections import defaultdict
from datetime import datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, notify, http, state

@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/usage_report/messages",
                    headers={"x-api-key": credentials.secret("ANTHROPIC_ADMIN_KEY"), "anthropic-version": "2023-06-01"},
                    params={"starting_at": (end - timedelta(days=7)).isoformat(), "ending_at": end.isoformat(),
                            "bucket_width": "1d", "group_by[]": ["model", "api_key_id"], "limit": 7})
    resp.raise_for_status()
    usage = defaultdict(int)
    for bucket in resp.json()["data"]:
        for r in bucket["results"]:
            usage[f"{r['model']} / {r['api_key_id']}"] += r["uncached_input_tokens"] + r["output_tokens"]
    previous = state.get("last_week") or {}
    lines = [f"{k}: {v:,} tokens (previous week {previous.get(k, 0):,})"
             for k, v in sorted(usage.items(), key=lambda kv: -kv[1])]
    notify.email_me("Anthropic token usage, last week", "\n".join(lines) or "No usage last week.")
    state.set("last_week", dict(usage))
    return {"rows": len(lines)}

FAQ

Common questions

Does the report need an Admin API key?
Anthropic's usage and cost reporting endpoints are part of the Admin API, which uses a separate admin key created by an organization admin in the Console. Standard API keys cannot read the report. ClickRuntime stores the admin key as a secret, so it never appears in the email or the logs.
Are the numbers per day or per week?
The query pulls one-day buckets, so the email can show each day inside the week as well as the weekly total per model and key. That helps when a spike lasted a single day, because a weekly average would have hidden it from you.
Can I send the table to a team channel instead of my inbox?
Yes. Email is the default delivery, but the final step can be pointed at a Slack channel or a shared mailbox. Tell your AI assistant where the table should go and approve the change when it is shown.
What permissions does it need?
Admin API key. 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 (weekly). 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 a weekly token report by model” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.