Drop-in cost intelligence for Python AI agent frameworks.
Project description
RunCost ๐ธ
Run a 1,000-agent simulation for $2 instead of $200. Drop-in cost intelligence for Python AI agent frameworks.
The Problem
You built a multi-agent system. It works beautifully in testing.
Then you ran it for real and saw the bill.
A 500-agent simulation on GPT-4o costs $40โ$80 per run. A recursive loop that nobody catches costs $200 before you notice. An overnight batch job you forgot about costs $600 by morning.
Nobody warns you. No framework stops it.
Multi-agent AI is the future. Uncontrolled spend is the tax on building it.
The Fix: One Line
# Before RunCost
from openai import OpenAI
client = OpenAI()
# After RunCost โ nothing else changes
from runcost import OpenAI
client = OpenAI()
Drop it in. That's it. Your existing code works exactly as before โ except now every API call is intercepted, measured, and intelligently routed before it costs you money.
What Happens When You Run It
RunCost // Live Agent Cost Monitor cost.run
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ researcher_01 โ llama-3-8b $0.001 11ms
โ analyst_04 โ gpt-4o $0.047 780ms
โ writer_02 โ mistral-7b $0.002 43ms
โ crawler_07 โ BLOCKED $0.000 loop@13
โ researcher_14 โ llama-3-8b $0.001 9ms
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Spent: $1.82 / $5.00 [==== ] 36%
Saved: $41.30 Efficiency: 95.7%
Blocked: 3 loops Calls: 847
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
RunCost intercepts every LLM call and:
- Estimates the cost before spending a dollar
- Routes simple tasks to cheap models (Groq, Llama 3, Mistral) automatically
- Routes reasoning-heavy tasks to GPT-4o or Claude only when needed
- Detects recursive loops and kills them before they drain your account
- Enforces hard spending limits โ when you hit your cap, everything stops
- Logs every call to a local SQLite database
- Shows a live terminal dashboard of spend vs. savings in real time
The Numbers
Same simulation. Same output quality. 10x cheaper.
| Workload | Without RunCost | With RunCost | Saved |
|---|---|---|---|
| 1,000-agent simulation | ~$180-$200 | ~$2-$4 | ~98% |
| 500-agent CrewAI workflow | ~$40-$80 | ~$4-$8 | ~90% |
| AutoGen research pipeline | ~$15-$20 | ~$1-$2 | ~90% |
| Recursive loop (caught) | $200+ | $0.00 | 100% |
Install
pip install runcost
Supported frameworks: OpenAI SDK ยท CrewAI ยท LangGraph ยท AutoGen ยท LangChain ยท MiroFish ยท any OpenAI-compatible client
Quick Start
from runcost import OpenAI, BudgetConfig
config = BudgetConfig(
hard_limit_usd=5.00, # Hard stop โ never exceed this per run
warn_at_usd=2.00, # Alert when approaching limit
auto_route=True, # Auto-route cheap tasks to Llama/Groq
block_loops=True, # Kill recursive agent loops instantly
log_to_db=True # Save full history to runcost.db
)
client = OpenAI(budget=config)
# Use exactly as normal โ RunCost works silently underneath
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Analyze these 500 documents"}]
)
How Routing Works
RunCost classifies each call by complexity before sending it:
| Complexity | Model Used | Typical Cost |
|---|---|---|
| Simple: formatting, lookup, summarization | Groq Llama-3 8B | ~$0.001 |
| Medium: research, extraction, classification | Mistral 7B | ~$0.002 |
| Complex: reasoning, code, multi-step logic | GPT-4o / Claude | ~$0.04โ0.09 |
| Detected loop / budget exceeded | BLOCKED | $0.000 |
You can override routing per agent, per task type, or per model preference.
The Dashboard
runcost dashboard
Opens a live terminal view showing real-time spend, savings, active agents, blocked loops, and full call history. Dark mode. No browser required.
Why Open Source?
Because every developer deserves to see exactly what their agents are spending โ before it's too late.
The core engine is AGPL-3.0. Run it yourself, audit it, fork it, build on it.
RunCost Pro (coming soon): team dashboards ยท multi-project tracking ยท SSO ยท compliance exports ยท Slack/Discord alerts ยท SLA support
Roadmap
โ OpenAI SDK wrapper โ Real-time cost tracking per call โ Hard budget limits with BudgetExceededError โ SQLite call logging โ Terminal dashboard (runcost dashboard) โ Web dashboard (runcost server) โ Pre-flight cost calculator โ DeepSeek support โ Grok / xAI support โ Auto-routing (automatic cheap model selection) โ Recursive loop detection โ Slack / Discord spend alerts ๐ Claude (Anthropic SDK) support ๐ Gemini (Google SDK) support ๐ CrewAI native plugin ๐ LangGraph native plugin
๐ AgentLedger โ audit trail for every agent action
If RunCost saved you money, a โญ on GitHub costs nothing and means everything.
License
AGPL-3.0 โ free for individuals and open source projects.
Commercial license available for enterprise deployments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file runcost-0.4.tar.gz.
File metadata
- Download URL: runcost-0.4.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9bb69ab7a410e2f000e6817e03cc6aad8f07a5297a6c4488e176c56a4329951
|
|
| MD5 |
1b189c2bee9e9d50ada3d547752db0cb
|
|
| BLAKE2b-256 |
1e56022ddc24f0cc9e8b5fe211221d8492f3f59943c42ee1a07bee0824112b1a
|
File details
Details for the file runcost-0.4-py3-none-any.whl.
File metadata
- Download URL: runcost-0.4-py3-none-any.whl
- Upload date:
- Size: 26.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8e1409fbc8119bc1a22e640ddae778139e01c57e4fb4655cd3929967ffbcae8
|
|
| MD5 |
b82ad6a1d7417dbaf643093851c99edd
|
|
| BLAKE2b-256 |
ffd9ae7f7f701c527a4f52c0f4c3afb77a21ac84f3e62d11d1541f9412393aa9
|