Skip to main content

Agent Wallet SDK

Python SDK for the Agent Wallet API - secure financial operations for AI agents.

Installation

pip install agent-wallet

Quick Start

from agent_wallet import WalletClient

# Initialize the client
client = WalletClient(
    api_key="aw_your_api_key_here",
    base_url="http://localhost:8000"
)

# Check your balance
balance = client.balance()
print(f"Available: {balance.available} {balance.currency}")
print(f"Held: {balance.held} {balance.currency}")
print(f"Total: {balance.total} {balance.currency}")

Features

  • Type-safe: Full type hints and Pydantic models for all responses
  • Idempotent: Built-in support for idempotency keys to prevent duplicate transactions
  • Retry logic: Automatic retries with exponential backoff for network errors
  • Clean exceptions: Specific exception classes for different error types

Usage Examples

Transfer Funds

transfer = client.transfer(
    to_handle="@merchant",
    amount="25.00",
    currency="USD",
    idempotency_key="unique-transfer-key-123",
    reference_id="order_456",
    metadata={"note": "Payment for order"}
)
print(f"Transfer ID: {transfer.id}")

Create and Capture a Hold

# Create a hold (reservation)
hold = client.hold(
    amount="100.00",
    currency="USD",
    idempotency_key="hold-key-789",
    expires_in_seconds=3600  # 1 hour
)
print(f"Hold ID: {hold.id}")

# Capture the hold (partial or full)
capture = client.capture(
    hold_id=hold.id,
    to_handle="@merchant",
    amount="75.00",  # Capture only $75 of the $100 hold
    idempotency_key="capture-key-101"
)

# Release the remaining hold
release = client.release(
    hold_id=hold.id,
    idempotency_key="release-key-102"
)

Payment Intents (Merchant Flow)

# Merchant creates a payment intent
intent = client.create_payment_intent(
    amount="50.00",
    currency="USD",
    expires_in_seconds=900,  # 15 minutes
    metadata={"order_id": "order_789"}
)
print(f"Payment Intent ID: {intent.id}")

# Customer pays the intent
result = client.pay_payment_intent(
    intent_id=intent.id,
    idempotency_key="pay-intent-key-103"
)

Request a Refund

refund = client.refund(
    capture_id="cap_abc123",
    amount="25.00",  # Partial refund
    idempotency_key="refund-key-104"
)
print(f"Refund ID: {refund.id}")

Exception Handling

from agent_wallet import WalletClient
from agent_wallet.exceptions import (
    InsufficientFunds,
    ForbiddenScope,
    LimitExceeded,
    RecipientNotFound,
    CurrencyMismatch,
    ConflictIdempotency,
    WalletAPIError,
)

client = WalletClient(api_key="...", base_url="...")

try:
    transfer = client.transfer(
        to_handle="@merchant",
        amount="1000000.00",
        currency="USD",
        idempotency_key="key-123"
    )
except InsufficientFunds as e:
    print(f"Not enough funds: {e.message}")
except LimitExceeded as e:
    print(f"Transaction limit exceeded: {e.message}")
except RecipientNotFound as e:
    print(f"Recipient not found: {e.message}")
except ForbiddenScope as e:
    print(f"Permission denied: {e.message}")
except CurrencyMismatch as e:
    print(f"Currency mismatch: {e.message}")
except ConflictIdempotency as e:
    print(f"Idempotency conflict: {e.message}")
except WalletAPIError as e:
    print(f"API error: {e.status_code} - {e.message}")

Configuration

Custom Timeout

client = WalletClient(
    api_key="...",
    base_url="...",
    timeout=30.0  # 30 seconds
)

Disable Retries

client = WalletClient(
    api_key="...",
    base_url="...",
    max_retries=0
)

API Reference

WalletClient Methods

Method Description
balance() Get current wallet balance
transactions(cursor, limit) List transactions with pagination
transfer(...) Transfer funds to another wallet
hold(...) Create a hold/reservation
capture(...) Capture a hold
release(...) Release a hold
create_payment_intent(...) Create a payment intent
pay_payment_intent(...) Pay a payment intent
refund(...) Request a refund

License

MIT License

Metadata

Release files for ai-wallet 0.1.0

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

Source distribution (sdist)

Source distribution for ai-wallet 0.1.0
File Size Uploaded Provenance
ai_wallet-0.1.0.tar.gz 9.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-wallet 0.1.0
File Interpreter ABI Platform
ai_wallet-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / ai_wallet-0.1.0.tar.gz

Download URL ai_wallet-0.1.0.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7c2e68926c716b1a5a73af3dae36106812316da4223999c883995371d3ac4e3e
BLAKE2b-256 checksum
How to use checksums
a5af093eb9d2b8f1c709d32e809a6b454c5c139a846183822358b385c2004aea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

Release files / ai_wallet-0.1.0-py3-none-any.whl

Download URL ai_wallet-0.1.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4365b341c3c807c96c9178b2ab48ccce938f17e93c0116f623842ffd7e3e054
BLAKE2b-256 checksum
How to use checksums
72d9e09578426b72d7ab6160a301bcc090bff83db32f9f4182e33e7ad037ca1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

Security for ai-wallet 0.1.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ai_wallet-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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