Chunk local text, create embeddings, and export a portable RAG index without a vector database.
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
embedManyExternal services
app/page.tsxapp/layout.tsxapp/api/embed/route.tscomponents/local-rag-ingest.tsxcomponents/source-input.tsxcomponents/index-summary.tsxhooks/use-local-rag-ingest.tslib/chunk-text.tslib/embedding-config.tslib/ingest-state.tslib/local-rag-index.tslib/rate-limit.tslib/request-utils.tsREADME.mdnpm packages
6
Registry components
lib/local-rag-index.tsV1 portable embedding-index contract (schema, Zod validation, invariants, export constructor). Future Local RAG Chat must reuse this module as the compatibility seam—reject incompatible schema/version/model/dimensions/chunking before cosineSimilarity.
lib/chunk-text.tsBrowser-side UTF-8 decode, unicode-nfc-lf normalization, SHA-256 hashing, and paragraph-window-v1 deterministic chunking. Keep pure and unit-tested; do not move chunking to the server.
embed/route.tsStateless embedMany boundary via AI SDK Core from 'ai' with Gateway model string openai/text-embedding-3-small, providerOptions.openai.dimensions=512, abort/timeout, disabled telemetry, and no document/vector persistence. Never add @ai-sdk/openai solely for embeddings.
Chunk local text, create embeddings, and export a portable RAG index without a vector database.
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
embedManyExternal services
app/page.tsxapp/layout.tsxapp/api/embed/route.tscomponents/local-rag-ingest.tsxcomponents/source-input.tsxcomponents/index-summary.tsxhooks/use-local-rag-ingest.tslib/chunk-text.tslib/embedding-config.tslib/ingest-state.tslib/local-rag-index.tslib/rate-limit.tslib/request-utils.tsREADME.mdnpm packages
6
Registry components
lib/local-rag-index.tsV1 portable embedding-index contract (schema, Zod validation, invariants, export constructor). Future Local RAG Chat must reuse this module as the compatibility seam—reject incompatible schema/version/model/dimensions/chunking before cosineSimilarity.
lib/chunk-text.tsBrowser-side UTF-8 decode, unicode-nfc-lf normalization, SHA-256 hashing, and paragraph-window-v1 deterministic chunking. Keep pure and unit-tested; do not move chunking to the server.
embed/route.tsStateless embedMany boundary via AI SDK Core from 'ai' with Gateway model string openai/text-embedding-3-small, providerOptions.openai.dimensions=512, abort/timeout, disabled telemetry, and no document/vector persistence. Never add @ai-sdk/openai solely for embeddings.
Loading preview…
Early-bird pricing — limited time

Open on desktop for the interactive preview.
Chunk local text, create embeddings, and export a portable RAG index without a vector database.
Loading preview…
Early-bird pricing — limited time

Open on desktop for the interactive preview.
Chunk local text, create embeddings, and export a portable RAG index without a vector database.