Skip to main content

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](https://img.shields.io/badge/License-AGPL\_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)

[![PyPI version](https://img.shields.io/pypi/v/runcost?v=0.3)](https://pypi.org/project/runcost/)

[![GitHub Stars](https://img.shields.io/github/stars/Picasso976/runcostai?style=social)](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


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)

Uploaded Source

Built Distribution

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

runcost-0.3.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

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

Hashes for runcost-0.3.1.tar.gz
Algorithm Hash digest
SHA256 6eab0dab9091ed5af5643ff4bf070c872a64c6ab46576fb45e779eed6028a5eb
MD5 9093da094cec4f872c69155a15c1745f
BLAKE2b-256 d81773dcb9d7414b3fe082717c952e2aecda46395d0718787af19a534dae02f6

See more details on using hashes here.

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

Hashes for runcost-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5abf76690ba0abe0abc51a4cfc2cd640c762ab525de896f140ebf4dd32355db
MD5 0287b9d6a74472367e684080924b5163
BLAKE2b-256 b54d093c806212196579bf28132b82a7ee71043d0b5b606a8f7d95c4b63ad33b

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