Skip to main content

Python SDK for LetAgentPay — AI agent spending policy middleware

Project description

letagentpay

Python SDK for LetAgentPay — AI agent spending policy middleware. Set budgets, define spending policies, and control AI agent purchases.

Installation

pip install letagentpay

Quick Start

from letagentpay import LetAgentPay

client = LetAgentPay(token="agt_xxx")

# Create a purchase request
result = client.request_purchase(
    amount=15.0,
    category="api_calls",
    description="OpenAI GPT-4 call",
)
print(result.status)  # "auto_approved" / "pending" / "rejected"

# Check budget
budget = client.check_budget()
print(f"Remaining: ${budget.remaining}")

@guard Decorator

Automatically check the spending policy before executing a function:

from letagentpay import guard

@guard(token="agt_xxx", category="api_calls", amount=0.03)
def call_openai(prompt: str) -> str:
    return openai.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": prompt}]
    ).choices[0].message.content

# Runs only if the policy allows it
result = call_openai("Analyze this document")

Environment Variables

export LETAGENTPAY_TOKEN=agt_xxx
export LETAGENTPAY_BASE_URL=https://api.letagentpay.com/api/v1/agent-api  # optional
# Token is taken from LETAGENTPAY_TOKEN
client = LetAgentPay()

Documentation

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

letagentpay-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

letagentpay-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file letagentpay-0.1.0.tar.gz.

File metadata

  • Download URL: letagentpay-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for letagentpay-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63718156d475eef98cc297a3f4a3a50ef48d81971c7f5e9cdb880767b55aa449
MD5 d3cf1a90fa94a2db46a1c63d8804761b
BLAKE2b-256 27381764f3c9b0dae8c87dadf32f3cf393d4398bfa7a4613f662396de9e1547b

See more details on using hashes here.

Provenance

The following attestation bundles were made for letagentpay-0.1.0.tar.gz:

Publisher: publish.yml on LetAgentPay/letagentpay-python

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

File details

Details for the file letagentpay-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: letagentpay-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for letagentpay-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 331fbd0fcad682d630efaed0f443a7c53b606379df53a9179fe3e0079fae65f6
MD5 32248fa3412ea342d0417c254cf1182c
BLAKE2b-256 2ffd80d49b3c6d6428b531aac346812e8a36b27b3a34802ee32354a4973d6bfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for letagentpay-0.1.0-py3-none-any.whl:

Publisher: publish.yml on LetAgentPay/letagentpay-python

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