Skip to main content

Run a 1,000-agent simulation for $2 instead of $200. 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.

License: AGPL v3 PyPI version GitHub Stars Twitter Follow


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. You just get an email from OpenAI.

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 MiroFish sim $197.40 $2.10 98.9%
500-agent CrewAI workflow $43.20 $4.80 88.9%
AutoGen research pipeline $18.70 $1.90 89.8%
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.

A web dashboard is coming in v0.3. Join the waitlist โ†’


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

Join the Pro waitlist at cost.run โ†’


Roadmap

Status Feature
โœ… OpenAI SDK wrapper
โœ… Groq / Llama-3 auto-routing
โœ… Recursive loop detection
โœ… Hard budget limits
โœ… SQLite call logging
โœ… Live terminal dashboard
๐Ÿ”œ Web dashboard (v0.3)
๐Ÿ”œ CrewAI native plugin
๐Ÿ”œ LangGraph native plugin
๐Ÿ”œ MiroFish native plugin
๐Ÿ”œ Pre-flight cost estimator
๐Ÿ”œ Slack / Discord spend alerts
๐Ÿ”œ Team spend analytics
๐Ÿ”œ AgentLedger plugin โ€” audit trail for every agent action

Contributing

PRs welcome. See CONTRIBUTING.md.

If RunCost saved you money, a โญ on GitHub costs nothing and means everything.


The Story

I was building AI agent simulations and got hit with a $47 API bill for a single test run that didn't even produce useful output. A recursive loop had quietly fired 200 API calls before I noticed.

There was no tool that warned me. No framework stopped it. Just a bill.

RunCost is that warning. Built in public at cost.run โ€” follow the journey at @RunCostAI on X.


License

AGPL-3.0 โ€” free for individuals and open source projects.

Commercial license available for enterprise deployments. Contact: hello@cost.run


cost.run ยท @RunCostAI ยท pip install runcost

Project details


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.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

runcost-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file runcost-0.1.1.tar.gz.

File metadata

  • Download URL: runcost-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for runcost-0.1.1.tar.gz
Algorithm Hash digest
SHA256 00029b3bdb1167e929fea1ecd79a50f7856679bc1152e78b4302b2c3eb5cf6ca
MD5 8fc6a00654380ee4b66ffb745a42b1af
BLAKE2b-256 e9cd6e9fd6901e4e1b62a99311ec6722aacc4ea98d14378154c927796a02bf3f

See more details on using hashes here.

File details

Details for the file runcost-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: runcost-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for runcost-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c665d13063176e100aa9f9f080fbb9c533e57e8979d620183788e9f5524b43d
MD5 2eb0c203aab062386d333a16d6139418
BLAKE2b-256 bc952b7e6816bde4877ba598dbef45a7c9e861018fd9b550071a6d41b4f284d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page