Nory x402 payment tools for LlamaIndex - enables AI agents to make blockchain payments
Project description
Nory x402 Payment Tools for LlamaIndex
Enable your LlamaIndex AI agents to make blockchain payments using the x402 HTTP payment protocol.
Features
- Multi-chain support: Solana and 7 EVM chains (Base, Polygon, Arbitrum, Optimism, Avalanche, Sei, IoTeX)
- Sub-400ms settlement: Fast payment finality for real-time agent interactions
- x402 HTTP protocol: Native support for HTTP 402 Payment Required responses
- Simple integration: Drop-in tool spec for any LlamaIndex agent
Installation
pip install llama-index-tools-nory-x402
Quick Start
from llama_index.agent.openai import OpenAIAgent
from llama_index_tools_nory_x402 import NoryX402ToolSpec
# Create the tool spec
tool_spec = NoryX402ToolSpec()
# Create an agent with payment capabilities
agent = OpenAIAgent.from_tools(tool_spec.to_tool_list())
# Use the agent
response = agent.chat("Check if the Nory payment service is healthy")
print(response)
Available Tools
get_payment_requirements
Get x402 payment requirements for accessing a paid resource.
requirements = tool_spec.get_payment_requirements(
resource="/api/premium/data",
amount="0.10", # $0.10 USDC
network="solana-mainnet"
)
verify_payment
Verify a signed payment transaction before settlement.
result = tool_spec.verify_payment(payload="base64-encoded-payload")
settle_payment
Settle a payment on-chain with ~400ms settlement time.
result = tool_spec.settle_payment(payload="base64-encoded-payload")
lookup_transaction
Look up transaction status.
status = tool_spec.lookup_transaction(
transaction_id="tx-signature",
network="solana-mainnet"
)
health_check
Check Nory service health and see supported networks.
health = tool_spec.health_check()
Supported Networks
| Network | Chain Type |
|---|---|
solana-mainnet |
Solana |
solana-devnet |
Solana (testnet) |
base-mainnet |
EVM (Base) |
polygon-mainnet |
EVM (Polygon) |
arbitrum-mainnet |
EVM (Arbitrum) |
optimism-mainnet |
EVM (Optimism) |
avalanche-mainnet |
EVM (Avalanche) |
sei-mainnet |
EVM (Sei) |
iotex-mainnet |
EVM (IoTeX) |
Authentication
For public endpoints, no API key is required. For authenticated endpoints:
tool_spec = NoryX402ToolSpec(api_key="your-api-key")
How It Works
- Your agent encounters an HTTP 402 Payment Required response
- Use
get_payment_requirementsto learn how much to pay - Sign and encode the payment transaction (client-side)
- Use
verify_paymentto validate before submission - Use
settle_paymentto execute the payment on-chain - Access the paid resource with the payment receipt
Links
- Nory - Payment infrastructure for AI agents
- x402 Protocol - HTTP payment protocol specification
- LlamaIndex - Data framework for LLM applications
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 llama_index_tools_nory_x402-0.1.0.tar.gz.
File metadata
- Download URL: llama_index_tools_nory_x402-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92e64fc3d0bad2e3bab4539290746903e7d20b3c42474e07abd622b47a66f654
|
|
| MD5 |
52eb50c2a91ad526c5389fecb92cb291
|
|
| BLAKE2b-256 |
efaa0c0eefcfbe70d0d941e222f42b04727ef834f0859b4e2246f60bff575606
|
File details
Details for the file llama_index_tools_nory_x402-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_tools_nory_x402-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5f6d2d1cd67e6142c25c26ede39d8d18f6c700dc8faabba9888d20b27f3793a
|
|
| MD5 |
8095684808eee1795042c0ea49aa6a23
|
|
| BLAKE2b-256 |
64be1937b4a87213c3355598a7f96fd84987421f5678bcfb8a466cc67a33846b
|