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

# Configuration

> Learn how to configure tasks in Chunkr AI

Chunkr AI allows you to configure tasks with a `Configuration` object. All configurations can be used together.

<CodeGroup>
  ```python Python theme={"system"}
  from chunkr_ai.models import ChunkProcessing, Configuration, OcrStrategy

  config = Configuration(
      chunk_processing=ChunkProcessing(target_length=1024),
      expires_in=3600,
      ocr_strategy=OcrStrategy.AUTO,
  )

  task = chunkr.upload("path/to/your/file", config)
  ```
</CodeGroup>

## Available Configuration Examples

### Chunk Processing

<CodeGroup>
  ```python Python theme={"system"}
  from chunkr_ai.models import ChunkProcessing
  config = Configuration(
      chunk_processing=ChunkProcessing(
      target_length=1024
  )
  )
  ```
</CodeGroup>

### Expires In

<CodeGroup>
  ```python Python theme={"system"}
  config = Configuration(expires_in=3600)
  ```
</CodeGroup>

### OCR Strategy

<CodeGroup>
  ```python Python theme={"system"}
  config = Configuration(ocr_strategy=OcrStrategy.AUTO) # or OcrStrategy.ALL
  ```
</CodeGroup>

### Segment Processing

This example show cases all the options for segment processing. This is what the default configuration looks like, and is applied if nothing is specified.
For your own configuration, you can customize the options you want to change and the rest will be applied by default.

<CodeGroup>
  ```python Python theme={"system"}
  from chunkr_ai.models import (
      Configuration, 
      CroppingStrategy, 
      GenerationConfig, 
      GenerationStrategy, 
      SegmentProcessing,
      SegmentFormat
    )
    
    config = Configuration(
        segment_processing=SegmentProcessing(
            Caption=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.AUTO,
                description=False
            ),
            Formula=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.LLM,
                description=False
            ),
            Footnote=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.AUTO,
                description=False
            ),
            ListItem=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.AUTO,
                description=False
            ),
            Page=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.AUTO,
                description=False
            ),
            PageFooter=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.IGNORE,
                description=False
            ),
            PageHeader=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.IGNORE,
                description=False
            ),
            Picture=GenerationConfig(
                crop_image=CroppingStrategy.ALL, 
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.AUTO,
                description=False
            ),
            SectionHeader=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.AUTO,
                description=False
            ),
            Table=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.HTML,
                strategy=GenerationStrategy.LLM,
                description=True
            ),
            Text=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.AUTO,
                description=False
            ),
            Title=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.MARKDOWN,
                strategy=GenerationStrategy.AUTO,
                description=False
            )
        )
    )
  ```
</CodeGroup>

You can customize any segment's generation strategy and enable descriptions:

<CodeGroup>
  ```python Python theme={"system"}
  # Example with descriptions enabled for tables
    config = Configuration(
        segment_processing=SegmentProcessing(
            Table=GenerationConfig(
                crop_image=CroppingStrategy.AUTO,
                format=SegmentFormat.HTML,
                strategy=GenerationStrategy.LLM,
                description=True
            )
        )
    )
  ```
</CodeGroup>

### Segmentation Strategy

<CodeGroup>
  ```python Python theme={"system"}
  config = Configuration(
      segmentation_strategy=SegmentationStrategy.LAYOUT_ANALYSIS # or SegmentationStrategy.PAGE
  )
  ```
</CodeGroup>
