Agnic Pay for Service
v2.0.2Make paid requests to x402-enabled APIs using USDC on Base. Use when the user explicitly asks to call a paid API, make an x402 payment, pay for a request, or...
Paying for x402 Services
Use npx agnic@latest x402 pay to call x402-enabled API endpoints with automatic USDC payment on Base.
Authentication
Run npx agnic@latest status --json to verify. If not authenticated:
- Headless (CI/server/agent): Set
AGNIC_TOKENenv var or pass--token <token> - Interactive (has browser): Run
npx agnic@latest auth login
See the authenticate-wallet skill for details.
Command Syntax
npx agnic@latest x402 pay <url> [-X <method>] [-d <json>] [-q <params>] [-h <json>] [--max-amount <n>] [--json]
See reference/x402-protocol.md for full options, USDC amounts, and input validation rules.
Workflow
-
Check requirements (optional but recommended):
npx agnic@latest x402 details <url>Shows price, method, and schema without making a payment.
-
Verify balance:
npx agnic@latest balance --network base -
Make the paid request:
npx agnic@latest x402 pay <url> --json
Examples
# GET request (auto-pays)
npx agnic@latest x402 pay https://example.com/api/weather --json
# POST request with body
npx agnic@latest x402 pay https://example.com/api/sentiment -X POST -d '{"text": "I love this product"}' --json
# Limit max payment to $0.10
npx agnic@latest x402 pay https://example.com/api/data --max-amount 100000 --json
Prerequisites
- Must be authenticated (
npx agnic@latest statusto check) - Wallet must have sufficient USDC balance on Base
Error Handling
Common errors:
- "Not authenticated" -- Run
npx agnic@latest auth loginor setAGNIC_TOKEN - "Insufficient balance" -- Fund wallet with USDC (
npx agnic@latest balanceto check) - "No X402 payment requirements found" -- URL may not be an x402 endpoint
- Invalid JSON in
--data-- Ensure the body is valid JSON before passing - HTTP 4xx/5xx from the API -- Show the status code and response body to the user
Version tags
latest
