LangChain Tool integration for The Factory — x402 micropayment data API
Project description
langchain-the-factory
LangChain Tool integration for The Factory — an x402 micropayment agent that sells clean JSON data to AI agents.
Install
pip install langchain-the-factory
Quick start
from langchain_the_factory import FactoryToolkit
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI
# Initialize the toolkit with your Solana keypair
toolkit = FactoryToolkit(
private_key_base58="YOUR_BASE58_PRIVATE_KEY",
# optional: token="bulk_..." for pre-paid mode
)
# Get all 6 endpoint tools
tools = toolkit.get_tools()
# Build an agent that can call them
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Ask the agent anything that needs real-world data
executor.invoke({
"input": "What's the weather in Milano for the next 3 days? "
"Also check EUR/USD trend over the last 7 days."
})
Available tools
Each of the 6 endpoints becomes a LangChain Tool with auto-generated docstring:
get_weather—/api/v1/meteo($0.01/call)get_fx_rate—/api/v1/fx($0.02/call)get_transit_arrivals—/api/v1/transit($0.02/call)get_tech_news—/api/v1/news($0.02/call)get_stock_price—/api/v1/stocks($0.05/call)get_github_stats—/api/v1/github-stats($0.02/call)
Cost management
Each tool call costs $0.01-0.05. To control spend:
- Use bulk packs:
toolkit = FactoryToolkit(token="bulk_...")for 10 calls at $0.08. - Use subscription: $50/mo for 10,000 calls. Best for production agents.
- Cache hits are free: identical queries (same city, same date range) cost nothing for 1 hour due to server-side caching.
LangChain Hub submission
To submit this tool to the official LangChain Hub:
pip install langchainhub
langchainhub login # uses your LangChain account
langchainhub push langchain-the-factory
After review, the tool will be available at hub.langchain.com/the-factory.
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_the_factory-0.1.0.tar.gz.
File metadata
- Download URL: langchain_the_factory-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15acbbecc041657c09d74b4e8b5c79020650934a78fd99e17c2f73d2454cd001
|
|
| MD5 |
b6fceab871546a0b03e04146cddd8711
|
|
| BLAKE2b-256 |
c29229ca013902c571d7b7a7e45f032462b317577b07ee05b8f8c8e6a95eacae
|
File details
Details for the file langchain_the_factory-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_the_factory-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c599f8604a63c2c337cd1f14c860632e491a3de813e021ab8dc0b104760a201d
|
|
| MD5 |
6f18456cf90d243935c9f8eec7ff35f0
|
|
| BLAKE2b-256 |
99038011947a331576364eb4e425529f635257aa4dcca0eb5a5f18c36d79dd30
|