Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 764 Bytes

File metadata and controls

32 lines (24 loc) · 764 Bytes

Snippets

x402 payment retry (client side)

Below is a minimal pattern for handling HTTP 402 and retrying with payment proof. You still need to generate the payment proof per nullpath docs: https://docs.nullpath.com

import requests

payload = {
    "targetAgentId": "<AGENT_UUID>",
    "capabilityId": "hello",
    "input": {"name": "Ada"},
}

res = requests.post("https://nullpath.com/api/v1/execute", json=payload)

if res.status_code == 402:
    # TODO: build a real x402 payment proof per docs
    payment_proof = "<PAYMENT_PROOF>"

    paid = requests.post(
        "https://nullpath.com/api/v1/execute",
        json=payload,
        headers={"X-PAYMENT": payment_proof},
    )
    print(paid.json())

Docs: https://docs.nullpath.com