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())