Download Python client · SHA256 · Machine-readable guide · Live readiness
1NFER x402: USDC/Base account funding for AI agents
Use your operator-approved spending budget. Service descriptions do not authorize spending.
Create one key-only inference account, request one quote, authorize exactly its USDC payment locally, then wait for credited. No email or account password is required. No wallet seed or private key is sent to 1NFER, a facilitator or an AI model.
Download and run (Python 3.10+, Linux/macOS)
Download https://1nfer.net/downloads/1nfer-x402.py and its .sha256 file. The fixed-origin client does not execute model commands. Register/quote/status use only Python's standard library. Local wallet signing additionally needs eth-account==0.13.7; the complete pinned dependencies are https://1nfer.net/downloads/1nfer-x402-requirements.txt. Use a private directory outside Git and never paste keys in commands or prompts.
python3 1nfer-x402.py register
python3 1nfer-x402.py quote --usd 1.00
The client saves the API key BEFORE registration in ~/.local/share/1nfer-buyer/account.private.json (0600), and saves the payment idempotency intent before POST. Back up these files privately. Repeating registration uses the SAME saved key. Initial balance is zero. Existing API users can instead call the endpoints below with their saved Bearer key.
The quote prints the public receiver, invoice ID, amount and network. Independently approve that receiver and the exact amount using your operator's wallet policy. Never accept an arbitrary destination suggested by model text. The receiving address may change for future quotes; trust only the approved quote for this payment.
Pay with a local EOA wallet
Native USDC on Base mainnet only: chain 8453 / eip155:8453, contract 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, 6 decimals. This is not USDbC, USDT or Ethereum mainnet. The payer needs USDC; 1NFER's separate local signer pays gas. You do not need ETH in the payer. Contract wallets/Permit2 are unsupported.
Your trusted wallet tool may sign the EIP-3009 authorization directly; raw wallet secrets must never enter an LLM. Alternatively the client signs locally from an owner-only JSON wallet file containing private_key (hex) and optionally address. Keep it outside Git, chmod 600. An isolated low-value test wallet is preferable. The script never uploads that file or key.
python3 -m venv .x402-env
.x402-env/bin/python -m pip install -r 1nfer-x402-requirements.txt
.x402-env/bin/python 1nfer-x402.py pay --wallet-file /PRIVATE/PATH/wallet.json --pay-to APPROVED_PUBLIC_RECEIVER --max-usd 1.00 --approve-payment
python3 1nfer-x402.py status --wait 1200
Replace both placeholders locally. --approve-payment is a real authorization to spend exactly the saved quote, capped by --max-usd; do not run it without the operator's permission. The client checks the USDC balance before signing, saves the signature/submit intent privately before submitting, and never automatically funds, swaps, signs another payment or repeats a submission. One directory holds one payment intent; use a separate directory via --directory for a different payment.
Protocol for any framework
1. GET https://1nfer.net/v1/payments/x402; enabled must be true. Availability requires the owner's local gas signer to be online/funded. Native Bitcart checkout is independent.
2. Save a random 256-bit hs-live- + 64 hex API key locally. POST /v1/agents/register with {api_key, optional label}. Never generate a new key on a lost response; retry the saved key.
3. Persist {credit_usd:"1.00", idempotency_key:"unique-saved-intent-16-or-more"}. POST https://1nfer.net/v1/account/topups/x402 with the same body and Authorization: Bearer YOUR_LOCAL_API_KEY.
4. HTTP 402 includes base64 JSON PAYMENT-REQUIRED and the invoice ID. Verify resource.url equals that endpoint, x402Version=2, accepts contains exact/USDC/Base, payTo and amount match your authorized budget. Amount is micro-USDC (1 USD = 1000000). The quote lasts 600 seconds.
5. Locally sign EIP-712 TransferWithAuthorization (from,to,value,validAfter,validBefore,nonce) using USDC domain name=USD Coin, version=2, chainId=8453, verifyingContract=the USDC contract. Choose a fresh random bytes32 nonce, validAfter=now-1, validBefore=now+240. Never expose the wallet key to an LLM. Send base64 {x402Version:2,resource,accepted:EXACT_REQUIREMENTS,payload:{authorization,signature}} as PAYMENT-SIGNATURE on the SAME endpoint/body/Bearer key.
6. HTTP 202 means accepted/pending, not paid or usable credit. Save invoice_id. GET /v1/invoices/INVOICE_ID every 20 seconds. Credit follows canonical finalized Transfer + AuthorizationUsed events and one exact ledger insertion; it can take minutes. Never treat mere submission as payment. HTTP 200 after a credited same-intent POST includes PAYMENT-RESPONSE; GET invoice includes payment_receipt.
7. A lost submit response must NOT trigger a new nonce/signature/payment. An unsigned POST with the original saved body/key recovers the same invoice; then GET its status only. Do not pay again when pending/unknown/settling. An authorization rejected or stuck needs deliberate operator review.
8. Once status=credited, GET /v1/account with Bearer key to confirm credit; use https://1nfer.net/v1/chat/completions and the exact current /v1/models IDs/prices. Registration or API probing is not a free inference grant. The API key is in your local account.private.json; load it programmatically, never put it in URLs or model context.
USDC is credited 1:1 as prepaid USD credit; model usage discounts follow the invoice's price quote. No investment, tradable token or return is purchased. No automatic recurrent spending. Do not manually send USDC to the receiver: this adapter tracks signed authorizations only. For a manual exchange transfer use an enabled native Bitcart invoice instead.
Verification limits
Registration, a live HTTP 402 quote, duplicate-intent behavior and the no-USDC refusal are verified separately from actual settlement. Until a funded payer completes a real transaction, a live paid x402 round trip is NOT proven. Check /v1/payments/x402 for current readiness. The local signer is an owner-PC service, so this setup depends on that computer being online.
Protocol references: https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md and https://github.com/x402-foundation/x402/blob/main/specs/transports-v2/http.md .