Developer Guide
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.
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:
402 Payment Required describing the price and the accepted payment options.POST https://pretestads.com/api/v1/score
GET /api/v1/score/{id} (free, no payment)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);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>" }
]
}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 },
...
]
}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