LLMSpend: Open-source cost tracker for Anthropic and OpenAI SDKs

What LLMSpend does
LLMSpend is a Python package that monitors API usage costs for Anthropic and OpenAI SDKs. It was created because the Anthropic dashboard only shows total spend without breaking it down by feature. The tool tracks tokens, cost, and latency per call, grouping data by feature, model, user, or project.
How to use it
Install with pip install llmspend. Integration requires two lines of code:
from llmspend import monitor
client = monitor.wrap(anthropic.Anthropic(), project="my-app")
Then add an llmspend parameter to track specific features:
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1000,
messages=[{"role": "user", "content": query}],
llmspend={"feature": "chatbot"}
)
Reporting and dashboard
From the terminal, run llmspend stats --last 7d --by feature to get output like:
Total: $4.2100 across 847 calls
chatbot 512 $2.8900 1180ms
summarizer 335 $1.3200 640ms
Run llmspend dashboard to open a local web dashboard at localhost:8888.
Technical details
- Local SQLite storage — no account needed, no data leaves your machine
- Works with both Anthropic and OpenAI SDKs
- Zero dependencies (pure Python standard library)
- Never stores prompts or responses — only tracks cost metrics
- No prompt logging, tracing, or evaluations — focused solely on cost tracking
- MIT licensed, open source on GitHub
The tool was built entirely with Claude Code in a single session, with Claude writing the monkey-patching logic, pricing engine, CLI, and web dashboard.
📖 Read the full source: r/ClaudeAI
👀 See Also

GrapeRoot tool reduces Claude Code costs by 45% with pre-scanned repository context
A free tool called GrapeRoot that pre-scans repositories and builds dependency graphs reduced Claude Code costs by 45% on average across 10 engineering tasks while improving response quality by 13%. The tool eliminates exploration loops that normally consume tokens.

BrightBean Studio: Open-source social media management platform built with AI agents
BrightBean Studio is an open-source, self-hostable social media management platform that supports 10+ platforms with direct first-party API integrations. It was built in 3 weeks using Claude and Codex.

Mind Keg MCP: Persistent Memory for Claude Code and MCP-Compatible Agents
Mind Keg MCP v0.1.1 is an open-source MCP server that provides persistent memory for Claude Code and other MCP-compatible agents. It stores learnings locally via SQLite and retrieves them via semantic search, allowing AI coding assistants to remember context between sessions.

Building a Persistent AI Knowledge Infrastructure with OpenClaw
A developer built 'Brain'—a central knowledge service with local RAG, multi-agent coordination, and a typed plugin system—to solve the statelessness problem in AI setups. The system runs entirely on local hardware using Ollama, Postgres, MongoDB, Qdrant, and Memgraph.