βββββββββ βββββββ ββββββ ββββββββββββββββββββ ββββββ ββββββββββββββ βββ
βββββββββββββββββββββββββββββββββββββββββββββββ βββββββ ββββββββββββββββ ββββ
βββ βββ βββββββββββββββββββ βββ βββββββ βββββββ ββββββ βββββββ
βββ βββ βββββββββββββββββββ βββ βββββ βββββββ ββββββ βββββ
βββ ββββββββββββ βββββββββββ βββ βββ βββ βββββββββββ βββ
βββ βββββββ βββ βββββββββββ βββ βββ βββ βββββββββββ βββ
Track. Control. Understand. The API cost layer for AI-native builders.
Your AI agents burn through API credits silently. You find out when the bill arrives β or when a runaway loop costs you $200 in an afternoon. ToastyKey sits between your code and every AI provider, logging every call, calculating every cent, and letting you set hard stops before the damage is done.
# Install globally
npm install -g toastykey
# Load demo data and launch
toastykey --demo
cp toastykey-demo.db toastykey.db
toastykey
# Open dashboard
open http://localhost:3000Or try without installing:
npx toastykeyReal-time API cost monitoring across all your AI providers β local, private, zero telemetry.
| Overview | Projects | Anomaly Detection |
|---|---|---|
| Live spend, charts, provider breakdown | Per-project cost attribution | Rate spikes, cost spikes, error storms |
localhost:3000 |
Auto-detected from API calls | Auto-pause before you overspend |
Try it yourself:
npm install -g toastykey && toastykey --demo && cp toastykey-demo.db toastykey.db && toastykey
Stop guessing what your AI agents cost. Every API call to every provider is intercepted, logged, and priced in real-time. See your spend for today, this week, this month β broken down by provider, project, and model.
An Apple-aesthetic React dashboard that actually looks good. Spend trend charts, provider breakdown bars, "What You Got" tangible output counters (images generated, LLM calls, audio minutes, transcriptions). Monitor Claude Code costs, OpenAI spending, and all your other AI APIs in one place.
Set a daily or monthly budget. When you hit 80%, get a warning. At 100%, ToastyKey auto-pauses the responsible provider or kills all API calls outright. No more discovering overspending after the fact.
Six trigger types that watch for unusual patterns:
- Rate Spike β sudden surge in calls per minute
- Cost Spike β spending accelerating faster than normal
- Error Storm β >50% of calls failing at once
- Token Explosion β a single call using 10Γ your average tokens
- Silent Drain β API calls happening when nothing should be running
- New Provider β your code suddenly calling a provider you've never used
Each trigger can log, notify, webhook, auto-pause, or auto-kill.
Store all your API keys in one place, encrypted with AES-256-GCM. Auto-detect keys from .env files across your filesystem. Keys never leave your machine.
"How much have I spent today?" β βΉ2,847
"Set my daily budget to βΉ5,000" β Done
"Which project is costing the most?" β toastykey-dev: βΉ738
ToastyKey exposes 13 MCP tools directly to Claude Code. Your AI assistant can query its own API costs, set budgets, and get optimization recommendations β all without leaving the conversation.
Everything stored in SQLite on your machine. No cloud account, no API key for ToastyKey itself, no telemetry, no data ever sent anywhere. Works offline.
| Provider | Status | Proxy Route | Tracked Metrics |
|---|---|---|---|
| OpenAI | β Native | /openai/* |
Tokens, cost, model, images, audio |
| Anthropic | β Native | /anthropic/* |
Input/output tokens, cost, model |
| ElevenLabs | β Native | /elevenlabs/* |
Characters, audio minutes, voice |
| Cartesia | β Native | /cartesia/* |
Audio duration, model |
| Replicate | β Native | /replicate/* |
Predictions, compute time |
| Stability AI | β Native | /stability/* |
Images, steps, credits |
| Any REST API | β Generic | /custom/:name/* |
Request count, latency |
Your Code
β
βΌ
ToastyKey Proxy (localhost:4000)
β βββββββββββββββββββββββββββββββββββββββ
β β 1. Intercept request β
β β 2. Check budget (block if exceeded)β
β β 3. Forward to real API β
β β 4. Parse response, calculate cost β
β β 5. Log to SQLite β
β β 6. Check anomaly triggers β
β βββββββββββββββββββββββββββββββββββββββ
β
βΌ
Real API Provider (OpenAI, Anthropic, etc.)
β
βΌ
Your Code gets the response (unchanged)
Change one line in your code:
# Before (OpenAI example)
- OPENAI_BASE_URL=https://api.openai.com/v1
# After β all calls now tracked
+ OPENAI_BASE_URL=http://localhost:4000/openai/v1That's it. No SDK changes, no code refactoring. The proxy is transparent.
Add to your Claude Code settings.json:
{
"mcpServers": {
"toastykey": {
"command": "node",
"args": ["/path/to/toastykey/src/index.js", "mcp"]
}
}
}Or use the Settings page in the dashboard β it generates the config snippet automatically.
| Tool | What It Does |
|---|---|
get_spend_summary |
Today/week/month spend with provider breakdown |
get_project_cost |
Cost for a specific project directory |
get_session_cost |
Cost for the current Claude Code session |
set_budget |
Create/update a budget (global, project, or session) |
get_budget_status |
Check remaining budget and alert status |
list_keys |
List all stored API keys (no values exposed) |
add_key |
Store a new API key in the encrypted vault |
get_anomaly_log |
Recent anomaly detection events |
get_provider_stats |
Per-provider breakdown with costs and call counts |
get_cost_breakdown |
Detailed cost breakdown by model and time period |
pause_provider |
Pause all calls to a specific provider |
resume_provider |
Resume a paused provider |
get_recommendations |
AI-powered cost optimization suggestions |
toastykey # Start (with quick .env scan)
toastykey --no-scan # Start immediately, skip scan
toastykey --demo # Generate demo database
toastykey --port 5000 # Use custom port
toastykey scan # Manually scan for new API keys
toastykey config # Re-run setup wizard
toastykey watch list # Show watched directories
toastykey watch add ~/code # Watch directory for new projects
toastykey reset # Reset all configuration| Feature | ToastyKey | Helicone | Portkey | LiteLLM |
|---|---|---|---|---|
| Local-first | β | β Cloud | β Cloud | β |
| Free forever | β | Freemium | Freemium | β |
| MCP native | β | β | β | β |
| Visual dashboard | β | β | β | β CLI |
| Anomaly detection | β | β | β | β |
| Encrypted key vault | β | β | β | β |
| Budget auto-pause | β | β | Partial | Partial |
| Any REST provider | β Generic | Limited | Limited | β |
| Zero telemetry | β | β | β | β |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ToastyKey β
β β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββ β
β β Proxy β β Dashboard β β MCP β β
β β :4000 β β :3000 β β Server β β
β β β β React + Viteβ β β β
β β /openai β β β β 13 tools β β
β β /anthropic β β Overview β β β β
β β /elevenlabs β β Projects β β Claude β β
β β /cartesia β β Key Vault β β Code β β
β β /replicate β β Triggers β β β β β
β β /stability β β Reports β β ToastyKeyβ β
β β /custom β β Settings β β β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ βββββββββββββ β
β β β β
β βββββββββββ¬ββββββββββ β
β βΌ β
β βββββββββββββββββ β
β β SQLite DB β β
β β (local only) β β
β β β β
β β api_calls β β
β β projects β β
β β sessions β β
β β budgets β β
β β triggers β β
β β api_keys β β
β βββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Tech Stack:
- Backend: Node.js + Express, SQLite (better-sqlite3), Socket.io
- Dashboard: React 18, Vite, Tailwind CSS, Recharts, Lucide
- MCP: @modelcontextprotocol/sdk
- Security: AES-256-GCM key encryption (Node.js crypto)
- Pricing: Custom engine with model-level pricing for all providers
npm install -g toastykey
toastykeygit clone https://github.com/Knitefyre/toastykey.git
cd toastykey
npm install
npm run dashboard:install
npm run dashboard:build
npm startnpm run dashboard:install
npm run dev # Starts both proxy (4000) and Vite dashboard (3000)Config stored at ~/.toastykey/config.json. Override with:
TOASTYKEY_PORT=5000 toastykey # env var
toastykey --port 5000 # CLI flag
echo '{"port":5000}' > .toastykey.json # local file# Run all 148 tests
npm test
# Run tests with coverage
npm test -- --coverage
# Inspect the database
sqlite3 toastykey.db ".tables"
sqlite3 toastykey.db "SELECT * FROM api_calls LIMIT 5"
# Run just the MCP server (for Claude Code integration)
npm run mcpWe welcome contributions! Please read CONTRIBUTING.md before submitting a PR.
Quick contribution guide:
- Fork the repository
- Create a feature branch:
git checkout -b feat/my-feature - Make your changes + add tests
- Run
npm testβ all tests must pass - Submit a PR against
main
See CODE_OF_CONDUCT.md for community standards.
API keys stored in the vault are encrypted with AES-256-GCM before being written to disk. The encryption key is derived from your machine's unique identifier and never stored in plaintext.
Found a security issue? Please report it privately β see SECURITY.md.
MIT License β premmuditc
See LICENSE for full text.