langchain-nory
LangChain tools for x402 payments - Let your agents pay for APIs autonomously.
Overview
langchain-nory provides LangChain tools that enable AI agents to:
- Pay for x402-protected APIs automatically when they encounter HTTP 402 responses
- Access pre-built paid APIs for crypto prices, weather, translation, and more
- Make direct payments to any Solana or EVM wallet
All payments use USDC stablecoin on Solana (~400ms settlement) or EVM chains.
Installation
pip install langchain-nory
Quick Start
from langchain_nory import get_nory_tools
from langchain_openai import ChatOpenAI
from langchain.agents import create_react_agent, AgentExecutor
# Get all Nory tools (uses NORY_WALLET_KEY env var)
tools = get_nory_tools()
# Or configure with explicit wallet key
tools = get_nory_tools(wallet_key="your-solana-private-key")
# Create agent with tools
llm = ChatOpenAI(model="gpt-4")
agent = create_react_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
# Agent can now pay for APIs!
result = executor.invoke({"input": "What's the current price of Bitcoin?"})
Available Tools
Core Tools
| Tool | Description | Cost |
|---|---|---|
NoryFetchTool |
Fetch any URL with automatic x402 payment handling | Varies |
NoryPaymentTool |
Make direct USDC payments to any wallet | 0.1% fee |
Pre-built Paid API Tools
| Tool | Description | Cost per request |
|---|---|---|
NoryCryptoPricesTool |
Real-time crypto prices (BTC, ETH, SOL, etc.) | $0.001 |
NoryWeatherTool |
Weather + 7-day forecast for any city | $0.002 |
NoryTranslateTool |
Translate between 20+ languages | $0.005 |
NoryQRCodeTool |
Generate QR codes | $0.001 |
NoryWebSummaryTool |
Extract text from any webpage | $0.01 |
Individual Tool Usage
Fetch Any Paid API
from langchain_nory import NoryFetchTool
tool = NoryFetchTool(wallet_key="your-key")
# Automatically pays if the API requires it
result = tool.run("https://api.example.com/premium-data")
Get Crypto Prices
from langchain_nory import NoryCryptoPricesTool
tool = NoryCryptoPricesTool(wallet_key="your-key")
result = tool.run("BTC,ETH,SOL")
# {"BTC": {"price": 45000.50, ...}, "ETH": {...}, "SOL": {...}}
Get Weather
from langchain_nory import NoryWeatherTool
tool = NoryWeatherTool(wallet_key="your-key")
result = tool.run("London")
# {"current": {"temp": 15, "condition": "Cloudy"}, "forecast": [...]}
Translate Text
from langchain_nory import NoryTranslateTool
tool = NoryTranslateTool(wallet_key="your-key")
result = tool.run(text="Hello world", to_lang="es")
# {"translation": "Hola mundo", "from": "en", "to": "es"}
Environment Variables
export NORY_WALLET_KEY="your-solana-private-key"
With CrewAI
from crewai import Agent, Task, Crew
from langchain_nory import get_nory_tools
tools = get_nory_tools()
researcher = Agent(
role="Market Researcher",
goal="Get real-time crypto market data",
tools=tools,
verbose=True
)
task = Task(
description="Get the current prices of BTC, ETH, and SOL",
agent=researcher
)
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()
How x402 Payment Works
- Agent requests a paid API endpoint
- Server returns
402 Payment Requiredwith payment requirements NoryFetchToolcreates and signs a USDC transfer transaction- Transaction is sent to Nory for settlement (~400ms)
- Agent retries request with
X-PAYMENTheader containing proof - Server verifies payment and returns data
All of this happens automatically - your agent just calls tool.run(url).
Links
- Website: noryx402.com
- Documentation: noryx402.com/docs
- x402 Protocol: github.com/coinbase/x402
- npm packages: nory-x402-payer | nory-x402-middleware
License
MIT
Metadata
Release files for langchain-nory 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_nory-0.1.0.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_nory-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.1 kB
Release files / langchain_nory-0.1.0.tar.gz
| Download URL | langchain_nory-0.1.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb63453f8c9dbdaeed74810423ec7c60bbd5f30f9a223b381620f578ea2faaa3
|
|
BLAKE2b-256 checksum How to use checksums |
24f56573d7829d4b880d7b1bfe8a4fe5f103ad3d41c86b8bb908f6a7937d6c91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.3
|
Release files / langchain_nory-0.1.0-py3-none-any.whl
| Download URL | langchain_nory-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
63d1267d35d33bcde312dfbf495eacf801f7f16f3353bb687d140d13f0e5baa8
|
|
BLAKE2b-256 checksum How to use checksums |
a05e74ac44b5fdfc1bf37eb6f5b03ec8f9285777e11edf3b269dd5bc928694a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.3
|