Skip to content

On a schedule

Get a weekly OpenAI cost breakdown

A Monday table of last week's tokens and cost per model and project, compared with the week before.

Runs
On a schedule
Apps
OpenAI
AI
Not needed
Access
Admin key

Send this to your assistant

Create a ClickRuntime automation: every Monday at 8am, email me last week's OpenAI tokens and cost for each model and each project, with the change from 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 startup's OpenAI bill rose 60 percent last month and nobody can say why. The usage page shows totals, but it takes several clicks to see which model or project is responsible, and comparing this week with last week means screenshots and a spreadsheet. A team lead trying to decide whether to move a workload from a larger model to a cheaper one has no clean numbers to support the decision.

Every week, token usage and costs are pulled from OpenAI's usage and costs endpoints, grouped by model and by project. The totals are compared with the previous week, which are kept from the last run, and an email arrives with a table showing tokens, cost and the percentage change for each line.

It suits engineering leads, finance contacts and founders who need to explain and plan AI spending.

What you get out of it

  • The reason for a cost jump is visible

    A table by model and project shows whether the increase came from one app, one team or one model. You then know where to look, and do not have to guess.

  • Model choices can be justified

    With token counts and costs side by side, you can see whether a cheaper model could handle a high-volume task. Decisions about switching are based on data, not on feel.

  • Finance gets numbers they can use

    A weekly table with projects named is easy to forward to the person who allocates costs. That avoids the monthly scramble to explain a single unlabeled total. That clarity also helps when you need to explain to a manager why AI spending is rising and whether it is worth it.

  • Week-over-week change is clear

    Percentage changes show trends early. A project that grows 40 percent each week is a budget problem you can address before it becomes a large invoice. Early warnings like that give you time to set limits or optimize prompts before a budget is exceeded.

  • Waste is easier to find

    Models used for trivial tasks, or projects nobody remembers, appear in the table with real costs. Retiring them is a straightforward saving. Cleaning up unused projects and oversized models directly lowers your next invoice without touching anything that is working.

How it works

What happens, step by step

  1. Every Monday, ClickRuntime pulls last week's OpenAI token usage and costs.

  2. It totals tokens by model and cost by project, and compares each with the figures it saved the week before.

  3. You get an email showing this week's numbers and how much each went up or down.

Before it runs live

  • Connect OpenAI

What you get

RunsOn a schedule
Get a weekly OpenAI cost breakdowntoday, 9:00Succeeded
Email · OpenAI usage last weekTokens by model: gpt-4o-mini: 18,420,113 (+2,104,550) Cost by project: proj_support-bot: $96.20 (+11.40)

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

API = "https://api.openai.com/v1/organization"

@on_trigger
def run(event):
    headers = {"Authorization": f"Bearer {credentials.secret('OPENAI_ADMIN_KEY')}"}
    end = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0)
    params = {"start_time": int((end - timedelta(days=7)).timestamp()), "end_time": int(end.timestamp()), "limit": 7}
    tokens, cost = defaultdict(int), defaultdict(float)
    usage = http.get(f"{API}/usage/completions", headers=headers, params={**params, "group_by": ["model"]}).json()
    for b in usage["data"]:
        for r in b["results"]:
            tokens[r["model"]] += r["input_tokens"] + r["output_tokens"]
    for b in http.get(f"{API}/costs", headers=headers, params={**params, "group_by": ["project_id"]}).json()["data"]:
        for r in b["results"]:
            cost[r.get("project_id") or "no project"] += r["amount"]["value"]
    last = state.get("last_week") or {"tokens": {}, "cost": {}}
    lines = ["Tokens by model:"] + [f"  {m}: {n:,} ({n - last['tokens'].get(m, 0):+,})" for m, n in tokens.items()]
    lines += ["Cost by project:"] + [f"  {p}: ${v:,.2f} ({v - last['cost'].get(p, 0):+,.2f})" for p, v in cost.items()]
    notify.email_me("OpenAI usage last week", "\n".join(lines))
    state.set("last_week", {"tokens": tokens, "cost": cost})
    return {"models": len(tokens), "projects": len(cost)}

FAQ

Common questions

Does it need an admin API key?
Yes. The usage and costs endpoints belong to OpenAI's organization admin API, so a standard project key will not work. An organization owner creates the admin key, and it is stored as a secret. The cost is shown as OpenAI reports it, so you can match it against your invoice.
Why might tokens and cost not match exactly?
Costs include things beyond tokens, such as images, audio and fine-tuning, and prices differ by model. The report lists both figures from OpenAI, and small differences come from timing and rounding. Totals per team make budgeting conversations easy and keep the report short.
Can projects be grouped into teams?
Yes. If you name projects consistently, such as by team prefix, the table can roll them up into team totals. A mapping from project to team can also be provided when it is set up.
What permissions does it need?
Admin 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 (on a schedule). 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 OpenAI cost breakdown” from your assistant

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