Skip to main content

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

  1. Your agent encounters an HTTP 402 Payment Required response
  2. Use get_payment_requirements to learn how much to pay
  3. Sign and encode the payment transaction (client-side)
  4. Use verify_payment to validate before submission
  5. Use settle_payment to execute the payment on-chain
  6. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_tools_nory_x402-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_tools_nory_x402-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_nory_x402-0.1.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_tools_nory_x402-0.1.0.tar.gz
Algorithm Hash digest
SHA256 92e64fc3d0bad2e3bab4539290746903e7d20b3c42474e07abd622b47a66f654
MD5 52eb50c2a91ad526c5389fecb92cb291
BLAKE2b-256 efaa0c0eefcfbe70d0d941e222f42b04727ef834f0859b4e2246f60bff575606

See more details on using hashes here.

File details

Details for the file llama_index_tools_nory_x402-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_nory_x402-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5f6d2d1cd67e6142c25c26ede39d8d18f6c700dc8faabba9888d20b27f3793a
MD5 8095684808eee1795042c0ea49aa6a23
BLAKE2b-256 64be1937b4a87213c3355598a7f96fd84987421f5678bcfb8a466cc67a33846b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page