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.
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
Every Monday, ClickRuntime pulls last week's OpenAI token usage and costs.
It totals tokens by model and cost by project, and compares each with the figures it saved the week before.
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
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 OpenAI 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, 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?
Why might tokens and cost not match exactly?
Can projects be grouped into teams?
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
Generate weekly social images with OpenAI
Each week a set of images for your planned topics, made in your style, arrives in your inbox as links.
See how it worksGet warned when OpenAI spend runs high
An email on mornings when the previous day's API cost went over your limit, broken down by project.
See how it worksGet a morning digest summarised on your own key
Every day new items from the feeds you follow are summarised with your OpenAI model and emailed, with no repeats.
See how it worksKeep exploring
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.