Skip to main content

Python SDK for AgentAuth - Authorization layer for AI agent purchases

Project description

AgentAuth Python SDK

The official Python SDK for AgentAuth - the authorization layer for AI agent purchases.

Installation

pip install agentauth

For LangChain integration:

pip install agentauth[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)

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

agentauth_client-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

agentauth_client-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agentauth_client-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for agentauth_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 959db0651329a34b17f39c5e6e9f5a1586bb1481ac4b871620a9971551b6f74b
MD5 3f2e8f2e13fe88b6f51e2658d63386ca
BLAKE2b-256 7ecadac9eeb66abef2fa559292f99338b3860ac12f43f7e31fe44bad7cdca146

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agentauth_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6e93f06a50cb34aff259127106541eef3f395af91a66e25def7a2f94b3f23b5
MD5 e9921cda738ac36d99cab2627d15c4aa
BLAKE2b-256 1d5c885c1b5a23460569d6750811806ec3af6e6494a6afd7ffb0e13342cd2af5

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