Tutorial · Images
Mark every image your Vercel AI SDK app generates, with one wrapper
Wrap an image model once with markproof-ai: every image generateImage returns is watermarked and C2PA-signed, with the model recorded for you, and if marking fails, so does the generation.
0:37 video · Real run on 29 November 2026 · Markproof
0:37 · text on screen, no narration
In short
- Wrap your image model once with
markproofImageMiddleware. Every imagegenerateImagereturns then carries an invisible watermark and signed Content Credentials (C2PA). - Each image gets its own code and verify link, and your app's name and the exact model go into the signed record automatically.
- It's safe by default: if marking fails, the generation fails, so an unmarked image never slips out by mistake.
1. Install
You need Node.js 18+, a Markproof API key (sign up, 250 free calls a month) and a key for your image provider. This run used FLUX on fal.ai; the wrapper works with any image model the AI SDK supports.
npm install ai @ai-sdk/fal markproof-ai# .env: MARKPROOF_API_KEY (your Markproof key) and FAL_KEY (your fal.ai key)2. Wrap the model and generate
This is the whole script as it ran, asking for two images:
import { writeFile } from "node:fs/promises";import { generateImage, wrapImageModel } from "ai";import { fal } from "@ai-sdk/fal";import { markproofImageMiddleware } from "markproof-ai"; // Wrap the model once. Every image it generates comes back marked.const model = wrapImageModel({ model: fal.image("fal-ai/flux/dev"), middleware: markproofImageMiddleware({ generatorName: "my-app" }),}); const { images, providerMetadata } = await generateImage({ model, prompt: "Studio product photo of a matte white ceramic coffee mug on an oak table, soft morning light", n: 2, size: "1024x1024",}); for (const [i, image] of images.entries()) await writeFile(`mug-${i + 1}.png`, image.uint8Array);console.log(JSON.stringify(providerMetadata.markproof.images, null, 1));The proofs come back in providerMetadata.markproof.images, one per image, in the same order:
[ { "marked": true, "assetId": "45a7ac2b-ae8f-4854-9d88-a3685d90df4f", "watermarkCode": "JW2WP36B", "verifyUrl": "https://markproof.co/v/JW2WP36B", "c2paManifestLabel": "urn:c2pa:ea2704ce-e7bd-4ac1-89b3-79df7db827f8", "watermarkRobust": true }, { "marked": true, "assetId": "3fd3c42c-b11b-4102-a37c-7d71faedd615", "watermarkCode": "GVR83ST1", "verifyUrl": "https://markproof.co/v/GVR83ST1", "c2paManifestLabel": "urn:c2pa:eeec595c-e7db-40a5-a38c-d9515e997ebf", "watermarkRobust": true }]Both checked back through the API: watermark found with the matching code, and Content Credentials present and valid. You can confirm it yourself by downloading either file and dropping it into the free checker.
3. What goes into the signed record
The middleware fills in the model as provider/modelId from the AI SDK, so there's nothing extra to pass. Pass modelName if you want different text.
| Field | Value in this run |
|---|---|
| Action | created |
| Digital source type | trainedAlgorithmicMedia |
| Software | my-app / fal.image/fal-ai/flux/dev |
| Signed by | Markproof |
4. Safe by default
If marking fails (a bad key, the quota used up, a network problem), generateImage throws instead of returning an unmarked image. Here's the same call with a key that doesn't work:
const model = wrapImageModel({ model: fal.image("fal-ai/flux/dev"), middleware: markproofImageMiddleware({ generatorName: "my-app", apiKey: "lt_live_not_a_real_key" }),}); await generateImage({ model, prompt, size: "1024x1024" });// Error: API key not_found. (no image is returned)If you'd rather keep the image and handle it yourself, pass onError: "passthrough". The original comes back unmarked, and the proof records the error, so you can log it or retry.
Prefer plain Node.js, Python or HTTP? See Add Article 50 marking to your AI app in 10 minutes, or Tutorial 1 for what the watermark survives. This is technical guidance, not legal advice.
Check your own output in seconds.
Drop a file into the free checker to see whether it carries a watermark and Content Credentials. Then mark your files with one API call: 250 free calls a month, no card required.

