> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unstructured.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Contextual chunking node

> Add a Contextual Chunker node after your chunker to prepend LLM-generated context to each chunk, improving retrieval quality without changing chunk count or IDs.

*Type*: `chunk`

*Subtype*: `chunk_by_contextual`

## Usage guidance

Contextual chunking is a post-chunk enrichment step, not a chunking strategy. The `chunk_by_contextual` node does not split or combine elements. It takes the chunks an upstream chunker already produced and prepends a short, LLM-generated context summary to each chunk's text. Chunk count, chunk order, and element IDs are preserved.

Add `chunk_by_contextual` as a second chunker node, placed after a text chunker (such as `chunk_by_character`, `chunk_by_page`, `chunk_by_similarity`, or `chunk_by_title`). The supported workflow chains two chunker nodes:

```text theme={null}
Partitioner → Chunker (chunk_by_title) → Chunker (chunk_by_contextual) → Destination
```

The node enriches the chunks it receives from the upstream chunker. It does not re-read the source file. Each chunk is sent a window of the surrounding document, sized by `context_char_limit`.

For very large documents, the node estimates total request time and, if this exceeds the internal limit, returns the original elements unchanged. Per-element failures fall back to the original text rather than canceling document processing.

For more information, see [Contextual chunking](/concepts/chunking#contextual-chunking).

## Settings

<ParamField body="contextual_chunking_model" type="string" required>
  The model to use, in `provider/model` format (for example, `anthropic/claude-sonnet-4-6`). Supported providers: `anthropic`, `openai`, `custom_openai_compatible`, `vertexai`, `bedrock`. For available models, see [Available models](/api-reference/workflow/models).
</ParamField>

<ParamField body="context_char_limit" type="integer">
  Size of the document window, in characters, given to the LLM for each chunk. A larger window gives each chunk broader document context at higher token cost. Default: `15000`.
</ParamField>

<ParamField body="user_prompt" type="string">
  Custom instruction to override the default per-chunk prompt. Default: none.
</ParamField>

<RequestExample>
  ```python Python SDK theme={null}
  # Chain a Contextual Chunker node after your chunker.
  chunk_by_title_chunker_workflow_node = WorkflowNode(
      name="Chunker",
      subtype="chunk_by_title",
      type="chunk",
      settings={
          "max_characters": 2000,
          "new_after_n_chars": 1500,
          "overlap": 100
      }
  )

  chunk_by_contextual_chunker_workflow_node = WorkflowNode(
      name="Contextual Chunker",
      subtype="chunk_by_contextual",
      type="chunk",
      settings={
          "contextual_chunking_model": "<provider>/<model>",
          "context_char_limit": <context-char-limit>,
          "user_prompt": "<user-prompt>"
      }
  )
  ```

  ```json cURL theme={null}
  [
      {
          "name": "Chunker",
          "type": "chunk",
          "subtype": "chunk_by_title",
          "settings": {
              "max_characters": 2000,
              "new_after_n_chars": 1500,
              "overlap": 100
          }
      },
      {
          "name": "Contextual Chunker",
          "type": "chunk",
          "subtype": "chunk_by_contextual",
          "settings": {
              "contextual_chunking_model": "<provider>/<model>",
              "context_char_limit": <context-char-limit>,
              "user_prompt": "<user-prompt>"
          }
      }
  ]
  ```
</RequestExample>
