---
title: "Parse"
description: "Parse full documents into LLM-ready content using the Python SDK"
---

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

# Parse

The `parse.run()` method turns full documents into LLM-ready content: text, tables, figures, layout, and formatting. Set `settings.model` to `"r-1"` on every request (requires `reductoai>=0.23.0`). Parse returns content organized into chunks for LLM and RAG workflows.

---

## Basic Usage

```python
from pathlib import Path
from reducto import Reducto

client = Reducto()

# Upload and parse
upload = client.upload(file=Path("invoice.pdf"))
result = client.parse.run(input=upload.file_id, settings={"model": "r-1"})

# Access the results
for chunk in result.result.chunks:
    print(chunk.content)
    for block in chunk.blocks:
        print(f"  {block.type} on page {block.bbox.page}")
```

---

## Method Signature

```python
def parse.run(
    input: str | list[str],
    enhance: dict | None = None,
    formatting: dict | None = None,
    retrieval: dict | None = None,
    settings: dict | None = None,
    spreadsheet: dict | None = None,
    settings={"model": "r-1"},
) -> ParseResponse
```

### Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `input` | `str \| list[str]` | Yes | File ID (`reducto://...`), URL, or `jobid://` reference |
| `enhance` | `dict \| None` | No | Customized agentic processing and legacy enhancement options |
| `formatting` | `dict \| None` | No | Output formatting (table formats, metadata) |
| `retrieval` | `dict \| None` | No | Chunking and filtering options |
| `settings` | `dict \| None` | No | Processing settings such as page range, returned assets, and timeouts. Legacy OCR controls are ignored by r-1. |
| `spreadsheet` | `dict \| None` | No | Spreadsheet-specific options |

---

## Input Options

The `input` parameter accepts several formats:

```python
# From upload
result = client.parse.run(input=upload.file_id, settings={"model": "r-1"})

# Public URL
result = client.parse.run(input="https://example.com/doc.pdf", settings={"model": "r-1"})

# Presigned S3 URL
result = client.parse.run(input="https://bucket.s3.amazonaws.com/doc.pdf?X-Amz-...", settings={"model": "r-1"})

# Reprocess previous job
result = client.parse.run(input="jobid://7600c8c5-a52f-49d2-8a7d-d75d1b51e141", settings={"model": "r-1"})
```

---

## Configuration Examples

### Select the Parse Model

