# How do you build a knowledge base with AI answers on Sanity?

Reviewed by Martin Dejnicki · facts verified 25 October 2026 · canonical: https://deploi.ca/sanity/use-cases/knowledge-base-with-ai-answers

Experience: Deploi runs this in production.

## Short answer

Sanity runs a knowledge base with AI answers without a separate vector database, because Dataset Embeddings add semantic search to GROQ (Graph-Relational Object Queries) on every plan ([Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings), October 2026). Growth includes 1,000 semantic queries a month, then $1.50 per 1,000 ([Sanity pricing](https://www.sanity.io/pricing), October 2026). You bring the chat framework and model; Sanity stores and retrieves answers.

- **Semantic search:** Dataset Embeddings, on every plan. Generating and updating embeddings is included; queries using text::semanticSimilarity() count against a monthly quota ([Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings); [Sanity, Plans that scale with you](https://www.sanity.io/pricing))
- **Semantic query quota:** 500 a month on Free, 1,000 on Growth. Growth overage is $1.50 per 1,000 queries; Free stops at its limit; Enterprise is custom ([Sanity, Plans that scale with you](https://www.sanity.io/pricing); [Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings))
- **Older path:** Embeddings Index API, deprecated. No new features or fixes; Dataset Embeddings replace its two requests with one GROQ query ([Sanity Docs, Migrate from the Embeddings Index API to Dataset Embeddings](https://www.sanity.io/docs/content-lake/migrate-from-embeddings-index-api); [Sanity Docs, Embeddings Index API reference (deprecated)](https://www.sanity.io/docs/http-reference/embeddings-index))
- **Access for external agents:** Sanity Context, hosted and read-only. A Model Context Protocol server you switch on in Labs; you bring the model and agent loop; its Knowledge Bases mode is an opt-in beta ([Sanity Docs, Sanity Context](https://www.sanity.io/docs/ai/sanity-context); [Sanity, Plans that scale with you](https://www.sanity.io/pricing))

## Deploi's call

Build the answers first and the chatbot second. A knowledge base on Sanity pays off when every answer is a structured document with a short, quotable capsule, because the page and the chatbot's retrieval then read the same field. Start with GROQ semantic search plus a keyword fallback inside your own app, and add Sanity Context only when an external agent needs schema-aware access.

**BUILD: Build it on Sanity when**

- Your answers are, or should be, structured documents your editors own.
- Retrieval must respect rules in the same query: published only, category, locale or visibility.
- A developer will own the chat framework, the retrieval tests and the model bill.
- Chatbot traffic fits Growth's 1,000 semantic queries a month, or the $1.50 per 1,000 overage is budgeted ([Sanity pricing](https://www.sanity.io/pricing), October 2026).

**BUY: Buy a support chatbot tool instead when**

- The knowledge lives in help desk tickets, PDFs and macros rather than a content management system.
- You need agent handoff, ticketing and conversation analytics on day one, because Sanity stores and retrieves answers but ships no help desk.
- Nobody will maintain prompts and retrieval tests after launch.

## What does a knowledge base with AI answers need from a CMS?

A knowledge base with AI answers needs four things from a content management system (CMS): answers stored as structured documents, a short answer field a model can quote, rich text that flattens to plain text, and a retrieval query that ranks by meaning while it filters by rules. Sanity covers all four. Schema types in Sanity Studio define the answer document, Portable Text holds the body, and `pt::text()` turns that body into searchable text inside GROQ (Graph-Relational Object Queries) ([Sanity Docs, Search text content with GROQ](https://www.sanity.io/docs/content-lake/search-content-with-groq), October 2026).

The short answer field is the part teams skip. On deploi.ca's Shopify FAQ, each of the 256 live answers carries a capsule, key facts and a Deploi call as separate fields, counted 24 October 2026, and the schema validates the capsule at 40 to 75 words. The page and the chatbot's retrieval read the same capsule field, so the two can't drift apart. Structuring content so AI engines can quote it covers that answer layer on its own.

## Which Sanity capabilities does a knowledge base with AI answers use?

A knowledge base with AI answers on Sanity uses six layers, and only the top one sits outside Sanity: the chat framework and the model you pick.

**A knowledge base with AI answers on Sanity, from the visitor down to storage**

- Answer: your chat framework, your large language model
- Agents: Sanity Context, Sanity's Model Context Protocol (MCP) server
- Retrieval: Graph-Relational Object Queries (GROQ), Dataset Embeddings, keyword scoring
- Content: Portable Text, answer fields, categories
- Editing: Sanity Studio schema, validation rules, Structure Builder
- Storage: Content Lake dataset with embeddings enabled

The combination works because retrieval happens inside the content store. Dataset Embeddings add semantic search to GROQ, so one query filters, scores by meaning and returns the fields a model needs ([Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings), October 2026). Sanity Context is a hosted, read-only MCP server for external agents; it doesn't run the agent loop or write content, and an organization admin switches it on from the Labs page ([Sanity Docs, Sanity Context](https://www.sanity.io/docs/ai/sanity-context), October 2026). GROQ mode needs Sanity Studio 5.1.0 or later and a deployed schema. Sanity's pricing page lists it on every plan under the name Agent Context ([Sanity pricing](https://www.sanity.io/pricing), October 2026). What Sanity Context gives an agent is a separate review. The Sanity MCP server for editing agents can patch documents ([Sanity Docs, Sanity MCP server](https://www.sanity.io/docs/ai/mcp-server), October 2026), so keep it away from a public chatbot.

## How does a visitor's question become a grounded answer?

A visitor's question becomes a grounded answer when the chatbot runs one GROQ (Graph-Relational Object Queries) query, Content Lake returns the ranked answer documents, and the model writes from them.

**How a visitor's question becomes a grounded answer on deploi.ca's Shopify FAQ**

- Visitor -> Chatbot action: the question, asked on an FAQ hub page
- Chatbot action -> GROQ query: semantic scoring, with keyword scoring if that fails or returns nothing
- GROQ query -> Content Lake: the ranked FAQ answers
- Content Lake -> Model: capsule, body text and category URL of the top answers
- Model -> Visitor: an answer written from those documents

Dataset Embeddings let that one query rank by meaning inside the dataset, so you don't need a separate vector database ([Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings), October 2026). The query keeps its filter, so published-only and category rules still apply. Exact identifiers such as brand names and model numbers embed poorly, which is why Sanity's docs advise adding keyword matching and why the flow keeps a keyword fallback. [How the semantic query is written](https://deploi.ca/sanity/builds/semantic-search-in-groq) is covered in the build page.

## How do you keep AI answers grounded in your content?

You keep AI answers grounded by controlling what retrieval returns, not by asking the model to behave. Three controls keep answers grounded:

- **Put the rules in every query.** Published-only, category, locale and visibility rules belong in the GROQ (Graph-Relational Object Queries) filter itself. Sanity warns that a filter left out "can surface content you meant to hide" ([Sanity Docs, migration guide](https://www.sanity.io/docs/content-lake/migrate-from-embeddings-index-api), October 2026).
- **Return answer fields, not whole documents.** deploi.ca's retrieval returns each answer's capsule, its body as plain text and its category URL, so the model writes from short, sourced text.
- **Keep the instructions in Sanity Studio.** A chatbot settings document with an on switch and an instruction field lets editors change the assistant's behavior, or turn it off, without a deploy. deploi.ca also limits the knowledge-base action to FAQ hub pages and rate-limits requests.

For external agents, Sanity Context scopes dataset reads with a GROQ filter and stays read-only ([Sanity Docs, Sanity Context](https://www.sanity.io/docs/ai/sanity-context), October 2026). Deploi hasn't measured retrieval accuracy on deploi.ca, so we don't quote a figure. Sanity's migration guide says to test with real search queries pulled from your logs or analytics, which is the method we'd use ([Sanity Docs, migration guide](https://www.sanity.io/docs/content-lake/migrate-from-embeddings-index-api), October 2026).

## How do you build a knowledge base with AI answers on Sanity, step by step?

Build a knowledge base with AI answers on Sanity in eight steps, content first and chatbot last, because retrieval can only return what the schema stores.

**Building a knowledge base with AI answers on Sanity**

1. **Model the answer.** Define an answer document with a question, a short capsule, a Portable Text body and a category, and validate the capsule's length.
1. **Load real answers.** Import your existing content, or start from the sample dataset that ships with the FAQ Hub with AI Chatbot template.
1. **Enable Dataset Embeddings.** Turn embeddings on for the dataset with a tight projection, such as question, capsule and body.
1. **Write the retrieval query.** Filter by type and visibility, score by keyword and by meaning, slice the top results, and project only the fields the model needs.
1. **Add the fallback.** Run a keyword-only query when the semantic query errors or returns nothing.
1. **Wire the chatbot.** Give your chat framework an action that runs the query, and keep its instructions in a settings document in Sanity Studio.
1. **Test with real questions.** Pull questions from your search logs or analytics and check which answers come back before launch.
1. **Publish machine-readable copies.** Generate an llms.txt list and a Markdown copy of each answer from the same documents.

The FAQ Hub with AI Chatbot template, which Martin Dejnicki published on Sanity Exchange, gives you steps 2 and 6 ready-made, plus a starting answer schema for step 1 with a required excerpt field ([Sanity Exchange, FAQ Hub with AI Chatbot](https://www.sanity.io/templates/faq-hub-with-ai-chatbot), October 2026). How we built that template covers its schema.

## What does a knowledge base with AI answers on Sanity cost to run?

A knowledge base with AI answers on Sanity costs seats, semantic queries and API (application programming interface) requests, plus a model bill that Sanity doesn't charge. Generating embeddings is included on every plan; reads are what you pay for ([Sanity pricing](https://www.sanity.io/pricing), October 2026).

**Semantic queries are the Sanity meter that grows with chatbot traffic**

| Cost driver | Free | Growth | Enterprise |
| --- | --- | --- | --- |
| Plan price | $0 | $15 per seat a month | Custom |
| Embeddings generation | Included | Included | Included |
| Semantic queries a month | 500, hard limit | 1,000, then $1.50 per 1,000 | Custom |
| API requests a month | 250k | 250k, then $1 per 25k | Custom |
| Model and chat framework | Billed by your providers | Billed by your providers | Billed by your providers |

Sources: [Sanity, Plans that scale with you](https://www.sanity.io/pricing); [Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings). As of 24 October 2026.

A chatbot whose retrieval runs 10,000 times a month on Growth uses the 1,000 included queries and pays for 9,000 more at $1.50 per 1,000, which is $13.50 a month (Deploi arithmetic from the figures above). Semantic queries count against your organization's monthly quota, not one project's ([Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings), October 2026). [What Sanity's Free and Growth plans include](https://deploi.ca/sanity/faq/is-sanity-free) covers seats and quotas.

> **What the model costs**
>
> Sanity doesn't sell or price the model behind your chatbot, and that bill depends on your provider, model and answer length. Deploi hasn't metered one, so we don't estimate it.

## What goes wrong when you build a knowledge base with AI answers on Sanity?

Six pitfalls are documented by Sanity, from a deprecated service in older templates to a limit of 10 chunks per document:

- **Older templates call a deprecated service.** The Embeddings Index API (application programming interface), its command-line package and its Studio plugin get no new features or fixes ([Sanity Docs, migration guide](https://www.sanity.io/docs/content-lake/migrate-from-embeddings-index-api), October 2026). Deploi's own FAQ Hub with AI Chatbot template still uses it for search, so plan the move to Dataset Embeddings.
- **Score thresholds don't port.** `_score` only ranks results within one query, so cut results with a slice, not a number like 0.8 ([Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings); [Sanity Docs, migration guide](https://www.sanity.io/docs/content-lake/migrate-from-embeddings-index-api), October 2026).
- **References don't expand in the projection.** Copy a category name into a real field if search depends on it.
- **Long answers lose their tail.** Sanity embeds at most 10 chunks per document today, and later chunks drop out of search.
- **Turning embeddings off is destructive.** Re-enabling recomputes every document.
- **Knowledge Bases are an index, not your content store.** Sanity's Knowledge Bases are an opt-in beta index that Sanity Context builds from datasets, websites and files and serves to agents; your answers still live as documents in a dataset ([Sanity Docs, Knowledge Bases](https://www.sanity.io/docs/ai/sanity-context-knowledge-bases), October 2026).

## Deploi's point of view

**Where we disagree.** Most build guides start with a vector database and a chunking pipeline. On Sanity that's now extra infrastructure, because Dataset Embeddings put semantic scoring inside the same GROQ query that already filters by type, category and visibility. The second wrong claim is that semantic search alone is enough. Product names, model numbers and error codes embed poorly, Sanity's own docs say to add keyword matching for them, and that's why our assistant keeps a keyword fallback.

**What we've seen.** We built this twice. The FAQ Hub with AI Chatbot template, which Martin Dejnicki published on Sanity Exchange, ships 44 sample FAQ articles in 19 categories, a CopilotKit chatbot whose actions fetch Sanity articles, and semantic search through the Embeddings Index API, which Sanity has now deprecated. On deploi.ca, the Shopify FAQ assistant scores answers with text::semanticSimilarity() in GROQ and falls back to keyword scoring when that errors or returns nothing, and only FAQ hub pages get the knowledge-base action. Its 256 live answers each carry a validated capsule, key facts and a Deploi call as separate fields, and deploi.ca's llms.txt and Markdown copies are generated from the same documents.

**What we refuse to promise.** An accuracy figure. Deploi hasn't measured retrieval or answer quality on deploi.ca's assistant, and no published benchmark covers your content. Ask anyone who quotes one which questions they tested, and on whose content.

**Deploi's rule of thumb.** If more than a handful of your real test questions name products, codes or brands, put keyword scoring in the main query next to semantic scoring, not only in the fallback.

## When this answer changes

- Sanity changes the semantic query quota or the $1.50 per 1,000 overage
- Sanity sunsets the Embeddings Index API
- Sanity Context leaves Labs, or Knowledge Bases leave beta with published limits
- Sanity raises or removes the 10-chunk embedding limit per document
- Sanity renames Agent Context again or changes which plans include it

## How does semantic search in plain GROQ work?

See the queries behind deploi.ca's FAQ assistant: semantic scoring, the keyword fallback and what each returns. [Read the semantic search build](https://deploi.ca/sanity/builds/semantic-search-in-groq)

## Sources

1. [Sanity Docs, Dataset Embeddings](https://www.sanity.io/docs/content-lake/dataset-embeddings), checked 24 October 2026
2. [Sanity, Plans that scale with you](https://www.sanity.io/pricing), checked 24 October 2026
3. [Sanity Docs, Migrate from the Embeddings Index API to Dataset Embeddings](https://www.sanity.io/docs/content-lake/migrate-from-embeddings-index-api), checked 24 October 2026
4. [Sanity Docs, Embeddings Index API reference (deprecated)](https://www.sanity.io/docs/http-reference/embeddings-index), checked 24 October 2026
5. [Sanity Docs, Sanity Context](https://www.sanity.io/docs/ai/sanity-context), checked 24 October 2026
6. [Sanity Docs, Search text content with GROQ](https://www.sanity.io/docs/content-lake/search-content-with-groq), checked 24 October 2026
7. [Sanity Exchange, FAQ Hub with AI Chatbot](https://www.sanity.io/templates/faq-hub-with-ai-chatbot), checked 24 October 2026
8. [Sanity Docs, Sanity MCP server](https://www.sanity.io/docs/ai/mcp-server), checked 24 October 2026
9. [Sanity Docs, Knowledge Bases](https://www.sanity.io/docs/ai/sanity-context-knowledge-bases), checked 24 October 2026
