Skip to main content
Ampersend enables LangChain agents to pay for and use remote AI agent services. Payments are handled transparently via the x402 protocol, with A2A as the communication layer.

Overview

Integration details

Tool features

  1. a2a_get_agent_details - Get capabilities of the remote agent
  2. a2a_send_message - Send messages to the remote agent (payments handled automatically)

Key features

  • Spend controls: Pluggable payment authorization with limits and policies
  • Transparent payments: x402 protocol handles payment negotiation automatically

Setup

Installation

Install the langchain-ampersend package:

Credentials

The toolkit requires a session key and smart account address, which you can obtain from the Ampersend dashboard.
Set up credentials

Instantiation

Initialize toolkit

Invocation

Send a message to the remote agent:
Send message

Use within an agent

Create agent
Example usage:
Run agent

How payments work

When the remote agent requires payment (HTTP 402), the toolkit:
  1. Receives the payment requirement
  2. Calls the treasurer to authorize the payment
  3. Signs the payment with the configured wallet
  4. Retries the request with the payment attached
This is transparent to your LangChain agent. The AmpersendTreasurer provides managed payment sessions with spend limits and analytics. Alternative treasurer implementations are available in ampersend_sdk.

API reference