Set `settings.model` to `"r-1"`, or `"r-1-mini"` for [r-1 mini](/parse/r-1#r-1-mini). Until December 7, 2026, a request that omits `settings.model` runs legacy Parse. Legacy-only settings are listed on [Legacy Parse settings](/configs/parse/legacy).

```python
result = client.parse.run(
    input=upload.file_id,
    settings={
        "model": "r-1"  # Options: "r-1", "r-1-mini", "legacy"
    }
)
```

### Chunking

By default, Parse returns the entire document as one chunk. For RAG applications, use variable chunking:

```python
result = client.parse.run(
    input=upload.file_id,
    retrieval={
        "chunking": {
            "chunk_mode": "variable"  # Options: "disabled", "variable", "page", "section"
        }
    },
    settings={"model": "r-1"},
)
```

### Table Output Format

Control how tables appear in the output:

```python
result = client.parse.run(
    input=upload.file_id,
    formatting={
        "table_output_format": "html"  # Options: "dynamic", "html", "md", "json", "csv"
    },
    settings={"model": "r-1"},
)
```

### Augment r-1 with Customized Agentic Processing

Legacy Parse supports promptless agentic scopes as general-purpose accuracy enhancements. r-1 handles those improvements natively. With r-1, add agentic processing when you need a custom prompt for a specific scope. Agentic processing adds latency.

```python
result = client.parse.run(
    input=upload.file_id,
    enhance={
        "agentic": [
            {
                "scope": "table",
                "prompt": "Preserve domain-specific notation such as <0.01, ±, and N/A exactly as written."
            }
        ]
    },
    settings={"model": "r-1"},
)
```

For structured chart data, use [advanced chart extraction](/configs/parse/chart-extraction).

### Figure Descriptions

r-1 writes a short description of every figure by default. No setting is needed.

### Filter Blocks

Remove specific content types from output:

```python
result = client.parse.run(
    input=upload.file_id,
    retrieval={
        "filter_blocks": ["Header", "Footer", "Page Number"]
    },
    settings={"model": "r-1"},
)
```

### Return Images

Get image URLs for figures and tables:

```python
result = client.parse.run(
    input=upload.file_id,
    settings={"model": "r-1",
        "return_images": ["figure", "table"]
    }
)

# Access images from blocks
for chunk in result.result.chunks:
    for block in chunk.blocks:
        if hasattr(block, 'image_url') and block.image_url:
            print(f"{block.type}: {block.image_url}")
```

---

## Response Structure

The `ParseResponse` object contains:

```python
result: ParseResponse = client.parse.run(input=upload.file_id, settings={"model": "r-1"})

# Top-level fields
print(result.job_id)          # str: Unique job identifier
print(result.duration)        # float: Processing time in seconds
print(result.studio_link)     # str: Link to view in Studio

# Usage information
print(result.usage.num_pages)  # int: Pages processed
print(result.usage.credits)    # float: Credits consumed

# Result content
if result.result.type == "full":
    chunks = result.result.chunks
    for chunk in chunks:
        print(chunk.content)    # str: Full text content
        print(chunk.embed)      # str: Embedding-optimized content
        print(chunk.blocks)    # list[Block]: Individual elements
```

### Chunks

Each chunk contains:

- `content` (str): Full text content formatted as Markdown
- `embed` (str): Content optimized for embeddings
- `blocks` (list[Block]): Individual elements with positions

### Blocks

Each block contains:

- `type` (str): Element type (`Title`, `Header`, `Text`, `Table`, `Figure`, etc.)
- `content` (str): The block's content
- `bbox` (BoundingBox): Position on the page (normalized 0-1 coordinates)
- `confidence` (str): Confidence level (`"high"` or `"low"`)

---

## URL Results

For large documents, the response may return a URL instead of inline content:

```python
result = client.parse.run(input=upload.file_id, settings={"model": "r-1"})

if result.result.type == "url":
    # Fetch the content from the URL
    import requests
    chunks = requests.get(result.result.url).json()
else:
    # Content is inline
    chunks = result.result.chunks
```

To always get a URL (for consistent handling):

```python
result = client.parse.run(
    input=upload.file_id,
    settings={"model": "r-1",
        "force_url_result": True
    }
)
```

---

## Advanced Features

### Raw Response Access

Access raw HTTP response data:

```python
response = client.parse.with_raw_response.run(input=upload.file_id)
print(response.headers.get('X-My-Header'))
parse_result = response.parse()  # Get the parsed object
```

### Streaming Response

Stream large responses:

```python
with client.parse.with_streaming_response.run(input=upload.file_id) as response:
    for line in response.iter_lines():
        print(line)
```

### Per-Request Options

Override client settings for this request:

```python
# Custom timeout
client.with_options(timeout=30.0).parse.run(input=upload.file_id, settings={"model": "r-1"})

# Custom retry settings
client.with_options(max_retries=5).parse.run(input=upload.file_id, settings={"model": "r-1"})
```

---

## Error Handling

```python
from reducto import Reducto
import reducto

try:
    result = client.parse.run(input=upload.file_id, settings={"model": "r-1"})
except reducto.APIConnectionError as e:
    print(f"Connection failed: {e}")
    print(e.__cause__)  # underlying exception
except reducto.RateLimitError as e:
    print(f"Rate limited: {e}")
except reducto.APIStatusError as e:
    print(f"API error: {e.status_code} - {e.response}")
except reducto.APITimeoutError as e:
    print(f"Request timed out: {e}")
```

---

## Complete Example

```python
from pathlib import Path
from reducto import Reducto

client = Reducto()

# Upload
upload = client.upload(file=Path("fidelity-example.pdf"))

# Parse with r-1 and additional configuration
result = client.parse.run(
    input=upload.file_id,
    formatting={
        "table_output_format": "html"
    },
    retrieval={
        "chunking": {"chunk_mode": "variable"}
    },
    settings={"model": "r-1",
        "page_range": {"start": 1, "end": 5}
    }
)

# Process results
print(f"Processed {result.usage.num_pages} pages")
print(f"Used {result.usage.credits} credits")
print(f"View in Studio: {result.studio_link}")

for i, chunk in enumerate(result.result.chunks):
    print(f"\n=== Chunk {i + 1} ===")
    print(chunk.content[:500])  # First 500 chars
    
    # Count block types
    block_types = {}
    for block in chunk.blocks:
        block_types[block.type] = block_types.get(block.type, 0) + 1
    
    print(f"Block types: {block_types}")
```

---

## Best Practices

- **Use Variable Chunking for RAG**: Enable `chunk_mode: "variable"` for RAG pipelines to get semantically meaningful chunks.

- **Customize Agentic Processing**: Add a scoped custom prompt when your workflow needs use-case-specific parsing instructions. r-1 handles scanned documents natively.

- **Filter Headers/Footers**: Use `filter_blocks` to remove headers and footers that pollute search results.

- **Handle URL Results**: Always check `result.type` and handle URL results for large documents.

---

## Next Steps

- Learn about [extracting specific fields](/sdk/python/extract) from parsed documents
- Learn how [Parse r-1](/parse/r-1) handles documents and customized agentic processing
- Explore [response format details](/parse/response-format) for complete structure
- Check out [best practices](/parse/best-practices) for optimization
- See the [async client](/sdk/python/async) for concurrent processing

Source: https://docs.reducto.ai/sdk/python/parse/index.mdx
