Contextualize Chunks
Contextualize Chunks asks an LLM to write a short sentence saying where each chunk sits in its document, and prepends it to the chunk before embedding. A chunk retrieved on its own often does not say whose rate, which year, or which product it is talking about; writing that context onto the chunk measurably improves retrieval. You find it on the node picker’s AI shelf.
It is an optional step: place it between Split Text and Embed. It reads the chunk list and emits the same shape, so adding it changes nothing downstream.
Ingest: Read a File as Text → Split Text → Contextualize Chunks (optional) → Embed → Knowledge Base InsertRead back: Knowledge Base Query (search) or Read Knowledge Base (read whole)The node has one input handle and one output handle. It calls a chat model, so it needs a provider credential: pick a secret or a connection, or leave the field empty to use the workspace key for the provider.
Set the reuse knowledge base, always
Section titled “Set the reuse knowledge base, always”An LLM writes slightly different words every run. Without reuseFromCollectionId, every scheduled ingest regenerates every context, which changes every chunk’s content hash, which in turn defeats the Embed node’s reuse and makes Knowledge Base Insert rewrite the whole knowledge base. Nothing errors; the bill explains it later. Point the field at the knowledge base the chunks are headed for, and an unchanged chunk of an unchanged document reuses its stored context without calling a model at all. Changing the document, the model, or the prompt template deliberately breaks reuse, because each one makes every stored context stale.
Configuration
Section titled “Configuration”

| Field | Type | Default | Description |
|---|---|---|---|
Provider (provider) | one of openai, anthropic, gemini, ollama, mistral, groq, xai, voyageai, openrouter, typesafe, eleven, openai-compatible, soniox ✦ (required) |
— | The AI provider that writes the situating context. A cheap, fast model is the right choice here. |
Model (model) | string ✦ (required) | — | The model that writes the context, e.g. claude-haiku-5-5. |
Credential (credential) | string ✦ (optional) | — | The key this node pays with, picked from your secrets. Leave it empty to use the workspace key for this provider, set on the AI models page. |
Document (document) | string ✦ (optional) | — | The whole document the chunks came from. Leave empty and it is rebuilt by joining the chunks back together. |
Prompt template (promptTemplate) | string ✦ (optional) | — | The instruction sent with each chunk. Use %DOCUMENT% for the whole document and %CHUNK% for the chunk. Leave empty for the default, which asks for 50–100 tokens situating the chunk. |
Reuse from knowledge base (reuseFromCollectionId) | string ✦ (optional) | — | The knowledge base these chunks are headed for. Set it, and a chunk whose source text has not changed reuses the context already stored there instead of paying a model to write it again — this is what makes the node affordable to run on a schedule. |
Fields marked ✦ accept expressions.
Try this node — run it once against your own workspace, with your credentials, without building a flow first.
Output
Section titled “Output”{ "chunks": [ { "text": "This figure is from ACME's Q2 2026 report...\n\nThe rate rose to 4.2%...", "index": 0, "metadata": { "raw_content_hash": "9f2c..." } } ], "contextualized": 1, "reused": 0, "document_chars": 5230, "document_truncated": false, "prompt_cached": true}contextualized and reused report how many chunks were written fresh against how many came from the reuse knowledge base. prompt_cached reports whether the document prefix was actually cached; prompt caching is implemented for Anthropic only, and on any other provider the whole document is re-read at full price once per chunk, roughly an order of magnitude more expensive.
Example
Section titled “Example”The template Rag / Contextualize under Automation → Templates runs two ambiguous chunks (“The rate rose to 4.2% in the second quarter”) through this node with claude-haiku-5-5 on Anthropic and a reuse knowledge base set, then embeds them and inserts them under the source key quarterly-report. A cheap, fast model is the right choice here.
By default the document each chunk is situated in is rebuilt by joining the chunks back together. When the chunks are only part of a document, point the document field at the reader instead. Its output is a list, so address the document you want by position:
{!! $workflow->node('Read a File as Text')->documents[0]->text !!}Limitations
Section titled “Limitations”- The prompt template uses
%DOCUMENT%and%CHUNK%placeholders, not expression braces. - The document is capped at a platform limit (200,000 characters by default); over-long documents are truncated for context writing and the output reports
document_truncated: true. - The stored chunk text includes its situating sentence. With
expandNeighborson Knowledge Base Query, an expanded window repeats one sentence per chunk, so keep the radius at 2 or less when this node is in the flow.
Related
Section titled “Related”- Split Text produces the chunks this node rewrites.
- Embed is the next step in the ingest pipeline.
- Knowledge bases explains the storage this pipeline fills.
- How to choose between searching and reading covers when a knowledge base is small enough to hand over whole, in which case improving its search buys nothing.