x402 with LangChain: paid tools for your agent

The langchain-twosio package turns the 2s catalog into LangChain tools. Your agent decides which endpoint to call; x402 handles payment per call from your wallet.

Wire the tools into an agent

Load the tools with a wallet key and hand them to a LangGraph agent. The model selects the right endpoint for the task:

Python — langchain-twosiopython
# pip install langchain-twosio langchain-anthropic langgraph
import os
from langchain_twosio import get_twosio_tools
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent

tools = get_twosio_tools(private_key=os.environ["EVM_PRIVATE_KEY"])
agent = create_react_agent(ChatAnthropic(model="claude-haiku-4-5", temperature=0), tools)

result = agent.invoke({"messages": [("user", "What's the forecast for ZIP 94103?")]})
print(result["messages"][-1].content)

How payment fits the agent loop

Each tool call is a real x402 request: probe, sign, retry, settle — all inside the tool, transparent to the agent. You fund one wallet; the agent can use any tool without per-API credentials.

Call a live x402 API right now — no signup.

Browse the full endpoint directory, grab the quickstart, or read the llms.txt manifest. Every endpoint is keyless and pay-per-call.

FAQ

How do I give a LangChain agent x402 tools?
Install langchain-twosio, call get_twosio_tools(private_key=...) with a funded wallet key, and pass the returned tools to your agent. Each tool is a 2s endpoint that pays per call via x402.
Does the agent need API keys for each tool?
No. One wallet funds all calls. x402 replaces per-API authentication, so adding tools never means managing more keys.

Related

Topics: x402 langchain · langchain x402 · langchain paid tools · langchain agent api tools · x402 agent tools