azeth_pay
Pay for x402-gated HTTP services by automatically handling 402 payment responses. Supports smart accounts, on-chain agreements, and direct settlements to access paid APIs.
Instructions
Pay for an x402-gated HTTP service. Makes the request, handles 402 payment automatically, and returns the response.
Use this when: You need to access a paid API or service that uses the x402 payment protocol (HTTP 402). The tool automatically detects if you have an active payment agreement (subscription) with the service. If an agreement exists, access is granted without additional payment. Otherwise, a fresh USDC payment is signed.
Returns: Whether payment was made, the payment method used ("smart-account" for a fresh smart-account settlement, "agreement" for access granted by an active on-chain payment agreement, "session" for SIWx reuse of a prior payment session (older servers may also report agreement-granted access as "session"), "x402" for a direct EOA settlement, or "none"), the HTTP status, and the response body.
Note: Requires USDC balance to pay (unless an agreement grants access). Set maxAmount to cap spending. Only HTTPS URLs to public endpoints are accepted. The payer account is determined by the AZETH_PRIVATE_KEY environment variable.
Example: { "url": "https://api.example.com/data" } or { "url": "https://api.example.com/data", "maxAmount": "1.00" }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The HTTPS URL of the x402-gated service to access. Must be a public endpoint. | |
| body | No | Request body for POST/PUT/PATCH requests (JSON string, max 100KB). | |
| chain | No | Target chain. Defaults to AZETH_CHAIN env var or "baseSepolia". Accepts "base", "baseSepolia", "ethereumSepolia", "ethereum" (and aliases like "base-sepolia", "eth-sepolia", "sepolia", "eth", "mainnet"). | |
| method | No | HTTP method. Defaults to "GET". | |
| maxAmount | No | Maximum USDC amount willing to pay (e.g., "5.00"). Rejects if service costs more. | |
| smartAccount | No | Smart account to pay from. Use "#1", "#2", etc. (index from azeth_accounts) or a full address. Defaults to your first smart account. |