Skip to content

Configuration Guide

For complete field documentation, see Configuration Reference.

All extraction behavior is controlled through ExtractionConfig. Every field is optional with sensible defaults — configure only what you need. You can pass config objects directly in code, or load them from TOML/YAML/JSON files.

Python
import asyncio
from kreuzberg import extract_file, ExtractionConfig
async def main() -> None:
config = ExtractionConfig(
use_cache=True,
enable_quality_processing=True
)
result = await extract_file("document.pdf", config=config)
print(result.content)
asyncio.run(main())

Kreuzberg supports three file formats. TOML is recommended for readability.

kreuzberg.toml
use_cache = true
enable_quality_processing = true
[ocr]
backend = "tesseract"
language = "eng"
[ocr.tesseract_config]
psm = 3

Kreuzberg searches for configuration files in this order:

  1. Current directory./kreuzberg.{toml,yaml,yml,json}
  2. User config~/.config/kreuzberg/config.{toml,yaml,yml,json}
  3. System config/etc/kreuzberg/config.{toml,yaml,yml,json}

The first file found is merged with defaults. If no file exists, defaults are used.

Python
import asyncio
from kreuzberg import ExtractionConfig, extract_file
async def main() -> None:
config: ExtractionConfig = ExtractionConfig()
result = await extract_file("document.pdf", config=config)
content: str = result.content
content_preview: str = content[:100]
print(f"Content preview: {content_preview}")
print(f"Total length: {len(content)}")
asyncio.run(main())

Enable OCR for scanned documents and images:

Python
import asyncio
from kreuzberg import ExtractionConfig, OcrConfig, TesseractConfig, extract_file
async def main() -> None:
config: ExtractionConfig = ExtractionConfig(
ocr=OcrConfig(
backend="tesseract", language="eng+fra",
tesseract_config=TesseractConfig(psm=3)
)
)
result = await extract_file("document.pdf", config=config)
print(result.content)
asyncio.run(main())

For backend selection and language packs, see OCR Guide. For fine-grained Tesseract tuning, see TesseractConfig Reference.

Split extracted text into overlapping chunks for vector database ingestion:

Python
from kreuzberg import (
ExtractionConfig,
ChunkingConfig,
EmbeddingConfig,
EmbeddingModelType,
)
config: ExtractionConfig = ExtractionConfig(
chunking=ChunkingConfig(
max_chars=1500,
max_overlap=200,
embedding=EmbeddingConfig(
model=EmbeddingModelType.preset("all-minilm-l6-v2")
),
)
)

Kreuzberg’s configuration covers extraction behavior, OCR, formatting, chunking, and hardware acceleration:

See Configuration Reference for the complete field documentation.