zk AgentPay zkAPI
LIVE ON BASE L2 · CLEAN-ROOM RAIL

Private AI payments.

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.

32Tree depth
5Nullifier ledger
0.002 USDCMin query price
Groth16 / BN254Proof system
Base L2Settlement network

How it works

01 — DEPOSIT

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.

02 — WATCH

Read your leaf

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.

03 — PROVE

Generate a spend proof

Use the kit at GET /zkapi/kit (wasm + zkey + snippet). Prove membership, amount, and receiver without revealing the secret.

04 — SPEND

POST proof + query

Send the proof and your query to POST /zkapi/spend. One nullifier, one query. Change is re-inserted as a new leaf.

Buyer example

curl · X-Zkapi-Proof
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.

No prover? Use a session.

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"}'
Receiver

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:

/zkapi/kit · /zkapi/openapi.json · /zkapi/mcp