Skip to main content

LangChain integration for Ampersend x402 payments

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

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)

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

langchain_ampersend_ai-0.0.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

langchain_ampersend_ai-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_ampersend_ai-0.0.1.tar.gz.

File metadata

  • Download URL: langchain_ampersend_ai-0.0.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for langchain_ampersend_ai-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6cbfe642d3bdc5e12f0bb7161cab826bea00f90f36f9ee483ec3a68be7e1bd71
MD5 93ac4208ad6a6b6f6fb5eeeec561707b
BLAKE2b-256 625e32444976c5bdc4119c6141cb8880acb984bf0630f2df900b9a17713c1e31

See more details on using hashes here.

File details

Details for the file langchain_ampersend_ai-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_ampersend_ai-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fdd1a425da7e84d64c081174ed352b81333d504da99934027713d66ff82ba20
MD5 32bb366180ccf98004a1052737dc4038
BLAKE2b-256 2a88baf3921248e1f11e145530a49dbf79c42af8b8a157b3f814ee6fe3efdd6d

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