---
title: "Label AI-generated content"
description: "Mark what a model made, in the file and in the page: the IPTC digital source type, and C2PA content credentials signed with the deployment's key, in each JPEG, PNG or WebP stored through `ctx.storeImage` once `setupAi({ provenance })` is on, a provenance record of which model made what from which inputs, and the visible AI-generated label the EU AI Act asks for."
canonical_url: "https://nuxt-backend.dev/docs/build/ai/provenance"
---
# Label AI-generated content

> Mark what a model made, in the file and in the page: the IPTC digital source type, and C2PA content credentials signed with the deployment's key, in each JPEG, PNG or WebP stored through `ctx.storeImage` once `setupAi({ provenance })` is on, a provenance record of which model made what from which inputs, and the visible AI-generated label the EU AI Act asks for.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: experimental

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- **You get:** generated images that say they are AI-generated in their own metadata, a record of which model made each result from which inputs, and a visible label in the page.
- **Powered by:** the open [C2PA](https://c2pa.org) standard for content credentials (version 2.3), and the [IPTC](https://cv.iptc.org/newscodes/digitalsourcetype/) digital source type vocabulary. The Content Credentials verifier and a growing number of tools and platforms read them (checked on 2026-10-25).
- **The package adds:** a signed manifest written into every image your steps store, the IPTC source type beside it, the provenance record on job results, and `<AiLabel>`.

People should be able to tell what a model made, and so should software. EU AI Act Art. 50 asks for both from 2026-08-02: generated images, audio, video and text marked in a machine-readable way, and deep fakes disclosed to the people who see them. Apps already on the market have until 2026-12-02 ([Disclose AI-generated content](https://nuxt-backend.dev/docs/ship/compliance/ai-transparency) has the duties; it is not legal advice).

Panels draws comic strips from people's ideas and photos, so every panel it stores carries content credentials, and every panel it shows carries a label.

## Label a result

Turn provenance on in `setupAi`:

```ts [backend/ai.ts]
import { setupAi } from 'nuxt-backend/ai'
import { components } from './_generated/api'
import { billing } from './billing'
import { rateLimiter } from './rateLimiter'

export const ai = setupAi(components, {
  billing,
  rateLimiter,
  provenance: { name: 'Panels' },
})
```

`provenance: true` is the shorthand with the defaults, and `{ name }` sets the generator name the manifest shows. Then store each generated image through `ctx.storeImage`, in a [job step](https://nuxt-backend.dev/docs/build/ai/jobs#define-a-job) or a [metered action](https://nuxt-backend.dev/docs/build/ai/metered-actions), instead of `ctx.storage.store`:

```ts [backend/strips.ts]
export const drawPanel = jobs.step({
  model: 'google/gemini-3.1-flash-image-preview',
  args: { stripId: v.id('strips'), photoId: v.id('_storage'), idea: v.string(), panel: v.number() },
  handler: async (ctx, { stripId, photoId, idea, panel }) => {
    const { files } = await generateText({ model: ctx.model(), prompt: `Panel ${panel} of a strip about ${idea}.` })
    const image = files.find(file => file.mediaType.startsWith('image/'))!
    const storageId = await ctx.storeImage(image, { inputs: [stripId, photoId] })
    await ctx.runMutation(internal.strips.savePanel, { stripId, panel, storageId })
  },
})
```

`ctx.storeImage(file, { inputs, sourceType? })` takes the file the AI SDK returned and, before it reaches file storage:

1. **Writes a C2PA manifest into it.** The manifest's actions say the image was created (`c2pa.created`), with the IPTC digital source type `trainedAlgorithmicMedia`, the generator (your `provenance.name` and the model id) and the time. A hash binds the manifest to every byte of the file, so any later edit shows as one.
2. **Signs the manifest** with your app's signing key, inside your deployment, in the step itself: the package writes and signs it with Web Crypto, so it needs no Node.js action and no native code.
3. **Adds the IPTC source type to the XMP metadata** too, for software that reads IPTC and not C2PA.
4. **Records the provenance** in the package's component: the storage id, the models, the time and the `inputs` you pass. `inputs` are ids of your own rows and files, never their content, and are never read: the record names them, the manifest does not.
5. **Keeps the image as its owner's file**, in the package's file storage beside the uploads `setupStorage` keeps. A job's image belongs to the job's owner: the workspace that pays for it, read by its members, or the account. A metered action's belongs to the caller's billing entity. The [storage quota](https://nuxt-backend.dev/docs/build/data/files/checked-uploads) counts it, the owner's [data export](https://nuxt-backend.dev/docs/ship/compliance/privacy) lists it, and the owner's erasure deletes it. The quota never refuses it, since the model was paid for by then: check the quota before you start the job.

Two helpers store files, one per side. `ctx.storeImage` is for what a model made, inside a job step or a metered action. `storage.store(ctx, bytes, owner)` is for what a person uploaded, inside your mutation ([Accept checked uploads](https://nuxt-backend.dev/docs/build/data/files/checked-uploads)).

It resolves with the file's storage id, in the package's storage: keep it in a `v.string()` field, as you keep an upload's. It takes the AI SDK's generated file, a `Blob` or the bytes. While `provenance` is off it throws: store the file with `ctx.storage.store` then.

Read the image's URL through the package, as you read an upload's: `storage.fileUrl(ctx, storageId)` in a query that decided who may see it, `storage.signedUrl` for an expiring link, or `getFileUrl` behind `<StorageImage>`, which shows it to the owner's members only. `ctx.storage.getUrl` reads your app's own storage and answers `null` for it. Delete it with `storage.release(ctx, storageId)` when your row drops it.

`sourceType: 'composite'` writes `compositeWithTrainedAlgorithmicMedia` instead, for a photo a model edited in part, such as inpainting a background. A new image made from a photo, as a Panels panel is, stays `trainedAlgorithmicMedia`.

### The signing key

`npx nuxt-backend env push` generates a signing key and its certificate when the backend turns provenance on and neither `.env.local` nor the deployment has them. It keeps them in `.env.local`, so a later `env push --prod` sets the same pair on production, and sets them on the deployment:

<table>
<thead>
  <tr>
    <th>
      Variable
    </th>
    
    <th>
      What it is
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        PROVENANCE_PRIVATE_KEY
      </code>
    </td>
    
    <td>
      The key that signs every manifest: a PKCS #8 PEM key (<code>
        BEGIN PRIVATE KEY
      </code>
      
      ), P-256, P-384 or RSA.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        PROVENANCE_CERTIFICATE
      </code>
    </td>
    
    <td>
      The certificate chain embedded in each manifest, the signer's certificate first, so anyone can check the signature.
    </td>
  </tr>
</tbody>
</table>

Both are PEM text on one line, their line ends written as `\n`. A key that does not match the first certificate, or a value that can't be read as PEM, signs nothing: the image is stored with the source type only, and the log says why.

C2PA readers refuse a self-signed signer, so the generated certificate is issued by a root made for it, whose key is thrown away. It proves the image was not changed since you signed it, but verifiers show its signer as unknown, since that root is on no trust list. For a named signer, buy a certificate from a certificate authority on the [C2PA trust list](https://c2pa.org) and put it and its key in the two variables. Rotating them is safe: each manifest carries the certificate it was signed with.

## Show it in a page

`<AiLabel>` renders the visible label, "AI-generated", in the reader's language. Put it beside every generated image or text people could take for something a person made:

```vue [app/pages/strips/[id].vue]
<script setup lang="ts">
import { api } from '#backend/api'

const route = useRoute()
const strip = useQuery(api.strips.get, () => ({ id: route.params.id as string }))
const job = useJob(() => strip.value?.jobId)
</script>

<template>
  <figure v-for="panel in strip?.panels" :key="panel._id">
    <img :src="panel.url ?? undefined" :alt="`Panel ${panel.panel} of ${strip?.idea}`">
    <figcaption>
      <AiLabel :provenance="job.provenance.value" :src="panel.url" />
    </figcaption>
  </figure>
</template>
```

- **Without props**, it is the label alone.
- **With provenance**, it opens a details popover on press: the model, the date, and a link to check the image's content credentials. Pass the image's URL as `src` and the link opens the verifier on it. Pass a public URL: a signed one (`storage.signedUrl`) is a key to a private file, so it is never sent, and the verifier asks for the file instead. The link sends no referrer.
- **Without its markup**, `useAiLabel({ provenance, src })` returns the same words, state and bindings for markup of your own.
- **Its words are labels**, so you can reword or translate them like the rest of the UI ([Change copy and labels](https://nuxt-backend.dev/docs/build/ui/customize/labels)). Keep the meaning: "AI-generated" or "Made with AI", not a vague "Enhanced".

`useJob(jobId).provenance` reads a job's record once it is done: `{ models, finishedAt, inputs }`. For an image stored outside a job, `ai.provenanceOf(ctx, storageId)` reads the same record in a query of your own.

Label text the same way. A caption or a story a model wrote carries no metadata a file can hold, so the label and the provenance record are its marking.

## What happens when…

<table>
<thead>
  <tr>
    <th>
      The image
    </th>
    
    <th>
      What happens
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Is stored with no signing key set
    </td>
    
    <td>
      Stored with the IPTC source type only, no manifest; the log says <code>
        ai.provenance_unsigned
      </code>
      
      , <code>
        doctor
      </code>
      
       warns and <code>
        doctor --prod
      </code>
      
       fails
    </td>
  </tr>
  
  <tr>
    <td>
      Is in a format C2PA cannot carry
    </td>
    
    <td>
      Stored without a manifest, with the provenance record; the log says <code>
        ai.provenance_skipped
      </code>
      
       and names the type. JPEG, PNG and WebP are supported
    </td>
  </tr>
  
  <tr>
    <td>
      Passes through <code>
        setupStorage
      </code>
      
      's metadata stripping
    </td>
    
    <td>
      Keeps its manifest: <code>
        ctx.storeImage
      </code>
      
       writes after the strip, which only touches uploads
    </td>
  </tr>
  
  <tr>
    <td>
      Is downloaded and re-uploaded elsewhere
    </td>
    
    <td>
      Keeps its manifest where the other service keeps metadata, and loses it where it strips metadata. Your provenance record stays
    </td>
  </tr>
  
  <tr>
    <td>
      Is edited after you stored it
    </td>
    
    <td>
      The hash no longer matches, and verifiers say the content changed since signing
    </td>
  </tr>
</tbody>
</table>

## Limits

- **Metadata can be stripped.** Many social platforms remove it on upload, and a screenshot drops it. C2PA's answer is durable credentials: a watermark or fingerprint that finds the manifest again. The package writes no watermark yet. The AI Act's Code of Practice expects watermark detection to work across vendors by 2027-02-02, and the [Roadmap](https://nuxt-backend.dev/docs/start/roadmap) tracks it.
- **Text has no file to carry a manifest.** The visible label and the record are what the package offers for text.
- **The model's own marks are separate.** Some providers embed their own watermark or credentials. The package keeps a file that carries credentials as it came and adds no manifest of its own, since a second one would break the first one's hash; the record is still written, and the log says `ai.provenance_skipped`.
- **No trusted timestamp.** The manifest is signed without a time-stamping authority, so verifiers check it against the certificate's validity: ten years for the generated one.
- **Inputs are not ingredients.** `inputs` are recorded by id; an input that carries content credentials of its own does not join the manifest as an ingredient yet.
- **Signing costs a little.** Writing and signing a manifest adds a short step and a few kilobytes to each image.
- **Not legal advice.** Whether your app is a provider or a deployer under Art. 50, and which exceptions apply, is for you and your counsel ([Disclose AI-generated content](https://nuxt-backend.dev/docs/ship/compliance/ai-transparency)).

## Test it

On your dev deployment, generate a panel, download it, and read its manifest with the Content Authenticity Initiative's open-source `c2patool`:

```bash
c2patool panel-1.png
```

It prints the manifest: the `c2pa.created` action, `trainedAlgorithmicMedia` as the digital source type, your `provenance.name`, the model id and the signature. Drop the same file on the [Content Credentials verifier](https://contentcredentials.org/verify) to see it as people will. Under Vitest, `ai.provenanceOf` returns the record a step wrote, so a test can check the inputs it names.

## Related

- [AI gateway](https://nuxt-backend.dev/docs/services/ai-gateway): the image models the panels come from.
- [Disclose AI-generated content](https://nuxt-backend.dev/docs/ship/compliance/ai-transparency): Art. 50, who it applies to, and the deadlines.
- [Run generation jobs](https://nuxt-backend.dev/docs/build/ai/jobs): `ctx.storeImage` in a step, and the provenance on job results.
- [Turn a long generation into a job](https://nuxt-backend.dev/docs/build/ai/jobs/long-generation): the strip renderer with labeled panels.
- [`nuxt-backend/ai` reference](https://nuxt-backend.dev/docs/reference/api/ai): every option of `setupAi`.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
