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.
[](https://www.gnu.org/licenses/agpl-3.0)
[](https://pypi.org/project/runcost/)
[](https://github.com/Picasso976/runcostai)
---
## 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
```python
# 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
```bash
pip install runcost
```
**Supported frameworks:** OpenAI SDK ยท CrewAI ยท LangGraph ยท AutoGen ยท LangChain ยท MiroFish ยท any OpenAI-compatible client
---
## Quick Start
```python
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
```bash
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
runcost-0.3.1.tar.gz
(25.1 kB
view details)
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
runcost-0.3.1-py3-none-any.whl
(22.2 kB
view details)
File details
Details for the file runcost-0.3.1.tar.gz.
File metadata
- Download URL: runcost-0.3.1.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eab0dab9091ed5af5643ff4bf070c872a64c6ab46576fb45e779eed6028a5eb
|
|
| MD5 |
9093da094cec4f872c69155a15c1745f
|
|
| BLAKE2b-256 |
d81773dcb9d7414b3fe082717c952e2aecda46395d0718787af19a534dae02f6
|
File details
Details for the file runcost-0.3.1-py3-none-any.whl.
File metadata
- Download URL: runcost-0.3.1-py3-none-any.whl
- Upload date:
- Size: 22.2 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 |
f5abf76690ba0abe0abc51a4cfc2cd640c762ab525de896f140ebf4dd32355db
|
|
| MD5 |
0287b9d6a74472367e684080924b5163
|
|
| BLAKE2b-256 |
b54d093c806212196579bf28132b82a7ee71043d0b5b606a8f7d95c4b63ad33b
|