Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

langchain-ampersend

LangChain integration for Ampersend x402 payments. Call remote A2A agents with automatic payment handling.

Installation

pip install langchain-ampersend

Usage

from langchain_ampersend import (
    A2AToolkit,
    AmpersendTreasurer,
    ApiClient,
    ApiClientOptions,
    SmartAccountWallet,
)
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI

# Setup Ampersend API client
api_client = ApiClient(ApiClientOptions(
    base_url="https://api.ampersend.ai",
    session_key_private_key="0x...",  # Your session key
))

# Setup wallet (smart account)
wallet = SmartAccountWallet(
    owner_private_key="0x...",
    smart_account_address="0x...",
)

# Create treasurer
treasurer = AmpersendTreasurer(api_client=api_client, wallet=wallet)

# Create toolkit for a remote agent
toolkit = A2AToolkit(
    remote_agent_url="https://agent.example.com",
    treasurer=treasurer,
)

# Initialize (discovers the agent)
await toolkit.initialize()

# Use with LangGraph
llm = ChatOpenAI(model="gpt-4")
agent = create_agent(llm, toolkit.get_tools())

# Run
result = await agent.ainvoke({"messages": [("user", "Query some data")]})

Tools

The toolkit provides two tools:

  • a2a_get_agent_details - Get the capabilities and skills of the remote agent
  • a2a_send_message - Send a message to the remote agent (payments handled automatically)

Metadata

Release files for langchain-ampersend-ai 0.0.2

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

Source distribution (sdist)

Source distribution for langchain-ampersend-ai 0.0.2
File Size Uploaded
langchain_ampersend_ai-0.0.2.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-ampersend-ai 0.0.2
File Interpreter ABI Platform
langchain_ampersend_ai-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / langchain_ampersend_ai-0.0.2.tar.gz

Download URL langchain_ampersend_ai-0.0.2.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f41a89df6f12ced8b9856940ad8feb12e83d9bd1531778c00490e816eefd1f55
BLAKE2b-256 checksum
How to use checksums
864c02c7ca1ecbf9b282d38dd01603a0a229c41c3757e1949bb63948cbf7461c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / langchain_ampersend_ai-0.0.2-py3-none-any.whl

Download URL langchain_ampersend_ai-0.0.2-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
013c8c06b1d2e118a6989f143774541bc1744a8c33f7792c4116fdc3ff738663
BLAKE2b-256 checksum
How to use checksums
d494852cee2818ce9d858bc23af00ea68e48c35f746062f3bfacc91c971e9076
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.0.2 This release

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