Skip to main content

Overview

Chunkr outputs processed documents in a structured JSON format containing chunks, segments, and metadata. Each segment can be formatted as HTML, Markdown, or plain text based on your configuration.

Output Structure

The output response follows this structure:

Output Response Fields

array
Array of chunks, where segments are grouped according to chunk_processing.target_length.
string
Original filename of the processed document.
integer
Total number of pages in the document.
string
Presigned URL to download the processed PDF file.

Chunk Structure

Each chunk contains:
string
Unique identifier for the chunk (UUID).
integer
Total number of tokens in the chunk, calculated using the configured tokenizer.
array
Array of segments contained in this chunk. Segments are never split - they always remain intact.
string
Suggested text for embedding this chunk. Generated by combining content from all segments according to the configured embed_sources.

Example Chunk

Segment Structure

Each segment contains detailed information about a detected document element:
string
Unique identifier for the segment (UUID).
enum
Type of segment: Title, SectionHeader, Text, ListItem, Table, Picture, Caption, Formula, Footnote, PageHeader, PageFooter, or Page.
string
Primary formatted content based on the format setting (HTML or Markdown).
string
Raw OCR text content without formatting.
string
HTML formatted content (deprecated - use content with format: "Html").
string
Markdown formatted content (deprecated - use content with format: "Markdown").
string
LLM-generated content if using strategy: "LLM" or custom prompts.
string
Presigned URL to the cropped image if crop_image is enabled.
object
Bounding box coordinates: {left, top, width, height}.
integer
Page number where the segment appears (1-indexed).
float
Width of the page containing this segment.
float
Height of the page containing this segment.
float
Confidence score from the layout analysis model (0-1).
array
Array of OCR results with word-level bounding boxes and confidence scores.

Example Segment

Content Format Options

HTML Format

When configured with format: "Html":
Output:
  • content field contains HTML
  • Preserves structure with proper tags
  • Best for tables and complex layouts
  • Can be rendered directly in browsers
Example:

Markdown Format

When configured with format: "Markdown":
Output:
  • content field contains Markdown
  • Human-readable
  • Easy to convert to other formats
  • Ideal for text-heavy content
Example:

Plain Text

The text field always contains plain text extracted via OCR:

Accessing Output

Getting Task Results

Query Parameters:
  • include_chunks=true - Include full chunk data (default: true)
  • base64_urls=false - Use presigned URLs vs base64 (default: false)

Downloading Files

All file URLs are presigned and expire after a certain time:

Export Formats

JSON Export

The default output format:

Markdown Export

Combine all Markdown segments:

HTML Export

Combine all HTML segments:

Embedding-Ready Export

Extract just the embed fields for vector database ingestion:

Best Practices

  1. Choose the right format for your use case
    • HTML for tables, structured content, and web rendering
    • Markdown for documentation, text processing, and readability
    • Plain text for search indexing and simple analysis
  2. Use embed fields for RAG
    • Pre-configured based on embed_sources
    • Optimized for vector embeddings
    • Includes only relevant content
  3. Handle presigned URLs properly
    • URLs expire after a set time
    • Download and cache files you need to keep
    • Don’t store presigned URLs long-term
  4. Process chunks efficiently
    • Iterate through chunks for large documents
    • Use chunk metadata for filtering
    • Chunk IDs are stable across requests
  5. Leverage segment metadata
    • Use segment_type for filtering
    • Check confidence for quality control
    • Use bbox for spatial analysis

Complete Output Example