> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/lumina-ai-inc/chunkr/llms.txt
> Use this file to discover all available pages before exploring further.

# Segments

> Segment types and processing configuration options

## Segment Types

Chunkr identifies the following segment types during layout analysis:

<ResponseField name="Title" type="SegmentType">
  Main title or heading of the document.
</ResponseField>

<ResponseField name="SectionHeader" type="SegmentType">
  Section headers and subheadings within the document.
</ResponseField>

<ResponseField name="Text" type="SegmentType">
  Regular paragraph text.
</ResponseField>

<ResponseField name="ListItem" type="SegmentType">
  Individual items in bulleted or numbered lists.
</ResponseField>

<ResponseField name="Table" type="SegmentType">
  Tabular data.
</ResponseField>

<ResponseField name="Picture" type="SegmentType">
  Images, diagrams, and figures.
</ResponseField>

<ResponseField name="Caption" type="SegmentType">
  Captions for images, tables, or other elements.
</ResponseField>

<ResponseField name="Formula" type="SegmentType">
  Mathematical formulas and equations.
</ResponseField>

<ResponseField name="Footnote" type="SegmentType">
  Footnotes and endnotes.
</ResponseField>

<ResponseField name="PageHeader" type="SegmentType">
  Headers that appear at the top of pages.
</ResponseField>

<ResponseField name="PageFooter" type="SegmentType">
  Footers that appear at the bottom of pages.
</ResponseField>

<ResponseField name="Page" type="SegmentType">
  An entire page treated as a single segment (when using `Page` segmentation strategy).
</ResponseField>

## Segment Processing

The `SegmentProcessing` configuration allows you to control how each segment type is processed and which content representations are generated.

### Configuration Structure

Each segment type can have its own processing configuration:

```json theme={null}
{
  "segment_processing": {
    "Title": { /* AutoGenerationConfig */ },
    "SectionHeader": { /* AutoGenerationConfig */ },
    "Text": { /* AutoGenerationConfig */ },
    "ListItem": { /* AutoGenerationConfig */ },
    "Table": { /* TableGenerationConfig */ },
    "Picture": { /* PictureGenerationConfig */ },
    "Caption": { /* AutoGenerationConfig */ },
    "Formula": { /* LlmGenerationConfig */ },
    "Footnote": { /* AutoGenerationConfig */ },
    "PageHeader": { /* AutoGenerationConfig */ },
    "PageFooter": { /* AutoGenerationConfig */ },
    "Page": { /* LlmGenerationConfig */ }
  }
}
```

### AutoGenerationConfig

Used for most segment types (Title, SectionHeader, Text, ListItem, Caption, Footnote, PageHeader, PageFooter).

<ResponseField name="format" type="SegmentFormat" default="Markdown">
  Specifies the output format.

  <Expandable title="SegmentFormat options">
    * `Html` - Generate HTML output
    * `Markdown` - Generate Markdown output
  </Expandable>
</ResponseField>

<ResponseField name="strategy" type="GenerationStrategy" default="Auto">
  Determines how the content is generated.

  <Expandable title="GenerationStrategy options">
    * `Auto` - Use heuristics and rule-based generation
    * `LLM` - Use Chunkr's fine-tuned models for generation
  </Expandable>
</ResponseField>

<ResponseField name="crop_image" type="CroppingStrategy" default="Auto">
  Controls whether to crop the page image to the segment's bounding box.

  <Expandable title="CroppingStrategy options">
    * `All` - Always crop images for this segment type
    * `Auto` - Only crop when needed for post-processing
  </Expandable>
</ResponseField>

<ResponseField name="llm" type="string">
  Custom prompt for LLM-based processing of this segment. Only used when LLM processing is enabled for the segment.
</ResponseField>

<ResponseField name="embed_sources" type="EmbedSource[]" default="[Content]">
  Defines which content sources will be included in the chunk's embed field and counted towards the chunk length. The array's order determines the sequence in which content appears.

  <Expandable title="EmbedSource options">
    * `Content` - Use the primary content (HTML or Markdown based on format)
    * `LLM` - Use LLM-generated content
    * `HTML` - **DEPRECATED**: Use HTML representation
    * `Markdown` - **DEPRECATED**: Use Markdown representation
  </Expandable>
