AI Payment Use Cases

Real-world applications of autonomous AI payments. See how x402Nano enables the future of machine-to-machine commerce.

💡 Use Case #1

AI Agent Marketplaces

Enable autonomous buying and selling of AI services in digital marketplaces without human intervention.

⚠️

Webhook Security Notice

Code examples below include webhook URLs. Only use webhooks in production if your firewall and server security are properly configured.

Data Processing Services

AI agents purchase data cleaning, transformation, or analysis from specialized agents

API Access Marketplace

Agents sell access to proprietary APIs on a pay-per-call basis

Compute Resource Trading

Agents with excess compute power sell it to agents needing temporary resources

ai_marketplace.py
import requests

# Service provider creates payment request
service_address = "nano_3provider..."
response = requests.post(
    "https://api.x402nano.com/transaction/create",
    json={
        "receive_address": service_address,
        "amount": "0.5",
        "metadata": '{"service":"data-cleaning","job_id":"123"}',
        "callback_url": "https://provider.com/webhook"
    }
)
tx = response.json()

# AI agent pays instantly
pay_response = requests.post(
    "https://api.x402nano.com/transaction/pay",
    json={
        "transaction_id": tx["transaction_id"],
        "amount": tx["amount"],
        "encrypted_wallet_string": agent_wallet,
        "password": agent_password
    }
)

# Provider receives webhook → executes service
model_monetization.py
# AI Model Provider receives inference request
def handle_inference(request):
    # Create transaction for this inference
    tokens = count_tokens(request.prompt)
    cost = tokens * 0.00001  # 0.00001 NANO per token
    
    tx = requests.post(
        "https://api.x402nano.com/transaction/create",
        json={
            "receive_address": model_wallet_address,
            "amount": str(cost),
            "metadata": json.dumps({
                "model": "gpt-4",
                "tokens": tokens,
                "request_id": request.id
            })
        }
    ).json()
    
    # Return payment details to customer
    return {
        "transaction_id": tx["transaction_id"],
        "amount": tx["amount"],
        "address": tx["receive_address"]
    }

# Customer pays and polls status
pay_transaction(tx_id, amount, wallet, password)
status = poll_status(tx_id)  # 30s long-polling

if status["is_paid"]:
    result = run_inference(request.prompt)
    return result
🤖 Use Case #2

Pay-Per-Use AI Models

Monetize AI models with per-inference payments. Zero fees make microtransactions economically viable.

Per-Token Pricing

Charge $0.00001 per token using transaction metadata to track usage

Payment Verification

Long-polling status check (30s) confirms payment before serving inference

Webhook Notifications

Receive instant callback when payment completes—automate your workflow

⚡ Use Case #3

Direct Agent Payments

AI agents send and receive payments directly for compute, data, or services.

Simple Send/Receive

Use /send and /receive endpoints for direct agent-to-agent payments

Balance Monitoring

Check balance before purchasing—get both Nano and raw amounts

Pending Funds

Automatically receive pending payments before making purchases

Example: Compute Trading

# Agent A needs compute, checks balance
balance = requests.post(
    f"https://api.x402nano.com/balance/{agent_address}"
).json()

if float(balance["balance"]) >= 0.1:
    # Send payment to Agent B
    requests.post(
        "https://api.x402nano.com/send",
        json={
            "encrypted_wallet_string": wallet,
            "password": password,
            "to_address": provider_address,
            "amount": "0.1"
        }
    )
    
    # Agent B receives funds
    requests.post(
        "https://api.x402nano.com/receive",
        json={
            "encrypted_wallet_string": provider_wallet,
            "password": provider_password
        }
    )
    
    # Compute access granted

Data Purchase Flow

1

Create Transaction

Seller creates transaction with metadata describing dataset

2

Buyer Pays

Buyer pays with /transaction/pay endpoint

3

Webhook Callback

Seller receives webhook notification with metadata

4

Data Delivery

Dataset automatically sent to buyer's endpoint

5

Status Verification

Check /transaction/status to verify with metadata

< 30 seconds
Payment verification + delivery
📊 Use Case #4

Data Purchase with Metadata

Buy and sell data between AI agents with transaction metadata for tracking and verification.

Metadata Tracking

Store dataset info in transaction metadata (4KB JSON)—track what was purchased

Payment Verification

Check transaction status with metadata to verify purchase details

Webhook Delivery

Receive callback when payment completes—automatically deliver data

More AI Payment Scenarios

💳

Recurring Subscriptions

Create new transaction every billing period with /transaction/create—customers pay automatically

🔔

Webhook Automation

Use callback_url to trigger actions when payments complete—fully autonomous

🤝

Multi-Agent Collaboration

Agents split costs using /send—pay each contributor their share instantly

📊

Usage Tracking

Store usage data in transaction metadata—build audit trails and analytics

Instant Refunds

Use /send to refund overpayments—no processing delays or fees

🔐

Pay-Per-Access

Grant API/resource access only after verifying payment via /transaction/status

Ready to Build Your AI Payment System?

Start with our integration guide and have your first AI agent transacting in minutes