Integration

Lamina + Sanity

Write generated assets and their metadata into a Sanity dataset as native image documents queryable from GROQ.

The Lamina + Sanity integration writes generated assets and structured metadata into a Sanity dataset as native image documents. lamina.distribute calls the Sanity Asset API to upload bytes and patches the target document with the asset reference — so generated content is queryable through GROQ alongside hand-curated content.

What you can do

  • Upload generated assets to a Sanity dataset via the Asset API
  • Patch existing documents with the new asset reference and metadata
  • Write run id, brand-fit score, and seed to a sibling field for traceability
  • Generate alt text from the brief and store it on the image asset
  • Bind the integration to a workspace + dataset (production / staging) per environment

Setup

  1. 1

    Generate a Sanity API token

    In manage.sanity.io, create a token with Editor or Deploy access on the target dataset.

  2. 2

    Add the token to Lamina

    In Lamina dashboard → Integrations → Sanity, paste the token and pick projectId + dataset.

  3. 3

    Distribute a run to Sanity

    Call lamina.distribute with target { kind: 'sanity', projectId, dataset, document, fieldPath, assetRoleName }.

  4. 4

    Query through GROQ

    Treat generated assets like any other Sanity image — *[_type == 'product' && lamina.score >= 0.85]

Example

sanity-distribute.ts

await lamina.distribute(shoot.assets, {
  targets: [{
    kind: "sanity",
    projectId: "abc12345",
    dataset: "production",
    document: "product.homestead-linen-tee",
    fieldPath: "hero.image",
  }],
});

// Then in your frontend:
// *[_type == 'product' && hero.image.asset->lamina.score >= 0.85]

How it works

Lamina uses Sanity's HTTP Asset API to upload generated bytes, then mutates the target document to attach the asset reference at the path you specify. Run id, brand-fit score, model graph, and seed are written to a sibling object so editors can trace any image back to the run that produced it. Because the asset is a native Sanity image, every CDN transformation — hotspot, crop, format — works without further wiring.

When to use it

Use this integration when Sanity is your source of truth for content and you want generated assets to flow through the same review, scheduling, and localization machinery as the rest of your editorial work. Pairs naturally with the Sanity AI Assist plugin for editors who want to trigger Lamina runs from inside Studio.