LangChain and CrewAI (Python)
agent402-langchain · PyPI · MIT
The Python adapter: an Agent402Toolkit that hands LangChain and CrewAI agents the same four meta tools the JavaScript adapters expose. Pure-CPU tools are free through the built-in proof-of-work; live-data tools settle in USDC through a signing callable you pass in.
Install
pip install "agent402-langchain[langchain]"
Example
from agent402_langchain import Agent402Toolkit
toolkit = Agent402Toolkit(base_url="https://agent402.tools")
tools = toolkit.get_tools() # four meta-tools your agent can call
What it exposes
agent402_find: resolve a plain-language task to the best tool (slug, price, schema, example).agent402_route: the cross-seller x402 router across the indexed ecosystem.agent402_call: call a tool by slug and pay for it.agent402_about: the service manifest.agent402_tool_specs()returns the four as plain dicts (name, description, JSON Schema, execute) with no langchain-core dependency.
How payment works
- Pure-CPU tools (hashing, encoding, QR, markdown, JSON) settle with proof-of-work: no wallet, no API key.
- Wallet-only tools need
x402_fetch; without it, calling one raises an error naming what is missing, and the free tier keeps working.
# x402_fetch: a callable with the requests-style signature
# (method, url, **kwargs) -> requests.Response that signs the USDC payment
toolkit = Agent402Toolkit(base_url="https://agent402.tools", x402_fetch=my_signed_fetch)
A call that fails is not charged: settlement runs after the tool and only on a successful response. Background: What x402 is · MPP (Machine Payments Protocol).
Tools to try first
Hash$0.001
hash
Web search$0.02
search
Stock quote$0.001
stock-quote
Extract article$0.010
extract
UUID generator$0.001
uuid
Every tool, price and input schema: the catalog.
Links
agent402-langchain on PyPI · source on GitHub
Guides: Make your AI agent pay for what it needs: x402 in 5 minutes · One payment, any proven seller: the x402 Smart Order Router
All integrations