AgentAuth Python SDK
Official Python SDK for AgentAuth - the authorization layer for AI agent purchases.
Installation
pip install agentauth-client
With LangChain support:
pip install agentauth-client[langchain]
Quick Start
from agentauth import AgentAuth
# Initialize client
client = AgentAuth(
api_key="aa_live_xxx",
base_url="https://api.agentauth.io" # or your self-hosted URL
)
# 1. Create a consent (user expresses intent)
consent = client.consents.create(
user_id="user_123",
intent="Buy flight to NYC under $500",
max_amount=500.0,
currency="USD"
)
print(f"Token: {consent.delegation_token}")
# 2. Authorize a transaction (agent requests approval)
auth = client.authorize(
token=consent.delegation_token,
amount=347.0,
currency="USD",
merchant_id="delta_airlines"
)
if auth.allowed:
print(f"✅ Authorized! Code: {auth.authorization_code}")
else:
print(f"❌ Denied: {auth.reason}")
# 3. Verify authorization (merchant confirms)
verification = client.verify(
authorization_code=auth.authorization_code,
amount=347.0,
currency="USD"
)
if verification.valid:
print(f"✅ Valid! Proof: {verification.proof_token}")
Async Support
from agentauth import AsyncAgentAuth
async def main():
client = AsyncAgentAuth(api_key="aa_live_xxx")
consent = await client.consents.create(
user_id="user_123",
intent="Buy flight",
max_amount=500.0,
currency="USD"
)
auth = await client.authorize(
token=consent.delegation_token,
amount=347.0,
currency="USD"
)
LangChain Integration
from agentauth.langchain import AgentAuthTool
# Create tool for LangChain agents
tool = AgentAuthTool(api_key="aa_live_xxx")
# Use in your agent
from langchain.agents import initialize_agent
agent = initialize_agent(tools=[tool], llm=llm)
Billing API
Manage subscriptions and usage programmatically:
from agentauth import AgentAuth
client = AgentAuth(api_key="aa_live_xxx")
# Get available billing plans
plans = client.get_billing_plans()
for plan in plans:
print(f"{plan['name']}: ${plan['price_monthly']}/mo - {plan['requests_per_month']} requests")
# Check your organization's current usage
usage = client.get_billing_usage()
print(f"Plan: {usage['plan']}")
print(f"Used: {usage['current_usage']} / {usage['limit']} requests")
print(f"Remaining: {usage['remaining']}")
# Create a checkout session to upgrade
checkout = client.create_checkout_session(
plan="growth",
success_url="https://yourapp.com/billing/success",
cancel_url="https://yourapp.com/billing/cancel"
)
print(f"Redirect user to: {checkout['checkout_url']}")
# Get billing portal for managing subscription
portal = client.get_billing_portal_url(
return_url="https://yourapp.com/dashboard"
)
print(f"Portal URL: {portal['portal_url']}")
Available Plans
| Plan | Price | Requests/month |
|---|---|---|
| Free | $0 | 1,000 |
| Startup | $99 | 50,000 |
| Growth | $499 | 500,000 |
| Enterprise | Custom | Unlimited |
License
MIT
Metadata
Release files for agentauth-client 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentauth_client-0.2.0.tar.gz | 13.4 kB | Without provenance | Details for agentauth_client-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentauth_client-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for agentauth_client-0.2.0-py3-none-any.whl |
Total release size: 29.8 kB
Release files / agentauth_client-0.2.0.tar.gz
| Download URL | agentauth_client-0.2.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
becf222432de7b59626532a1687f632b1d50e7d6556a5548fe3de9e641194213
|
|
BLAKE2b-256 checksum How to use checksums |
9ac67aa234691d652121c52b7b16df57a8e381300b23938ba9401abe2c26977b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / agentauth_client-0.2.0-py3-none-any.whl
| Download URL | agentauth_client-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2173841d8a6280a07c2b7ef420f08155ddde6cceabb3bfa118b2b86e05da3ec8
|
|
BLAKE2b-256 checksum How to use checksums |
99cdd5276bf83e434adb76385a944fbf7a252216dabf642fee7ee3a5d9e19514
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for agentauth-client 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.