RecipesOpenAI
OpenAI spend
FreeSpend today, spend this month, daily spend, cost by model, and how close you are to your budget. Your agent holds an OpenAI Admin key. Botopticon is not affiliated with OpenAI.
Access
OpenAI Admin key, usage and costs read
Required. Env OPENAI_ADMIN_KEY, OPENAI_MONTHLY_BUDGET. Mode api_key.
- Read-only permissions, if the form offers them
Only an OpenAI organization Owner can make this key: platform.openai.com > Settings > Organization > Admin keys > Create new admin key. Name it Botopticon board and choose read-only permissions if the form offers them. A full Admin key can also manage projects, members, and API keys, so the agent only makes GET calls to the usage and costs endpoints with it. A project key (sk-proj-) can't read org spend. Put your monthly budget in dollars in OPENAI_MONTHLY_BUDGET (for example 500). The costs API doesn't return a budget, so without it Usage limit stays idle.
Botopticon never stores this key. Paste it into the agent, cron host, or MCP config. Revoke it any time.
Board
Sample · not your account.
Spend today
+$22
Month spend
Daily spend
min $98.00max $184.00
By model
- 1gpt-4.12,400USD
- 2o31,100USD
- 3text-embedding-3-small620USD
Command Tiles
ProSample · not your account. The agent puts the ask on the board. You answer there. How Command Tiles work
Pause at 80% spend
Needs youApproval · OpenAI
Pause new jobs at 80% of the month budget?
Budget is 82%. Next?
Needs youQuestion · OpenAI
Month-to-date spend is 82% of the monthly budget. What next?
Tiles
- Spend today
- Month spend
- Daily spend
- By model
- Usage limitneeds you
- Spend today. The current UTC day's costs bucket.
- Usage limit. Month spend against OPENAI_MONTHLY_BUDGET. At or above 80% asks a person.
State map
- Spend today. value = today's UTC costs bucket in dollars. delta only when you stored yesterday's total. needs_you stays false.
- Month spend. value = sum of cost buckets since the 1st (UTC). Subtitle names the budget when OPENAI_MONTHLY_BUDGET is set. needs_you stays false (Usage limit carries the ask).
- Daily spend. One point per UTC day from the costs buckets. Post only days OpenAI returns.
- By model. Rank month-to-date costs by line_item, input and output merged per model. Ranking only.
- Usage limit. At or above 80% of OPENAI_MONTHLY_BUDGET -> "needs_you" with needs (kind "approval"). Below -> "idle" with the percent. No budget set -> "idle", task "No budget set". Never "done". 401/403 -> "blocked" with a blocker needs. Needs you: Month spend is 82% of the $5,000 budget. Raise it or slow usage?
Verify
The agent runs these on the first run, then reports.
- GET https://www.botopticon.com/api/catalog with the token -> 200. A 401 means the token is wrong, revoked, or still the placeholder.
- POST each body to https://www.botopticon.com/api/ingest?dry_run=1 (or post_tile with dry_run true). On board_not_found, stop and ask me; don't switch boards. On a validation error or warning (title or subtitle too long, weak title), fix that body and dry-run it again.
- Post for real. Each reply has ok true, a pane_id, and board_name "OpenAI spend".
- Call list_tiles (or open the board): 5 tiles on "OpenAI spend", none stale.
- Then tell me those four results in one short message.
Keep it current
A small script, not an LLM loop. It runs every 30 minutes for today, once an hour for the month and models. It posts to “OpenAI spend” only when a tile changes, and reads BOTOPTICON_TOKEN and OPENAI_ADMIN_KEY and OPENAI_MONTHLY_BUDGET from the environment.
An LLM routine every few minutes spends your usage and adds nothing new.
Setup
01
Make an OpenAI Admin key
An organization Owner opens platform.openai.com > Settings > Organization > Admin keys and creates one named Botopticon board, read-only if offered. A full Admin key can manage the org, so the agent only makes GET calls to usage and costs. Keep it in OPENAI_ADMIN_KEY and your monthly budget in dollars in OPENAI_MONTHLY_BUDGET. Botopticon never stores this key. Paste it into the agent, cron host, or MCP config. Revoke it any time.
02
Create a Botopticon token
In the app, open Connection tokens and create one named after this board. It starts with bot_ and is shown once. Save it as BOTOPTICON_TOKEN where the agent runs. It posts to Botopticon. It is not the OpenAI key.
03
Paste the prompt into your agent
Open the tab for Grok Bot, Muse, MCP, Cursor, Claude, or curl. The agent checks the token, dry-runs every tile, posts to the OpenAI spend board, and reports back.
04
Let the script keep it current
The agent writes a small script that checks every 30 minutes (the month and models once an hour) and posts only what changed. A quiet tile overnight is normal.
Snippets
Read BOTOPTICON_TOKEN from your environment or secret store. If it isn't set, stop and ask me. Never send the text $BOTOPTICON_TOKEN. If I paste a token in chat, save it as BOTOPTICON_TOKEN and don't repeat it.
Same recipe, one tab per platform. The prompt fetches the source and posts. Do not paste the sample numbers as live data.
Click Use this recipe first so the board exists.
Paste this into Grok Bot. Set BOTOPTICON_TOKEN in its environment or secret store first.
1. Goal
Keep my Botopticon board "OpenAI spend" current with live OpenAI data.
Any agent that can make HTTPS calls can do this. You report; I decide.
2. Connect
- Botopticon token (starts with bot_): Read BOTOPTICON_TOKEN from your environment or secret store. If it isn't set, stop and ask me. Never send the text $BOTOPTICON_TOKEN. If I paste a token in chat, save it as BOTOPTICON_TOKEN and don't repeat it.
- HTTP (works everywhere): POST https://www.botopticon.com/api/ingest
Headers: Authorization: Bearer <token>, Content-Type: application/json
- MCP (optional, same token): https://www.botopticon.com/api/mcp, tool post_tile. If an MCP tool returns HTML or an error, use HTTP.
3. Source access
OpenAI: read OPENAI_ADMIN_KEY, OPENAI_MONTHLY_BUDGET from your environment (OpenAI Admin key, usage and costs read). If one isn't set, ask me.
Only an OpenAI organization Owner can make this key: platform.openai.com > Settings > Organization > Admin keys > Create new admin key. Name it Botopticon board and choose read-only permissions if the form offers them. A full Admin key can also manage projects, members, and API keys, so the agent only makes GET calls to the usage and costs endpoints with it. A project key (sk-proj-) can't read org spend. Put your monthly budget in dollars in OPENAI_MONTHLY_BUDGET (for example 500). The costs API doesn't return a budget, so without it Usage limit stays idle.
Scopes: Read-only permissions, if the form offers them.
Botopticon never stores this key. Paste it into the agent, cron host, or MCP config. Revoke it any time.
4. Board
Send "board": "OpenAI spend" on every post. On a Free workspace with one board, posts land on that board, and the reply warns board_ignored_free when the names differ.
5. Tiles
Bot "OpenAI" on every tile. Never change the tile keys.
- spend-today, kpi, "Spend today". The current UTC day's costs bucket. States: value = today's UTC costs bucket in dollars. delta only when you stored yesterday's total. needs_you stays false. ttl_seconds 43200.
- spend-month, kpi, "Month spend". States: value = sum of cost buckets since the 1st (UTC). Subtitle names the budget when OPENAI_MONTHLY_BUDGET is set. needs_you stays false (Usage limit carries the ask). ttl_seconds 86400.
- spend-7d, trend, "Daily spend". States: One point per UTC day from the costs buckets. Post only days OpenAI returns. ttl_seconds 86400. needs_you stays false.
- by-model, leaderboard, "By model". States: Rank month-to-date costs by line_item, input and output merged per model. Ranking only. ttl_seconds 86400. needs_you stays false.
- near-limit, status, "Usage limit". Month spend against OPENAI_MONTHLY_BUDGET. At or above 80% asks a person. States: At or above 80% of OPENAI_MONTHLY_BUDGET -> "needs_you" with needs (kind "approval"). Below -> "idle" with the percent. No budget set -> "idle", task "No budget set". Never "done". 401/403 -> "blocked" with a blocker needs. ttl_seconds 43200. When a person must act: needs_you true and needs {"who":"OpenAI","kind":"approval","ask":"Month spend is 82% of the $5,000 budget. Raise it or slow usage?","link":"https://platform.openai.com/settings/organization/limits"}.
6. Fetch notes
Read the current OpenAI Admin API docs for Usage and Costs. Base https://api.openai.com/v1, header Authorization: Bearer <OPENAI_ADMIN_KEY>. Only GET calls. Objects: daily cost buckets (amount.value in USD, line_item), usage buckets by model.
Costs come in 1-day UTC buckets only. Use costs for every dollar figure; never estimate cost from tokens.
Spend today. The current UTC day's bucket as format currency. Subtitle "UTC day so far". delta only when you stored yesterday's total.
Month spend. Sum of buckets from the 1st of the month (UTC) through today. Subtitle "of $<budget> budget" when OPENAI_MONTHLY_BUDGET is set, else "Month to date · UTC".
Daily spend. One point per UTC day for the last 7 days from the same costs call. OpenAI stores these, so reading all 7 is fine.
By model. Month-to-date costs grouped by line_item. Line items read like "gpt-4.1, input"; merge input and output under the text before the comma. Label 64 characters. Ranking only.
Usage limit. p = month spend / OPENAI_MONTHLY_BUDGET. p at or above 80% -> state "needs_you", needs_you true, needs {"who":"OpenAI","kind":"approval","ask":"Month spend is <p>% of the $<budget> budget. Raise it or slow usage?","link":"https://platform.openai.com/settings/organization/limits"}. Below 80% -> state "idle", task "<p>% of the $<budget> budget". OPENAI_MONTHLY_BUDGET not set -> state "idle", task "No budget set", no needs. Never "done". Don't invent a budget. OpenAI answers 401 or 403 -> state "blocked", task "Admin key rejected", needs {"who":"OpenAI","kind":"blocker","ask":"Replace OPENAI_ADMIN_KEY"}.
- Spend, month, and trend: GET /organization/costs?start_time=<1st of month 00:00 UTC>&bucket_width=1d&limit=31; follow next_page while has_more.
- By model: the same call with group_by=line_item.
- Token counts (optional, for the label only): GET /organization/usage/completions?start_time=<unix>&bucket_width=1d&group_by=model.
- Look-back: Nothing short-lived to miss: costs are daily UTC buckets. Each run, re-read every bucket since your last run plus yesterday's, because a day's total can still change after midnight UTC.
7. Posting rules
Fields: bot, tile, type, title, subtitle, props, needs_you, needs, ttl_seconds, board, brief (link optional). Send the full body each time; a post without needs or link clears it.
needs is required whenever needs_you is true: {"who","kind":"task|issue|question|blocker|approval","ask"} (link and detail optional).
Limits: title shows 24 characters (max 80). Subtitle shows 48 (cut at 80). Row labels 64. Feed labels 280. needs.ask 140 on one line. needs.who 48.
Post a tile only when its body changes. Do not invent numbers. Do not post the same body again just to keep a tile fresh.
8. Verify on the first run
a) GET https://www.botopticon.com/api/catalog with the token -> 200. A 401 means the token is wrong, revoked, or still the placeholder.
b) POST each body to https://www.botopticon.com/api/ingest?dry_run=1 (or post_tile with dry_run true). On board_not_found, stop and ask me; don't switch boards. On a validation error or warning (title or subtitle too long, weak title), fix that body and dry-run it again.
c) Post for real. Each reply has ok true, a pane_id, and board_name "OpenAI spend".
d) Call list_tiles (or open the board): 5 tiles on "OpenAI spend", none stale.
e) Then tell me those four results in one short message.
9. Keep it current
Write a small script (no LLM in the loop). Run it every 30 minutes for today, once an hour for the month and models. Use cron or a loop that holds a lock. It keeps a hash of each body, posts only the tiles that changed, retries once on 429 or 5xx, stops re-posting a body that got a 4xx, reads BOTOPTICON_TOKEN and OPENAI_ADMIN_KEY and OPENAI_MONTHLY_BUDGET from the environment, never logs them, and has a --dry flag.
Don't set up an LLM routine that runs every few minutes; it spends my usage and adds nothing.
On the board, a quiet tile with an old "updated" time is normal. A stale tile means your script stopped.
10. Report back
One short message: the token check, the dry-run result, each pane_id, the board name, and the schedule you chose.
FAQ
- Which pane turns amber?
- Usage limit, when month-to-date spend reaches 80% of the budget you set in OPENAI_MONTHLY_BUDGET: raise it or slow usage. Without a budget it stays idle; the agent never invents one. If the costs endpoints return 403, the key isn't an Admin key with usage access, and the tiles say so instead of guessing.
- Does this run on the Free plan?
- Yes. Every tile in this recipe is a Free type. A Free workspace still has one board and 8 live tiles. Using this recipe adds the sample tiles to that board.
- Does Botopticon store the OpenAI key?
- Botopticon never stores this key. Paste it into the agent, cron host, or MCP config. Revoke it any time.
- How does the board stay current?
- A small script fetches the source and posts a tile only when its body changes. A quiet tile is fine: nothing changed. A stale tile means the agent stopped checking. Fifteen minutes after a tile goes stale it leaves the board, and it comes back on the next post.
- Why did a tile leave the board?
- Three reasons. A progress tile with every row finished leaves 5 minutes later. A status tile set to done leaves 5 minutes later. A stale tile leaves 15 minutes after it goes stale. The next post brings it back.