Pay-per-Call Search
Let an autonomous service pay for each Search request with x402.
Use the x402 SDK when the caller should pay for each Search request with a wallet instead of using an OptimAI API key.
Workflow
- Create an x402 client with an EVM or Solana payer handler.
- Call
createSearch()without hard-coding a payment amount. - Let the SDK read the server's
402 Payment Requiredchallenge and sign its exact accepted requirement. - Persist the returned
paymentContextwith the search ID. - Poll with
waitForSearchCompletion()orgetSearch()using that context. - Retry a create request with the same idempotency key and
existingPaymentContextif another worker needs to recover it.
Agent mode
Set search_mode: "agent" for longer multi-step web, social, and crypto
research. Agent mode is text-only and the server advertises an offer exactly
twice the Standard Search offer. Always sign the amount in the current 402
challenge.
The x402 API currently supports Search only. Use API-key authentication for Scrape, Seed, and Crawl.
Settlement safety
The server settles only after a completed Search has a usable non-empty result. Failed, cancelled, timed-out, and empty-result searches are voided. Keep the fresh result-bound payment context available until the final result is read.