Sanity AI Assist Setup for Editors in Next.js
By Nayan Kyada · · 7 min read
Part of The Sanity + Next.js Guide
Sanity AI Assist — the @sanity/assist Studio plugin — lets editors run AI commands directly inside Sanity Studio without touching any code. Drafting a field, translating a snippet, summarising a long body, generating SEO metadata: all of it happens in-place, triggered by the editor, inside the same Studio your team already uses. Here is how I wire it up in a Next.js + Sanity project and which instruction patterns have actually been useful.
Heads up: AI Assist is actively evolving. This post covers what is stable and documented as of mid-2026. Always treat the official Sanity AI Assist docs as the authoritative reference — API surface and option names can change between minor releases.
What Sanity AI Assist actually does
AI Assist is a Studio-side plugin. It does not touch your Next.js application code at all. The plugin adds a sparkle icon to compatible fields and to the document header; editors pick from saved instructions (written in plain language in Studio and shared across the team) or create new ones. The output is written into the field directly. Translation, tone adjustments, summarisation, and field-specific generation all run through Sanity's hosted AI layer — you do not manage an OpenAI key yourself, but you do need an eligible Sanity plan (check current plan eligibility on the pricing page before you start).
From a Next.js perspective the integration is transparent. The Next.js app reads published content from the Sanity Content Lake exactly as it does today — AI-generated text is just content. No extra API calls, no SDK changes on the frontend.
Installing and configuring the plugin
Start inside your Sanity Studio workspace. If you followed the embedded Studio pattern common in Next.js App Router projects, your Studio lives at something like app/studio/[[...tool]]/page.tsx with a sanity.config.ts at the project root.
# Run this inside your project root (where package.json lives)
npm install @sanity/assistThen register the plugin in sanity.config.ts:
// sanity.config.ts
import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
import { assist } from '@sanity/assist'
export default defineConfig({
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!,
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET!,
plugins: [
structureTool(),
assist(), // Add this. No required options for basic setup.
],
schema: {
types: [
// your schema types
],
},
})That is the minimum. Run next dev, open Studio and any document, click the sparkle icon, and choose Enable Sanity AI Assist — this creates a "Sanity AI" API token for the project (someone with token-creation permissions has to do it once). After that, the AI Assist menu is available on compatible fields across all datasets.
Defining useful AI instructions on schema fields
Out of the box, AI Assist is enabled for every compatible field and document type. Instructions themselves are not written in schema code — editors (or you, during setup) create them in Studio via the sparkle icon on a field or document header, and they're stored in the dataset so the whole team can reuse them. This is where you invest the most time — the quality of instructions directly determines whether editors trust the feature or ignore it. Your schema work is about scoping: exclude fields the AI should never touch, and switch on the image-specific helpers.
Here is a practical example for a blog post schema. I keep schemas in sanity/schemas/.
// sanity/schemas/post.ts
import { defineField, defineType } from 'sanity'
export const post = defineType({
name: 'post',
title: 'Post',
type: 'document',
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
// Keep AI Assist away from deterministic fields
aiAssist: { exclude: true },
},
}),
defineField({
name: 'excerpt',
title: 'Excerpt',
type: 'text',
rows: 3,
}),
defineField({
name: 'seoDescription',
title: 'SEO meta description',
type: 'string',
}),
defineField({
name: 'mainImage',
title: 'Main image',
type: 'image',
fields: [
defineField({ name: 'alt', title: 'Alternative text', type: 'string' }),
],
options: {
// Adds a "Generate image description" instruction to the alt field
aiAssist: { imageDescriptionField: 'alt' },
},
}),
],
})Then, in Studio, hover the excerpt field, click the sparkle icon, and create instructions such as "Generate excerpt from title" (for example: write a 1–2 sentence excerpt for a post with the document's Title field inserted as context; plain prose, no hype, under 160 characters) and "Shorten to one sentence". Do the same for the SEO description field. Those instructions then appear in the field's AI Assist menu for every editor — the normal input stays where it is, with the sparkle icon alongside it.
A few things I have learned the hard way:
- Be specific about character limits. Editors trust output they do not have to rewrite. Vague prompts produce vague results.
- Reference other fields in instructions. The instruction editor lets you insert document fields (e.g. the title) as context — use that instead of hoping the model guesses.
- Exclude what shouldn't be touched. AI Assist targets every supported field by default, so set
options.aiAssist.exclude: trueon fields and types where AI output makes no sense — it also keeps the schema context small on large Studios. Portable Text body fields are usually better written by a human. I focus instructions on structured fields: excerpt, meta description, SEO title, alt text, and social share copy.
How it fits a Next.js content workflow
The day-to-day flow for an editor looks like this: they open a post document in Studio, write or paste the title, click the AI button on the excerpt field, pick "Generate excerpt from title", review the output, tweak if needed, then publish. The published document hits the Content Lake. Your Next.js App Router pages pick it up via GROQ queries exactly as they do for any other content — nothing changes on the frontend.
If you are using ISR or on-demand revalidation (via Sanity webhooks to a Next.js route handler), the AI-generated content flows through that same pipeline. There is no special handling needed.
One workflow note worth calling out: AI Assist operates on draft documents. The editor reviews and approves before publishing. This is the right model — the AI is a writing assistant, not an autopublisher. Make that clear to your content team during onboarding, because a common confusion is editors expecting AI to update the live site immediately.
Access control and plan considerations
AI Assist availability depends on your Sanity plan. At the time of writing, Sanity's docs list it as available on the Growth plan and up — verify current limits on sanity.io/pricing because this changes. It is switched on project-wide via the "Sanity AI" token created from Studio; revoking that token in sanity.io/manage disables it again.
There is no configuration needed in Next.js itself — no environment variables to add, no API routes to create. The AI computation runs server-side within Sanity's infrastructure.
What I skip and why
I do not use AI Assist to generate Portable Text body content. Long-form generation inside a block editor produces inconsistent structure, and the editor ends up spending more time cleaning markup than they would writing from scratch. I also exclude slug fields (as in the schema above) — slug logic should be deterministic and tied to validation, not a freeform AI suggestion.
The plugin earns its keep on the repetitive structured fields: SEO metadata, alt text, excerpts, social copy. Those are the fields editors consistently skip or fill with placeholder text, and they directly affect Next.js page metadata and accessibility (alt text feeds next/image, meta description feeds search CTR).
For anything beyond what is covered here — document-level translation, the @sanity/document-internationalization integration, or using AI instructions that reference multiple fields — start with the Sanity AI Assist documentation. The plugin's capabilities are expanding quickly and the docs reflect current state more reliably than any third-party post.
Frequently asked questions
01What is Sanity AI Assist and where's the official documentation?
AI Assist (the `@sanity/assist` Studio plugin) adds a sparkle (AI Assist) menu to compatible fields and documents, letting editors create and run reusable natural-language instructions that write into fields in place — translation, summarisation, SEO metadata generation, and similar structured tasks. The authoritative reference is [Sanity's AI Assist docs](https://www.sanity.io/docs/studio/install-and-configure-sanity-ai-assist) — the API surface changes between minor releases, so treat this post as a working setup guide and the docs as the source of truth.
02Does Sanity AI Assist require a specific plan?
As of mid-2026 it's available on Growth and Enterprise plans, not the Free tier — verify current eligibility on [sanity.io/pricing](https://www.sanity.io/pricing) since plan inclusions change. Once a project member with token permissions clicks **Enable Sanity AI Assist** in Studio, it works for everyone on the project.
03Does Sanity AI Assist require any changes on the Next.js side?
No. AI Assist runs entirely inside Sanity Studio and Sanity's hosted AI layer — there's no environment variable, API route, or SDK change needed in your Next.js app. AI-generated text is published like any other content and your existing GROQ queries pick it up unchanged.