Load a sample Local RAG index, rank chunks in the browser, and stream a cited answer without a vector database.
Use this when you already have an exported embedding index of text chunks and want users to chat over it with cited, streamed answers.
Similar patterns, and when each one is the better fit.

Local RAG IngestUse this when a small docs or knowledge-base prototype needs its text turned into embeddings held in React state and saved as a portable index.
Local Image SearchUse this when you already have an exported image index and need to search it by meaning in the browser using caption embeddings.
Local Image IngestUse this when teaching or prototyping caption-then-embed for images and you want a downloadable index file as the result.
Jev AEO AuditUse this when auditing a page for AEO and you want title, canonical, and noindex checks in code while Jev judges the citation-worthiness.Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
Download → Next.js app
Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: AI_GATEWAY_API_KEY.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
Run the app and open the pattern route
Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.
AI_GATEWAY_API_KEYGet keyAI SDK APIs
embedcosineSimilaritystreamTextsafeValidateUIMessagesconvertToModelMessagescreateUIMessageStreamtoUIMessageStreamcreateUIMessageStreamResponsegatewayExternal services
app/page.tsxapp/layout.tsxapp/api/query-embedding/route.tsapp/api/chat/route.tscomponents/local-rag-chat.tsxcomponents/index-import.tsxcomponents/local-citations.tsxhooks/use-local-rag-chat.tslib/chat-contract.tslib/chunk-text.tslib/embedding-config.tslib/local-rag-index.tslib/rate-limit.tslib/request-utils.tslib/retrieval.tslib/sample-indexes.tsfixtures/acme-ops-handbook.jsonfixtures/cedar-product-faq.jsonfixtures/atlas-deploy-runbook.jsonfixtures/sources/pto-and-holidays.mdfixtures/sources/tools-and-access.mdfixtures/sources/expense-policy.mdfixtures/sources/cedar/sharing-and-permissions.mdfixtures/sources/cedar/plans-and-billing.mdfixtures/sources/cedar/export-formats.mdfixtures/sources/atlas/rollback-procedure.mdfixtures/sources/atlas/on-call-and-paging.mdfixtures/sources/atlas/feature-flags.mdREADME.mdnpm packages
7
Registry components
lib/local-rag-index.tsCopied V1 portable embedding-index contract. Must stay parity-tested against local-rag-ingest. Reject incompatible schema/version/model/dimensions/chunking before cosineSimilarity.
lib/retrieval.tsBrowser-side ranking with AI SDK Core cosineSimilarity, threshold/top-K/context budget selection, and citation helpers. Keep ranking in the browser; never upload the full index to rank on the server.
query-embedding/route.tsStateless Core embed boundary for one query string. Locked model openai/text-embedding-3-small with providerOptions.openai.dimensions=512. Never add @ai-sdk/openai solely for embeddings.
chat/route.tsCited answer boundary: validate retrieval body without embeddings, assign S1..S5 server-side, write non-transient data-retrieval, convert prior data parts to undefined, streamText via gateway deepseek/deepseek-v4.1-flash.
Load a sample Local RAG index, rank chunks in the browser, and stream a cited answer without a vector database.
Use this when you already have an exported embedding index of text chunks and want users to chat over it with cited, streamed answers.
Similar patterns, and when each one is the better fit.

Local RAG IngestUse this when a small docs or knowledge-base prototype needs its text turned into embeddings held in React state and saved as a portable index.
Local Image SearchUse this when you already have an exported image index and need to search it by meaning in the browser using caption embeddings.
Local Image IngestUse this when teaching or prototyping caption-then-embed for images and you want a downloadable index file as the result.
Jev AEO AuditUse this when auditing a page for AEO and you want title, canonical, and noindex checks in code while Jev judges the citation-worthiness.Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
Download → Next.js app
Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: AI_GATEWAY_API_KEY.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
Run the app and open the pattern route
Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.
AI_GATEWAY_API_KEYGet keyAI SDK APIs
embedcosineSimilaritystreamTextsafeValidateUIMessagesconvertToModelMessagescreateUIMessageStreamtoUIMessageStreamcreateUIMessageStreamResponsegatewayExternal services
app/page.tsxapp/layout.tsxapp/api/query-embedding/route.tsapp/api/chat/route.tscomponents/local-rag-chat.tsxcomponents/index-import.tsxcomponents/local-citations.tsxhooks/use-local-rag-chat.tslib/chat-contract.tslib/chunk-text.tslib/embedding-config.tslib/local-rag-index.tslib/rate-limit.tslib/request-utils.tslib/retrieval.tslib/sample-indexes.tsfixtures/acme-ops-handbook.jsonfixtures/cedar-product-faq.jsonfixtures/atlas-deploy-runbook.jsonfixtures/sources/pto-and-holidays.mdfixtures/sources/tools-and-access.mdfixtures/sources/expense-policy.mdfixtures/sources/cedar/sharing-and-permissions.mdfixtures/sources/cedar/plans-and-billing.mdfixtures/sources/cedar/export-formats.mdfixtures/sources/atlas/rollback-procedure.mdfixtures/sources/atlas/on-call-and-paging.mdfixtures/sources/atlas/feature-flags.mdREADME.mdnpm packages
7
Registry components
lib/local-rag-index.tsCopied V1 portable embedding-index contract. Must stay parity-tested against local-rag-ingest. Reject incompatible schema/version/model/dimensions/chunking before cosineSimilarity.
lib/retrieval.tsBrowser-side ranking with AI SDK Core cosineSimilarity, threshold/top-K/context budget selection, and citation helpers. Keep ranking in the browser; never upload the full index to rank on the server.
query-embedding/route.tsStateless Core embed boundary for one query string. Locked model openai/text-embedding-3-small with providerOptions.openai.dimensions=512. Never add @ai-sdk/openai solely for embeddings.
chat/route.tsCited answer boundary: validate retrieval body without embeddings, assign S1..S5 server-side, write non-transient data-retrieval, convert prior data parts to undefined, streamText via gateway deepseek/deepseek-v4.1-flash.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
Load a sample Local RAG index, rank chunks in the browser, and stream a cited answer without a vector database.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
Load a sample Local RAG index, rank chunks in the browser, and stream a cited answer without a vector database.