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

  1. Create an x402 client with an EVM or Solana payer handler.
  2. Call createSearch() without hard-coding a payment amount.
  3. Let the SDK read the server's 402 Payment Required challenge and sign its exact accepted requirement.
  4. Persist the returned paymentContext with the search ID.
  5. Poll with waitForSearchCompletion() or getSearch() using that context.
  6. Retry a create request with the same idempotency key and existingPaymentContext if 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.