</ResponseField>

<ResponseField name="extended_context" type="boolean" default={false}>
  Use the full page image as context for LLM generation.
</ResponseField>

#### Deprecated Fields

<ResponseField name="html" type="GenerationStrategy" deprecated>
  **DEPRECATED**: Use `format: Html` and `strategy` instead.
</ResponseField>

<ResponseField name="markdown" type="GenerationStrategy" deprecated>
  **DEPRECATED**: Use `format: Markdown` and `strategy` instead.
</ResponseField>

### LlmGenerationConfig

Used for Formula and Page segment types. Has the same fields as AutoGenerationConfig but with `strategy` defaulting to `LLM`.

<ResponseField name="format" type="SegmentFormat" default="Markdown">
  Output format (Html or Markdown).
</ResponseField>

<ResponseField name="strategy" type="GenerationStrategy" default="LLM">
  Generation strategy (Auto or LLM).
</ResponseField>

<ResponseField name="crop_image" type="CroppingStrategy" default="Auto">
  Image cropping strategy.
</ResponseField>

<ResponseField name="llm" type="string">
  Custom LLM prompt.
</ResponseField>

<ResponseField name="embed_sources" type="EmbedSource[]" default="[Content]">
  Content sources for embedding.
</ResponseField>

<ResponseField name="extended_context" type="boolean" default={false}>
  Use full page image as context.
</ResponseField>

### TableGenerationConfig

Used specifically for Table segments. Has the same fields as AutoGenerationConfig but with different defaults.

<ResponseField name="format" type="SegmentFormat" default="Html">
  Output format (Html or Markdown). Tables default to HTML for better structure preservation.
</ResponseField>

<ResponseField name="strategy" type="GenerationStrategy" default="LLM">
  Generation strategy. Tables default to LLM for higher accuracy.
</ResponseField>

<ResponseField name="crop_image" type="CroppingStrategy" default="Auto">
  Image cropping strategy.
</ResponseField>

<ResponseField name="llm" type="string">
  Custom LLM prompt.
</ResponseField>

<ResponseField name="embed_sources" type="EmbedSource[]" default="[Content]">
  Content sources for embedding.
</ResponseField>

<ResponseField name="extended_context" type="boolean" default={false}>
  Use full page image as context.
</ResponseField>

### PictureGenerationConfig

Used specifically for Picture segments.

<ResponseField name="format" type="SegmentFormat" default="Markdown">
  Output format (Html or Markdown).
</ResponseField>

<ResponseField name="strategy" type="GenerationStrategy" default="Auto">
  Generation strategy.

  When set to `Auto`, generates image tags:

  * HTML format: `<img src="{url}" />`
  * Markdown format: `![Image]({url})`
</ResponseField>

<ResponseField name="crop_image" type="PictureCroppingStrategy" default="All">
  Controls image cropping for pictures.

  <Expandable title="PictureCroppingStrategy options">
    * `All` - Always crop picture images (default for pictures)
    * `Auto` - Only crop when needed for post-processing
  </Expandable>
</ResponseField>

<ResponseField name="llm" type="string">
  Custom LLM prompt for describing or processing the image.
</ResponseField>

<ResponseField name="embed_sources" type="EmbedSource[]" default="[Content]">
  Content sources for embedding.
</ResponseField>

<ResponseField name="extended_context" type="boolean" default={false}>
  Use full page image as context.
</ResponseField>

## Example Configuration

```json theme={null}
{
  "segment_processing": {
    "Text": {
      "format": "Markdown",
      "strategy": "Auto",
      "crop_image": "Auto",
      "embed_sources": ["Content"]
    },
    "Table": {
      "format": "Html",
      "strategy": "LLM",
      "crop_image": "All",
      "embed_sources": ["Content", "LLM"]
    },
    "Picture": {
      "format": "Markdown",
      "strategy": "Auto",
      "crop_image": "All",
      "embed_sources": ["Content"]
    },
    "Formula": {
      "format": "Markdown",
      "strategy": "LLM",
      "crop_image": "Auto",
      "embed_sources": ["LLM"],
      "llm": "Convert this formula to LaTeX notation"
    }
  }
}
```
