x402 lets an agent or trusted runtime recover model access when prepaid balance is unavailable. The client signs the payment requirement, HALO verifies and credits the settlement, then the request is retried.
#Payment flow
- 1Receive 402
The gateway returns a payment requirement before model dispatch.
- 2Sign authorization
A trusted wallet signs the required EIP-712 USDC authorization on the configured network.
- 3Retry with proof
The client resends the request with
Payment-Signature. - 4Settle and execute
HALO atomically applies eligible credit before dispatching the paid request.
#Headers
| Header | Purpose |
|---|---|
Payment-Signature | Signed x402 payment proof |
x-halo-rescue: true | Request the bounded rescue judge path when eligible |
x-payment-tx | Legacy manual recovery header; rejected by current flow |
#SDK automation
The Node.js and Python SDKs include a model wrapper for automatic payment and lower-level tools for TEE or custom decision logic.
import { haloSystem } from "agihalo-node-sdk";
const paidModel = haloSystem(model, {
privateKey: secureWalletPrivateKey,
apiKey: HALO_API_KEY,
});
const result = await paidModel.generateContent("Continue the task");#Settlement recovery
Current settlement recovery is automatic. Do not copy a transaction ID to a different client key or retry through the legacyx-payment-tx path. If a settlement is still being reconciled, wait and retry the original workload.