NexArt Canonical Renderer, AI Agent Contract

    Unambiguous API semantics for AI coding agents, CI systems, and programmatic clients.

    Important

    The NexArt Canonical Renderer is not a free public service. All certified execution requires an authenticated account.

    TL;DR for Agents

    • Local execution is free. No account required.
    • Canonical renderer always requires an account + API key.
    • There is no anonymous or public node.
    • Output is binary PNG, not JSON.
    • Certification is what is metered and billed.

    Execution Model

    NexArt supports two execution paths:

    1. Local Deterministic Execution

    • Uses @nexart/codemode-sdk or @nexart/cli
    • Free, unlimited, no account required
    • Deterministic output on your machine
    • No network calls, no metering

    2. Canonical Certified Execution

    • Uses POST /api/render on the canonical renderer
    • Requires an authenticated account and valid API key
    • Produces auditable, verifiable proof artifacts
    • Metered against account quota

    Canonical Renderer API

    POST /api/render

    Authentication

    All requests require a valid API key:

    Authorization: Bearer nx_live_...

    All canonical access is authenticated. There is no public endpoint, no anonymous mode, and no way to render without a valid API key.

    Request Payload (Strict)

    { "code": "function setup() { background(50); }", "seed": "12345", "VAR": [50, 50, 50, 0, 0, 0, 0, 0, 0, 0], "protocolVersion": "1.2.0" }
    FieldTypeRequiredNotes
    codestringYesThe generative sketch code
    seedstringYesRandom seed for deterministic output
    VARnumber[]YesExactly 10 values (VAR[0..9])
    protocolVersionstringRecommendedDefaults to current if omitted

    Recommendation

    Agents should always send protocolVersion explicitly. This ensures reproducibility and prevents output drift when the renderer updates.

    Output Format (Critical)

    • Content-Type: image/png
    • Resolution: 1950×2400 pixels (fixed, non-configurable)
    • Body: Binary PNG data

    Critical Warning

    Do NOT call response.json() on this endpoint. The response is binary image data, not JSON.

    Correct Handling (JavaScript)

    const response = await fetch('/api/render', { method: 'POST', headers: { 'Authorization': 'Bearer nx_live_...', 'Content-Type': 'application/json' }, body: JSON.stringify({ code, seed, VAR, protocolVersion }) }); // CORRECT: Handle as binary const buffer = await response.arrayBuffer(); const blob = new Blob([buffer], { type: 'image/png' }); // WRONG: Do not do this // const data = await response.json(); // ❌ Will throw error

    Artifact vs Proof

    TypeFormatPurpose
    ArtifactPNG (binary)The rendered image at canonical resolution
    ProofSnapshot (JSON)Metadata for verification: hashes, inputs, protocol version

    The PNG is portable and viewable. The snapshot enables verification by re-rendering and comparing hashes.

    // Snapshot structure { "protocolVersion": "1.2.0", "seed": "12345", "VAR": [...], "codeHash": "sha256:...", "outputHash": "sha256:...", "timestamp": "2025-01-27T..." }

    Quotas & Metering

    • Quotas are enforced at the account level
    • All API keys under one account share the same quota
    • Only successful renders (HTTP 200) count toward usage
    • Quota is checked before rendering begins
    • When quota is exceeded, the renderer returns HTTP 429 and does not render

    Quota Headers

    Successful responses include:

    HeaderMeaning
    X-Quota-LimitMonthly quota for the account
    X-Quota-UsedRenders used this month
    X-Quota-RemainingRenders remaining this month

    Error Semantics

    Stable HTTP status codes for programmatic handling:

    CodeMeaningAgent Action
    400Protocol violation (e.g., wrong canvas size, invalid VAR)Fix request payload
    401Missing or invalid API keyCheck Authorization header
    403API key disabled or account suspendedContact account owner
    429Quota exceeded or rate limitedWait or upgrade plan
    503Service temporarily unavailableRetry with backoff

    What NexArt Never Charges For

    • @nexart/codemode-sdk, Free
    • @nexart/cli, Free
    • Local deterministic execution, Free
    • Verification of existing snapshots, Free
    • Reading documentation, Free

    Only certified renders via the canonical renderer are metered.

    One-Line Rule for Agents

    Rule

    If you need a verifiable proof that the output is canonical, call the canonical renderer with a valid API key. Otherwise, execute locally for free.

    Related Documentation