HTML frames (render contract, frame check)

quoted per request from $0.02USDC via x402POST /api/html-frames

Freeze frames of an animation under the render contract: the page defines window.renderAt(t). Send POST /api/html-frames with the required fields html and times and pay quoted per request from $0.02 over x402 or MPP (there is no free tier). It returns a JSON object with width, height, frameCount, frames, contactSheet and 2 more.

The tool renders the self-contained HTML document in headless Chromium with all network access refused, calls renderAt for each requested time in seconds and returns a PNG still per time (base64) plus one contact-sheet PNG of every still in a grid. For previews and frame checks of canvas, SVG or CSS animations an agent wrote itself (motion design, motion graphics, generative art). Frame check: the optional compare input holds either baseline, an array of {t, png} stills (base64 PNG, one per requested time, from an earlier call or another renderer), or baselineUrl, the public URL of a second document under the same contract, fetched through the same public-URL guard as page-speed and rendered the same way; each compared frame then carries similarity (0 to 1 from the 32x18 grid of grayscale cell means; identical stills score 1) and changedRegions (bounding boxes of the differing cells in pixels, largest first, up to 16 with changedRegionsPartial saying how many there were). A compare by baselineUrl renders two documents, so that call is quoted at twice the listed price ($0.04) in its 402; a compare by baseline stills is quoted at the listed price. The document must carry everything inline: every request it makes (fetch, images, fonts, frames, sockets, navigations) is refused and counted; data: and blob: URLs it builds itself work. A script error while loading, a missing renderAt or a renderAt that throws answers 400. Limits: html up to 512 KB, 1 to 12 times, width up to 1280 and height up to 720 (default 640x360), 5 s per renderAt and 25 s for loading and every renderAt together, 8 MB of PNG output in all; a baseline of up to 12 stills and 8 MB of PNG, each still at most 1280x720. Deterministic code, no model. Body: {"html":"<!doctype html>…","times":[0,0.5,1],"width":640?,"height":360?,"compare":{"baseline":[{"t":0,"png":"iVBORw0KGgo…"}]}?} or "compare":{"baselineUrl":"https://…"}.

Category: Web & documentsTags: browser html render frames animation png canvas contact-sheetAlso found as: render-contract renderat renderat-frames contact-sheet frame-check motion-design-frame-check

Try in playground →

Parameters

NameTypeRequiredDescription
htmlstringyesA self-contained HTML document (max 512 KB) that defines window.renderAt(t); it may return a promise Also accepted as content, body, markup, text, source.
timesarray of numberyes1 to 12 times in seconds (0 to 3600), one still each
widthintegernoViewport width in px, 16 to 1280 (default 640)
heightintegernoViewport height in px, 16 to 720 (default 360)
compareobjectnoOptional frame check: exactly one of baseline or baselineUrl. Adds similarity (0 to 1) and changedRegions to each compared frame. A baselineUrl renders a second document and is quoted at twice the listed price ($0.04)

Example request

curl -i -X POST https://agent402.tools/api/html-frames \
  -H "Content-Type: application/json" \
  -d '{"html":"<body style=margin:0><canvas id=c width=320 height=180></canvas><script>x=c.getContext('\''2d'\'');x.fillStyle='\''#4cc38a'\'';renderAt=t=>{x.clearRect(0,0,320,180);x.fillRect(20+t*100,70,40,40)}</script>","times":[0,1,2],"width":320,"height":180}'

Without payment this returns HTTP 402 Payment Required with the exact price for html-frames; any x402 v2 or MPP client pays it and retries.

Example response

{
  "width": 320,
  "height": 180,
  "frameCount": 3,
  "frames": [
    {
      "t": 0,
      "bytes": 641,
      "pngBase64": "iVBORw0KGgo…"
    },
    {
      "t": 1,
      "bytes": 641,
      "pngBase64": "iVBORw0KGgo…"
    },
    {
      "t": 2,
      "bytes": 640,
      "pngBase64": "iVBORw0KGgo…"
    }
  ],
  "contactSheet": {
    "columns": 2,
    "rows": 2,
    "width": 664,
    "height": 420,
    "bytes": 3246,
    "pngBase64": "iVBORw0KGgo…"
  },
  "totalBytes": 5168,
  "network": {
    "blockedRequests": 0,
    "policy": "all network access refused; only inline script and style, and data: or blob: URLs the document builds itself"
  }
}
FieldTypeAlways presentIn the example
widthnumberyes320
heightnumberyes180
frameCountnumberyes3
framesarray of objectsyes3 items in the example
contactSheetobjectyes6 fields: columns, rows, width, height, bytes, pngBase64
totalBytesnumberyes5168
networkobjectyes2 fields: blockedRequests, policy

From an MCP client

catalog.call {
  "slug": "html-frames",
  "params": {
    "html": "<body style=margin:0><canvas id=c width=320 height=180></canvas><script>x=c.getContext('2d');x.fillStyle='#4cc38a';renderAt=t=>{x.clearRect(0,0,320,180);x.fillRect(20+t*100,70,40,40)}</script>",
    "times": [
      0,
      1,
      2
    ],
    "width": 320,
    "height": 180
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for html-frames; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y [email protected].

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.04" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/html-frames", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "html": "<body style=margin:0><canvas id=c width=320 height=180></canvas><script>x=c.getContext('2d');x.fillStyle='#4cc38a';renderAt=t=>{x.clearRect(0,0,320,180);x.fillRect(20+t*100,70,40,40)}</script>",
    "times": [
      0,
      1,
      2
    ],
    "width": 320,
    "height": 180
  }),
});

Related tools

Screenshot

$0.004 · GET /api/screenshot

Screenshot any public URL in headless Chromium.

Hidden text scan

FREE w/ compute · or $0.001 · POST /api/hidden-text-scan

Check an email or web page for text a person reading it would not see but an AI reading it would: HTML comments.

HTML links

FREE w/ compute · or $0.001 · POST /api/html-links

Enumerate every <a href> in an HTML string with its anchor text and rel attribute.

HTML meta (from string)

FREE w/ compute · or $0.001 · POST /api/html-meta

Extract <title>, <meta description>, OpenGraph/Twitter cards, canonical URL, and JSON-LD blocks from an HTML string.

HTML select

FREE w/ compute · or $0.001 · POST /api/html-select

Run a CSS selector against an HTML string and return the matches (text, attrs, and optionally outerHTML for each).

HTML strip to text

FREE w/ compute · or $0.001 · POST /api/html-strip

Strip all HTML tags and return plain text.