openai-balance

Reviewed at commit e839261 New version, not yet reviewed

Sends data to OpenAI (api.openai.com), your Admin key only, to read your own costs and usage

Your OpenAI API credit above the prompt: an estimated balance with a gauge, today's spend, where the money mostly went, and the last call. /openai-balance…

Made by
Hamza Zafar
What we checked

Shows an estimated OpenAI API credit balance, today's spend and the last model used in a band above the prompt, and /openai-balance prints a breakdown. It sends your OpenAI Admin key to api.openai.com to read your organization's costs and usage; none of your prompts or code leave the machine. It stores only the balance you set, and once per session reads a small band-order file from your Claude config folder.

Review details

Static review of the source at the pinned commit; not run. Delta review of the changes since 5657c52; the rest carries over from the review at that commit. Registers session.start (registers /openai-balance, starts a 60 second timer), turn.complete (refresh), command.run and ui.render (AbovePrompt band). Runtime calls: $.http.fetch GET to https://api.openai.com/v1/organization (costs, usage/completions, decisions, embeddings, moderations, projects and projects/<id>/api_keys for key names) with a Bearer Admin key, refreshed at most every 10 minutes; $.process.run for printenv OPENAI_ADMIN_KEY and, on macOS, security find-generic-password -s openai-admin-key -w, used only when the Admin key is not set in plugin config; $.store.get/set for the balance you set; atoms for the displayed line. The key is kept in memory only and must start with sk-admin-. Failures are shown in the band and retried after a minute. It makes no calls to other hosts and does not touch prompts or tool calls. The requests list project and API key names and ids, which an Admin key can read. Changes in this version: a new hooks/bands.ts lets several band mods stack in a shared order. Once per session the module reads CLAUDE_CONFIG_DIR and HOME with $.env.get, checks with $.fs.exists and reads <config dir or ~/.claude>/claude-code-mods/bands.json with $.fs.read, and only parses an { order: string[] } list of mod names (any error gives an empty list); the band is now wrapped in a keyed Box and sorted among other mods' bands. Nothing from that file is sent anywhere and nothing is written.

What it uses
  • Reads your prompts: no
  • Sees tool calls: no
  • Blocks or changes tool calls: no
  • Reads or writes files: yes
  • Runs programs on your machine: yes
  • Calls the model (uses tokens): no
  • Sends data over the network: yes
  • Stores data: yes
  • Shows something on screen: yes
Hooked events
Screenshot of openai-balance

Your OpenAI API credit above the prompt: an estimated balance with a gauge, today's spend, where the money mostly went, and the last call. /openai-balance shows the breakdown.

Made this mod? Add a badge to your README

modsforClaude badge for openai-balance

Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.

[![Listed on modsforClaude](https://modsforclaude.com/badge/openai-balance.svg)](https://modsforclaude.com/mods/openai-balance/)

← All mods