Skip to main content

AI Agent Cost Governance โ€” budget enforcement, per-tool cost tracking, multi-tenant workspaces

Project description

๐Ÿ›ก agent-gov

AI Agent Cost Governance Platform

PyPI version Python versions License: MIT

A reverse proxy that tracks, budgets, and controls what your AI agents spend. Like a credit card with limits โ€” but for your agents.


What Problem Does This Solve?

AI agents call expensive tools (LLMs, browsers, APIs, email services). Without controls:

  • A recursive agent burns โ‚น5,000 in one night on GPT-4
  • A buggy loop sends 10,000 emails before you notice
  • You discover the bill when your credit card statement arrives

agent-gov sits between your agents and their tools. Every call goes through us. We check budgets, track costs, and auto-pause overspending agents.


Quick Start

1. Install

pip install agent-gov-saas

2. Start the server

agent-gov start

Server starts at http://localhost:8000.

Alternatively, use Docker: docker compose up (see GitHub repo for docker-compose.yml).

3. Register an Agent

curl -X POST http://localhost:8000/agents/register \
  -H "Content-Type: application/json" \
  -d '{"name": "My Bot", "daily_budget": 500}'

Response:

{
  "api_key": "ag-abc123...",
  "name": "My Bot",
  "daily_budget": 500,
  "message": "Save this API key โ€” it won't be shown again!"
}

4. Route Agent Calls Through the Proxy

Instead of calling tools directly, your agent calls our proxy:

# BEFORE (no governance):
response = call_openai(prompt)

# AFTER (with agent-gov):
gov_response = requests.post("http://localhost:8000/proxy/call", json={
    "agent_key": "ag-abc123...",
    "tool_name": "openai-gpt4",
    "estimated_cost": 12.50   # โ‚น12.50 for this call
})
if gov_response.status_code == 429:
    print("Budget exceeded! Agent auto-paused.")
else:
    response = call_openai(prompt)  # Proceed with actual call

5. Watch the Dashboard

Open http://localhost:8000/dashboard โ€” live view of all agents, their spend, and budget status.

6. (Optional) Pre-Register Common Tools

# Register 24 common AI tools with realistic costs (โ‚น)
python seed_tools.py

# Preview before registering:
python seed_tools.py --list

API Reference

Method Endpoint Description
GET / Health check + stats
POST /agents/register Create agent, get API key
POST /proxy/call Proxy a tool call (budget checking + real cost lookup)
POST /agents/{key}/resume Resume a paused agent (resets budget)
POST /agents/{key}/reset Reset daily budget counters (no unpause)
POST /workspaces Create a workspace (returns API key)
GET /workspaces List all workspaces
POST /tools/register Register a tool with its known cost per call
GET /tools List all registered tools
GET /analytics/tools Per-tool spend statistics
GET /dashboard Live HTML dashboard
GET /docs Interactive OpenAPI docs (Swagger)

Features

Feature What it does
Budget enforcement Auto-pause agents that exceed their daily budget
Tool registry Register tools with known costs โ€” agents can't lie about pricing
Real cost lookup Proxy uses registered tool cost, not client estimate
Per-tool analytics See spend broken down by tool, not just by agent
Daily auto-reset Budgets reset automatically at midnight
Multi-tenancy Workspaces for teams, projects, or clients
Dashboard Live HTML dashboard with per-agent and per-tool views
CLI agent-gov start / status / version
Docker Ready-to-run Docker Compose setup

Architecture

Agent (your code)
    โ”‚
    โ”‚ POST /proxy/call { agent_key, tool_name, estimated_cost }
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         agent-gov             โ”‚
โ”‚                                โ”‚
โ”‚  1. Auth: Is key valid?       โ”‚
โ”‚  2. Budget: Will this exceed? โ”‚
โ”‚  3. Log: Track cost + tool    โ”‚
โ”‚                                โ”‚
โ”‚  If approved โ†’ return 200     โ”‚
โ”‚  If denied  โ†’ return 429     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚
    โ”‚ Agent calls actual tool
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Actual Tool (OpenAI, etc.)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Technology Stack

Component Technology Why
API Framework FastAPI Fast, async, auto-docs
Validation Pydantic Type-safe input validation
Server Uvicorn Production ASGI server
Storage SQLite via aiosqlite Persistent, zero setup
Templates Jinja2 Server-rendered dashboard
Tool Registry SQLite + UPSERT Known tool costs, agents can't lie
Workspaces SQLite + migrations Multi-tenancy with workspace isolation
Testing pytest + httpx Fast, isolated tests

License

MIT

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

agent_gov_saas-0.5.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

agent_gov_saas-0.5.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file agent_gov_saas-0.5.1.tar.gz.

File metadata

  • Download URL: agent_gov_saas-0.5.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agent_gov_saas-0.5.1.tar.gz
Algorithm Hash digest
SHA256 e117f7d167e1f3680aa76d62cd44587b0cb4b73de62619e28ea0cda07d3ea591
MD5 9afa966053f7258a574e8ac06aa241f6
BLAKE2b-256 a02c2e2fc5e74b5b67f143e06380628295b130959ad83516f159fe45a722009d

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_gov_saas-0.5.1.tar.gz:

Publisher: publish.yml on sschelliah2026-source/agent-gov

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_gov_saas-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: agent_gov_saas-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agent_gov_saas-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91cc8085906f4484786ed64cd1099c0c2ff39efefac31c9e78bfc2254aa1cd75
MD5 ced0b42154c0352e1b5507e3cfa09c88
BLAKE2b-256 3800f7638785b67ade05544617cdc1acc756200d4391001de2e1689c32b96eac

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_gov_saas-0.5.1-py3-none-any.whl:

Publisher: publish.yml on sschelliah2026-source/agent-gov

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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