Inspiration

Before you send money to a wallet or buy a token, the answers you need sit behind paid data APIs: a honeypot test, a sanctions list, holder concentration. Each one costs a fraction of a cent and wants its own account, key or crypto wallet. Nobody signs up for five APIs to answer one question, and when a check comes back empty you have paid for nothing.

What it does

PerCall is pay per answer. You ask a question in plain English. An AI agent picks the data checks it needs and shows you the exact price, check by check. You pay once with PayPal. The agent buys each check from a pay-per-call data provider, writes a short answer that cites the check behind every fact, and refunds every check that returned nothing back to your PayPal, on the spot.

How we built it

  • Planning: Cloudflare Workers AI (Llama 3.3 70B) with JSON-schema output, limited to the ten checks on the menu.
  • Checkout agent: the same model, given the tools exported by PayPal Agent Toolkit. It creates the order with one line item per check (create_order), captures it after the buyer approves (pay_order), and issues the partial refund for empty checks (create_refund).
  • Guard rails: the server checks every argument the agent proposes against the quote (currency, line items, total, capture id, refund amount) before the toolkit runs it. If they do not match, it makes the same PayPal call directly with the exact figures, and the receipt shows which path was used.
  • Buying the data: the agent pays the provider per call in USDC over x402 on Base, under a daily budget cap. The receipt links every provider payment.
  • Answer: written only from the purchased results, one citation per fact.
  • One Cloudflare Worker serves the app and the API; quotes and receipts live in KV.

Challenges

The model wrote prices as strings and added zero-value fields, so the first agent orders failed our checks; the server now normalises numbers before checking them. The toolkit sends no idempotency key on refunds, so once a toolkit refund is sent we never retry it through the direct path, which could refund twice.

Accomplishments

A full loop on real rails: a PayPal sandbox order created by the agent, a live USDC payment to the data provider on Base mainnet, and an automatic PayPal refund when the data is not there. The buyer only ever pays for checks that returned something.

What's next

More checks (company registries, sanctions beyond crypto), a monthly PayPal balance for repeat buyers, and the same "refund what came back empty" rule offered to any pay-per-call API.

Built With

  • base
  • cloudflare-workers
  • javascript
  • llama
  • paypal
  • paypal-agent-toolkit
  • paypal-orders-api
  • usdc
  • workers-ai
  • x402
Share this project:

Updates

Submission history