explaingit

mikecase/opencode-cost-monitor

Analysis updated 2026-05-18

1PythonAudience · developerComplexity · 1/5LicenseSetup · easy

TLDR

A live terminal dashboard that reads your opencode session database and shows real-time AI cost breakdown, cache savings, and daily spending trends by model.

Mindmap

mindmap
  root((opencode-cost-monitor))
    What it shows
      Cost per model
      Cache hit rate
      Daily spending trend
      Token counts
    Controls
      Time period filter
      Pricing plan toggle
      Manual refresh
    Setup
      Python virtual env
      textual library
      opencode.db file
    Audience
      Developers
      opencode users
      Cost-conscious coders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Run the monitor while working in opencode to see live cost totals and cache hit rates update as you use the AI assistant.

USE CASE 2

Press m to filter to 'Today' and check how much you have spent in the current session before continuing.

USE CASE 3

Switch between Go and Zen pricing plans with the p key to compare which subscription mode would cost less given your usage pattern.

What is it built with?

PythontextualSQLite

How does it compare?

mikecase/opencode-cost-monitora-bissell/unleash-liteabhiinnovates/whatsapp-hr-assistant
Stars111
LanguagePythonPythonPython
Setup difficultyeasyhardhard
Complexity1/54/53/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Requires an existing opencode installation with a populated opencode.db file, only one Python dependency (textual) to install.

MIT license: use, copy, modify, and distribute freely for any purpose, including commercially, as long as you keep the copyright notice.

In plain English

OpenCode Cost Monitor is a small Python tool that shows you a live dashboard in your terminal tracking how much your opencode sessions are costing. Opencode is an AI coding assistant that stores its usage data in a local database file, and this monitor reads that file every few seconds and displays up-to-date spending information without you needing to leave the terminal. The dashboard breaks down costs by AI model, showing how many sessions used each one, how many tokens were processed, and what percentage of responses came from cache rather than being generated fresh. Cache responses cost less, so the tool also calculates how much you saved compared to what the same usage would have cost without caching. A small sparkline chart at the bottom shows your daily spending over the last 30 days so you can spot if usage is trending up. You can press a key to filter by different time ranges: all time, the last 30 days, the last 7 days, or just today. Another key cycles between opencode's two pricing plans (Go and Zen) so you can see the numbers recalculated for whichever subscription you have. Setup is two commands: create a Python virtual environment, install one dependency called textual, and run the script. The tool finds the opencode database at the standard location automatically, or you can point it at a different path. The project is MIT licensed and is a single script built for developers who use opencode and want visibility into their AI usage costs as they work.

Copy-paste prompts

Prompt 1
I use opencode and want to monitor my AI costs. Walk me through installing opencode-cost-monitor, confirming where my opencode.db file is, and launching the terminal dashboard.
Prompt 2
Using the opencode-cost-monitor code as a reference, explain how the cache economics calculation works and how it computes savings compared to full-price token cost.
Prompt 3
I want to export my opencode cost data to a CSV. Using the opencode.db SQLite schema that opencode-cost-monitor reads, write a Python script that queries daily totals and writes them to costs.csv.

Frequently asked questions

What is opencode-cost-monitor?

A live terminal dashboard that reads your opencode session database and shows real-time AI cost breakdown, cache savings, and daily spending trends by model.

What language is opencode-cost-monitor written in?

Mainly Python. The stack also includes Python, textual, SQLite.

What license does opencode-cost-monitor use?

MIT license: use, copy, modify, and distribute freely for any purpose, including commercially, as long as you keep the copyright notice.

How hard is opencode-cost-monitor to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is opencode-cost-monitor for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub mikecase on gitmyhub

Verify against the repo before relying on details.