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)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.
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 FreeThe 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.
$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.
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.
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.