Developer Guide

Score Ads From Your AI Agent

Give any AI agent the ability to grade an ad's predicted brain engagement with a single HTTP call. Pay $5 USDC per request over the x402 protocol — no account, no signup, no API key.


How it works

The endpoint speaks x402 — the open "HTTP 402 Payment Required" standard that lets software pay for a single request with stablecoins. There are no accounts to create and no keys to manage. The flow is three steps your agent's wallet SDK handles automatically:

  1. Your agent POSTs the ad to the endpoint. With no payment attached, it gets back 402 Payment Required describing the price and the accepted payment options.
  2. The wallet SDK signs a $5 USDC payment and retries the request with the payment attached.
  3. The server verifies and settles the payment, then queues the scoring job and returns a job id plus a free status URL to poll for the result.
Your advideo · image · audioAdCortex™frame-by-frame analysisEngagement signalpredicted attention / second0.80strongpercentile score
What your agent buys for $5: the ad runs through a neural model frame by frame and returns an engagement curve plus a percentile score against 76 benchmark ads.

Endpoint & pricing

POST https://pretestads.com/api/v1/score

  • Price: $5.00 USDC per scored ad
  • Pay on: Solana or Base (your agent picks)
  • Media: MP4 / MOV / AVI video, or JPG / PNG / WebP image — up to 500MB
  • Status/result: GET /api/v1/score/{id} (free, no payment)

Skip the boilerplate — open-source toolkit

Ready-made clients for OpenAI, Claude, Gemini, LangChain, CrewAI, and Vercel AI SDK, a plain CLI, an MCP server, and a Claude plugin are free on GitHub: pretestads-agent-scripts. Claude Code users can install the plugin with /plugin marketplace add krecicki/pretestads-claude-plugin. Docs for all of it on the agent toolkit page.

Quick start (Node / TypeScript)

The x402-fetch wrapper turns the whole 402 → pay → retry dance into a normal fetch call. Point it at a wallet that holds USDC on Solana or Base:

import { wrapFetchWithPayment } from "x402-fetch";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";

// A wallet funded with a little USDC on Base (or use a Solana signer)
const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const wallet = createWalletClient({ account, chain: base, transport: http() });

const fetchWithPay = wrapFetchWithPayment(fetch, wallet);

// 1) Submit the ad — payment is handled automatically on the 402
const res = await fetchWithPay("https://pretestads.com/api/v1/score", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    media_url: "https://example.com/my-ad.mp4",
    window_seconds: 15,
  }),
});

const { id, status_url } = await res.json();

// 2) Poll the free status endpoint until the score is ready (~5-8 min)
let result;
do {
  await new Promise((r) => setTimeout(r, 20000));
  result = await (await fetch(status_url)).json();
} while (result.status !== "complete" && result.status !== "failed");

console.log(result.score, result.label, result.verdict);

What a request looks like

Send JSON with a public media_url, or a multipart upload with a file field. An unpaid request returns the payment options:

$ curl -X POST https://pretestads.com/api/v1/score \
    -H "Content-Type: application/json" \
    -d '{"media_url":"https://example.com/my-ad.mp4"}'

HTTP/1.1 402 Payment Required
{
  "x402Version": 2,
  "accepts": [
    { "scheme":"exact", "network":"solana:5eykt4...", "amount":"5000000",
      "asset":"EPjFWdd5...USDC", "payTo":"<merchant Solana address>" },
    { "scheme":"exact", "network":"eip155:8453", "amount":"5000000",
      "asset":"0x8335...USDC", "payTo":"<merchant Base address>" }
  ]
}

What you get back

Once scoring completes, the status URL returns the full result — a 0-100 attention score benchmarked against 76 top-performing TikTok Creative Center ads, a label, a plain-language verdict, and a per-second engagement curve:

{
  "id": "4c28e9c0-...",
  "status": "complete",
  "score": 79,
  "label": "strong",
  "verdict": "Your ad outperforms the majority of TikTok's top performers...",
  "engagement_timeseries": [
    { "second": 0, "activation": 0.25 },
    { "second": 1, "activation": 0.06 },
    ...
  ]
}

Notes for agent builders

  • One payment, one score. Each settled payment buys exactly one scoring run. Re-sending the same payment proof is rejected.
  • Settlement happens first. The payment is confirmed on-chain before the job runs, so a valid request always produces a job.
  • Discoverable. The endpoint publishes an x402 Bazaar discovery schema, so agents that browse the Bazaar catalog can find it and read its input/output shape automatically.
  • Machine-readable docs. A summary for agents lives at /llms.txt.

Prefer the dashboard?

If you're scoring ads by hand rather than from an agent, the web app has accounts, credits, and subscriptions — with your first analysis free.

Score Your Ad Free

Frequently asked questions

How does an AI agent pay for a single ad score?

The endpoint uses the x402 protocol. The first request returns HTTP 402 Payment Required with the price and payment options. Your agent signs a $5 USDC payment with a buyer SDK (like x402-fetch) and retries — the server verifies and settles the payment, then runs the scoring job. No account, signup, or API key is needed.

Which blockchains and tokens are accepted?

$5.00 USDC on either Solana or Base. The 402 response offers both; your agent pays on whichever chain it holds funds. Payment is settled through an x402 facilitator before the scoring job runs.

What does the agent get back?

A JSON payload with a 0-100 attention score, a label (weak/moderate/strong), a plain-language verdict, and a per-second engagement timeseries — benchmarked against 76 top-performing TikTok Creative Center ads.

How long does scoring take?

The paid request returns immediately with a job id and a free status URL. Scoring the media through the model typically completes in about 5 to 8 minutes. Your agent polls the status URL until the score is ready.

By Chris Krecicki · Published · Updated