Skip to main content

agentcap

agentcap is a cost guardrail for LLM agent runs. It calculates safe token limits before execution and enforces strict budget ceilings using real usage data.


Github: https://github.com/OliverIida/agentcap

PyPI: https://pypi.org/project/agentcap/


Install

pip install agentcap

Example usage

from agentcap import AgentCap

prompt = "Write 2 lines about Tallinn."

cap = AgentCap(
    model="gpt-5",
    budget_usd=0.05,
)

plan = cap.plan(prompt_text=prompt)

# Pass plan.max_output_tokens into your LLM call

actual_cost = cap.finalize(
    prompt_tokens=response_prompt_tokens,
    output_tokens=response_output_tokens,
)

print("Actual cost (USD):", actual_cost)

Documentation

https://github.com/OliverIida/agentcap/blob/main/DOCUMENTATION.md


Supported models

https://github.com/OliverIida/agentcap/blob/main/agentcap/models.json To add more models, open a PR.

Note: Prices may change. Please verify with the provider.


Model pricing sources

OpenAI pricing: https://developers.openai.com/api/docs/pricing?latest-pricing=standard
Anthropic pricing: https://platform.claude.com/docs/en/about-claude/pricing
Gemini pricing: https://ai.google.dev/gemini-api/docs/pricing#standard

Release files for agentcap 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentcap 0.1.1
File Size Uploaded
agentcap-0.1.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentcap 0.1.1
File Interpreter ABI Platform
agentcap-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / agentcap-0.1.1.tar.gz

Download URL agentcap-0.1.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
09d5bbeac86a5de6a16ed439a6c5e35a1d92ee590c97c31a85c8b3cfe5e5f048
BLAKE2b-256 checksum
How to use checksums
ce4c242c8e3c6cee75ecdf18ee41ba2ccb9a79894103bb401f6d26d2e1dcee38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / agentcap-0.1.1-py3-none-any.whl

Download URL agentcap-0.1.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c385b39bfccd00f2d7962f66d7cd9590bc2fee872715583860ab9e7f3eb0f33
BLAKE2b-256 checksum
How to use checksums
08a40d533d8270e42f4a8ac14f2885bc590b1ca36c6d5397d42bde9f847fa48c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page