LangChain toolkit for 2,400+ x402 pay-per-call APIs — discover, call, and manage with no wallet setup
Project description
langchain-x402
LangChain tools for 2,400+ x402 pay-per-call APIs. No wallet setup needed.
Install
pip install langchain-x402
Quick Start
from langchain_x402 import X402Toolkit
tools = X402Toolkit().get_tools()
# 3 tools: x402_discover, x402_call, x402_balance
With an Agent
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from langchain_x402 import X402Toolkit
agent = create_react_agent(ChatOpenAI(), X402Toolkit().get_tools())
result = agent.invoke({
"messages": [("user", "Find DeFi security APIs and check if USDC on Base is safe")]
})
Tools
x402_discover
Search 2,400+ x402 APIs by keyword. Returns URLs, descriptions, prices.
from langchain_x402 import DiscoverTool
tool = DiscoverTool()
result = tool.invoke({"query": "weather forecast", "limit": 5})
x402_call
Call any x402 API. Payment handled automatically via broker ($0.01/call).
from langchain_x402 import CallAPITool
tool = CallAPITool()
result = tool.invoke({"url": "https://weather.hugen.tokyo/weather/current?city=Tokyo"})
x402_balance
Check remaining API key balance.
from langchain_x402 import BalanceTool
tool = BalanceTool()
result = tool.invoke({}) # {"balance_usd": 0.04}
How Billing Works
- First use auto-creates an API key with $0.05 trial credit (5 broker calls)
- Each
x402_calldeducts from balance - When balance runs out, top up via
POST https://discovery.hugen.tokyo/keys/topup($1.00) - Discovery search is free (no payment needed)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_x402_toolkit-0.1.0.tar.gz.
File metadata
- Download URL: langchain_x402_toolkit-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c0501aa9a8e34b3db44cc3aa951c830c768d9d4c25f0c7d4072dca4df935097
|
|
| MD5 |
05f3d344fa3ee13f9acc0b87f49bc3ae
|
|
| BLAKE2b-256 |
bddd045ebcb8a6ea7f417e85e67499e091602eed07399041aa8542f674bff24c
|
File details
Details for the file langchain_x402_toolkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_x402_toolkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50bac9133404b3201247123e3670a2f3fa68e6d111536e8f8aa7ef0d1641517f
|
|
| MD5 |
32529eb7c1c3ef39ca28294bf08deba3
|
|
| BLAKE2b-256 |
4e6bc962315025dfc8f10900fc116f1b01860121a2961c6dd3ba081be6cb9f6d
|