Skip to main content

Standalone AI agent warehouse cost attribution and cap enforcement

Project description

pramiti-agent-finops

Standalone AI agent warehouse cost attribution and cap enforcement. Zero dependencies -- inject any storage backend via the ICostBackend protocol.

Install

pip install pramiti-agent-finops

Quick Start

from pramiti_agent_finops import CapChecker, CapExceededError
from pramiti_agent_finops.backends import InMemoryBackend

backend = InMemoryBackend()
backend.set_cap("ws-1", "agent-1", max_usd=5.0, action="block")
backend.add_cost("ws-1", "agent-1", 6.0)

checker = CapChecker(backend)
try:
    checker.check("ws-1", "agent-1")
except CapExceededError as e:
    print(f"Blocked: {e}")
    # Blocked: Agent 'agent-1' daily warehouse cost cap exceeded: $6.0000 >= $5.0000 limit

Use action="warn" instead of "block" to issue a CapWarning (Python warning) rather than raising an exception.

API

Export Description
CapChecker Core enforcement engine. Inject any ICostBackend. Call check() to enforce and get_today_cost() to query.
ICostBackend Protocol for storage backends. Requires get_cap() and get_today_cost().
InMemoryBackend In-memory backend for testing and development. Provides set_cap(), add_cost(), reset_cost().
CapExceededError Raised when an agent exceeds its daily cost cap (action="block").
CapWarning Python UserWarning issued when cap exceeded with action="warn".

Custom Backend

Implement ICostBackend (structural subtyping via Protocol -- no inheritance required) to use your own storage:

from pramiti_agent_finops.backends import ICostBackend

class MyBackend:
    def get_cap(self, workspace_id: str, agent_id: str) -> dict | None:
        """Return {"max_usd_per_day": float, "action_on_breach": "block"|"warn"} or None."""
        ...

    def get_today_cost(self, workspace_id: str, agent_id: str) -> float:
        """Return total warehouse cost in USD for agent today (midnight UTC to now)."""
        ...

License

MIT -- Pramiti Labs

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

pramiti_agent_finops-0.2.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

pramiti_agent_finops-0.2.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file pramiti_agent_finops-0.2.0.tar.gz.

File metadata

  • Download URL: pramiti_agent_finops-0.2.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pramiti_agent_finops-0.2.0.tar.gz
Algorithm Hash digest
SHA256 22559f78419ff83d25ef720551a11b4d802cb2919682ae4ecf36bc9b592a2b6f
MD5 7eb03db3335dbf48ee5af99e25cda15f
BLAKE2b-256 b57d6481687282870432aaa62a7dae159f8b75152598715ecd13b68942ee217e

See more details on using hashes here.

File details

Details for the file pramiti_agent_finops-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pramiti_agent_finops-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pramiti_agent_finops-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23299132ec7503004764fcb3b5aae2c108865c9ad031c3f5f23716d324565dd2
MD5 b6dd55996032a2c8c351387ccdcaecd7
BLAKE2b-256 6dbdfdcb597b13b5306e60cb2e41d3292ba38418a221a1d3d9f4b414c12590a1

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