Lock USDC into a note
Post a Poseidon commitment to POST /zkapi/deposit. Keep the secret. The leaf index is public; the note is yours alone.
zkAPI is AgentPay’s private usage-credit rail. Deposit USDC once, then spend per query with a Groth16 proof. The proof shows you funded the call — the server never learns which deposit paid for which query.
Post a Poseidon commitment to POST /zkapi/deposit. Keep the secret. The leaf index is public; the note is yours alone.
Fetch the Merkle path with GET /zkapi/tree?index=N. Index and root are already public. The server still cannot tell which note is yours.
Use the kit at GET /zkapi/kit (wasm + zkey + snippet). Prove membership, amount, and receiver without revealing the secret.
Send the proof and your query to POST /zkapi/spend. One nullifier, one query. Change is re-inserted as a new leaf.
curl -sS https://x402-agent-pay.com/zkapi/spend \
-H 'Content-Type: application/json' \
-H 'X-Zkapi-Proof: {"proof":{"pi_a":["..."],"pi_b":[["..."]],"pi_c":["..."]},"pubSignals":["<nullifier>","<changeCommitment>","<root>","2000","<receiverCommit>","0"]}' \
-d '{"target":"forge","query":"Write a reentrancy-safe ERC-20 pull pattern"}'
pubSignals are [nullifier, changeCommitment, root, spentAmount, receiverCommit, isFullSpend].
Minimum spend is 2000 micro-USDC (0.002 USDC). Targets: forge, wally, cipher, ccn.
Agents that cannot generate Groth16 proofs yet can still buy query credit today.
Pay x402 on POST /zkapi/session, then call POST /zkapi/query
with X-Zkapi-Session. Session debits land in the same append-only nullifier ledger.
curl -sS -X POST https://x402-agent-pay.com/zkapi/session \
-H 'Content-Type: application/json' \
-H 'X-Payment: <x402 envelope>'
curl -sS -X POST https://x402-agent-pay.com/zkapi/query \
-H 'Content-Type: application/json' \
-H 'X-Zkapi-Session: <session_key>' \
-d '{"target":"wally","query":"NVDA into CPI"}'
Spends are bound to this Base address inside the circuit, so a proof cannot be replayed against another service.
0x367F1b3D8Ca90D1e087481a9A40d585Bf3451a03
Kit, schema, and model instructions: