---
title: "Extract"
description: "Reducto Extract API pulls specific fields from documents as structured JSON. Reducto returns values matching your schema, handling OCR, layout detection, and more."
---

> 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.

# Extract

Extract pulls specific fields from documents as structured JSON. You define a schema describing the data you need, and Reducto returns values matching that schema, handling OCR, layout detection, and LLM-based field location under the hood.

Extract builds on [Parse](/parse/overview), which processes the document first, then uses AI to locate and return the specified fields accurately, even across complex layouts.

For a higher-level view of extraction use cases and how Extract fits into production document workflows, see the [Extract product overview](https://reducto.ai/extract?utm_source=docs&utm_medium=referral&utm_campaign=docs_product_bridge&utm_content=extract_overview_top).

---

## Parse vs Extract

Both endpoints process documents, but they answer different questions.

**Parse** answers: "What's in this document?" It returns all content as structured chunks with positions and types. Use Parse for RAG pipelines, document viewers, or when you need to feed full content to an LLM.

**Extract** answers: "What is the value of X?" It returns only the specific fields you request. Extract runs Parse internally, then uses AI to pull out values matching your schema.

The key insight is that **Extract can only return what Parse sees**. If a value doesn't appear in the Parse output (perhaps due to OCR issues or a table format problem), no amount of schema tweaking will extract it. 

> **Tip:** When debugging extraction issues, always verify the data exists in the Parse result first.

---

## Quick Start

Given [this investment statement](https://studio.reducto.ai/share/md726aw3w7mfs46659ttkqry0s7se3pd?processor=kh7c9e30evkfb5a4h80dq4xke17sfwck&fileId=js7e4hrtnh2tsyjqdbz114ceyn7sf1v1), we'll extract the portfolio value change, total income, and top holdings:

<img
  src="/images/finance-statement.png"
  alt="Finance Statement"
  title="Finance Statement"
  style={{ width:"84%" }}
/>

**Python**

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

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

result = client.extract.run(
    input=upload.file_id,
    instructions={
        "schema": {
            "type": "object",
            "properties": {
                "portfolio_increase": {
                    "type": "number",
                    "description": "Increase in total portfolio value"
                },
                "total_income_ytd": {
                    "type": "number",
                    "description": "Total income year-to-date"
                },
                "top_holdings": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "Names of top holdings"
                }
            }
        },
        "system_prompt": "Extract financial data from this investment statement."
    },
    parsing={"settings": {"model": "r-1"}},
)

print(result.result)
```

**Node.js**

```javascript
import Reducto from 'reductoai';
import fs from 'fs';

const client = new Reducto();
const upload = await client.upload({
  file: fs.createReadStream('fidelity-example.pdf'),
});

const result = await client.extract.run({
  input: upload.file_id,
  instructions: {
    schema: {
      type: 'object',
      properties: {
        portfolio_increase: {
          type: 'number',
          description: 'Increase in total portfolio value'
        },
        total_income_ytd: {
          type: 'number',
          description: 'Total income year-to-date'
        },
        top_holdings: {
          type: 'array',
          items: { type: 'string' },
          description: 'Names of top holdings'
        }
      }
    },
    system_prompt: 'Extract financial data from this investment statement.'
  },
  parsing: { settings: { model: 'r-1' } },
});

console.log(result.result);
```

**cURL**

```bash
# First upload the file
FILE_ID=$(curl -s -X POST https://platform.reducto.ai/upload \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -F "file=@fidelity-example.pdf" | jq -r '.file_id')

# Then extract with schema
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "'$FILE_ID'",
    "instructions": {
      "schema": {
        "type": "object",
        "properties": {
          "portfolio_increase": {
            "type": "number",
            "description": "Increase in total portfolio value"
          },
          "total_income_ytd": {
            "type": "number",
            "description": "Total income year-to-date"
          },
          "top_holdings": {
            "type": "array",
            "items": {"type": "string"},
            "description": "Names of top holdings"
          }
        }
      },
      "system_prompt": "Extract financial data from this investment statement."
    }
  }'
```

**What this does:**

1. **Upload** the PDF to get a `file_id`
2. **`Call /extract`** with the file reference and a JSON schema defining the three fields you want
3. **Get back** JSON with exactly those fields populated from the document

```json
{
  "result": [
    {
      "portfolio_increase": 21000.37,
      "total_income_ytd": 23278.62,
      "top_holdings": [
        "Johnson & Johnson (JNJ)",
        "Apple Inc (AAPL)",
        "NH Portfolio 2015 Delphi",
        "Corp Jr Sb Nt Slm Corp",
        "Spi Lkd Nt (OSM)"
      ]
    }
  ],
  "job_id": "9531166f-9725-4854-8096-459785a33972",
  "usage": {"num_fields": 7, "num_pages": 3, "credits": 10.0},
  "studio_link": "https://studio.reducto.ai/job/9531166f-..."
}
```

The `result` is an array containing objects matching your schema. When you enable citations, the response format changes to wrap each value with its source location.

- [Response Format Details](/extract/response-format): Full breakdown of result structure, citations, and usage fields.

---

## Request Parameters

```python
result = client.extract.run(
    input="...",                    # Required: file_id, jobid://, or URL
    instructions={
        "schema": {...},            # JSON schema defining fields to extract
        "system_prompt": "..."      # Context for the LLM about the document
    },
    settings={
        "array_extract": False,     # Segment document for long arrays
        "citations": {
            "enabled": False,       # Return source locations
            "numerical_confidence": True
        },
        "include_images": False,
        "optimize_for_latency": False
    },
    parsing={...}                   # Parse options (ignored if using jobid://)
)
```

### input (required)

The document to process. Accepts several formats:

| Format          | Example                                  | When to use                        |
| --------------- | ---------------------------------------- | ---------------------------------- |
| Upload response | `reducto://abc123`                       | Local files uploaded via `/upload` |
| Public URL      | `https://example.com/doc.pdf`            | Publicly accessible documents      |
| Presigned URL   | `https://bucket.s3.../doc.pdf?X-Amz-...` | Files in your cloud storage        |
| Job ID          | `jobid://7600c8c5-...`                   | Reuse a previous Parse result      |
| Job ID list     | `["jobid://...", "jobid://..."]`         | Combine multiple parsed documents  |

Using `jobid://` skips the parsing step entirely, which is useful when you want to try different extraction schemas on the same document without re-parsing, or when combining data from multiple documents into a single extraction.

**Python**

```python
# Combine multiple parsed documents
result = client.extract.run(
    input=["jobid://job-1", "jobid://job-2", "jobid://job-3"],
    instructions={"schema": schema}
)
```

**Node.js**

```javascript
// Combine multiple parsed documents
const result = await client.extract.run({
  input: ['jobid://job-1', 'jobid://job-2', 'jobid://job-3'],
  instructions: { schema }
});
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": ["jobid://job-1", "jobid://job-2", "jobid://job-3"],
    "instructions": {"schema": {...}}
  }'
```

### instructions

| Field           | Purpose                                                                                                                                                                                                                                                                                                                     |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `schema`        | JSON schema defining target fields and types. Field names and descriptions directly influence extraction quality because the LLM uses them to locate values. A field called `invoice_total` with description `"The total amount due, typically at the bottom of the invoice"` performs better than a generic `total` field. |
| `system_prompt` | Document-level context. Describe what kind of document this is or highlight edge cases. Field-specific instructions belong in schema descriptions, not here.                                                                                                                                                                |

### settings

| Field                            | Default | Purpose                                                                                                                                                                                          |
| -------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `array_extract`                  | `false` | Deprecated. Use `deep_extract` instead (higher cost and latency). Previously used for documents with repeating data (line items, transactions): segments the document, extracts from each segment, and merges results. |
| `deep_extract`                   | `false` | Agentic extraction mode that iteratively refines its output to achieve near-perfect accuracy. Best for complex documents where accuracy is critical. See [Deep Extract](/configs/extract/deep-extract). |
| `citations.enabled`              | `false` | Return page number, bounding box, and source text for each extracted value. Useful for verification and debugging.                                                                               |
| `citations.numerical_confidence` | `true`  | When citations are enabled, include a 0-1 confidence score instead of just "high"/"low".                                                                                                         |
| `include_images`                 | `false` | Include page images in the extraction context. Can help with visually complex documents but increases cost.                                                                                      |
| `optimize_for_latency`           | `false` | Prioritize speed at 2x credit cost. Jobs get higher priority in the processing queue.                                                                                                            |

> **Warning:** Citations cannot be used with chunking. If you enable `settings.citations.enabled`, the parsing step automatically disables chunking. This is because citations require knowing exactly where each piece of content came from, which chunking obscures.

### parsing

Since Extract runs Parse internally, you can configure how parsing works. These options are ignored if your `input` is a `jobid://` reference.

Common options:

**Python**

```python
result = client.extract.run(
    input=upload.file_id,
    instructions={"schema": schema},
    parsing={
        "formatting": {
            "table_output_format": "html"     # Better for complex tables
        },
        "settings": {"model": "r-1",
            "page_range": {"start": 1, "end": 10},  # Process specific pages
            "document_password": "secret"            # For encrypted PDFs
        }
    }
)
```

**Node.js**

```javascript
const result = await client.extract.run({
  input: upload.file_id,
  instructions: { schema },
  parsing: {
    formatting: {
      table_output_format: 'html'     // Better for complex tables
    },
    settings: { model: 'r-1',
      page_range: { start: 1, end: 10 },  // Process specific pages
      document_password: 'secret'          // For encrypted PDFs
    }
  }
});
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "reducto://your-file-id",
    "instructions": {"schema": {...}},
    "parsing": {
      "formatting": {
        "table_output_format": "html"
      },
      "settings": {
        "model": "r-1",
        "page_range": {"start": 1, "end": 10},
        "document_password": "secret"
      }
    }
  }'
```

- [Parse Configuration](/parse/overview#configuration): All available parsing options.

---

## Schema vs Schemaless

Extract supports two modes of operation: schema-based extraction (the default) and schemaless extraction.

**Schema-based extraction** is what most users need. You define a JSON schema specifying exactly which fields to extract and their types. The model returns data matching your schema structure. This gives you predictable, typed output that integrates cleanly with your application code.

**Python**

```python
# Schema-based: you define the exact structure
result = client.extract.run(
    input=upload.file_id,
    instructions={
        "schema": {
            "type": "object",
            "properties": {
                "invoice_number": {"type": "string"},
                "total": {"type": "number"}
            }
        }
    },
    parsing={"settings": {"model": "r-1"}},
)
```

**Node.js**

```javascript
// Schema-based: you define the exact structure
const result = await client.extract.run({
  input: upload.file_id,
  instructions: {
    schema: {
      type: 'object',
      properties: {
        invoice_number: { type: 'string' },
        total: { type: 'number' }
      }
    }
  },
  parsing: { settings: { model: 'r-1' } },
});
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "reducto://your-file-id",
    "instructions": {
      "schema": {
        "type": "object",
        "properties": {
          "invoice_number": {"type": "string"},
          "total": {"type": "number"}
        }
      }
    }
  }'
```

**Schemaless extraction** lets the model decide what to extract based on a natural language prompt. Instead of providing a schema, you describe what you want in plain English. The model analyzes the document and returns whatever it deems relevant. This is useful for exploration or when you don't know the document structure in advance.

**Python**

```python
# Schemaless: the model decides what to extract
result = client.extract.run(
    input=upload.file_id,
    instructions={
        "system_prompt": "Extract all the key financial information from this invoice"
    },
    parsing={"settings": {"model": "r-1"}},
)
```

**Node.js**

```javascript
// Schemaless: the model decides what to extract
const result = await client.extract.run({
  input: upload.file_id,
  instructions: {
    system_prompt: 'Extract all the key financial information from this invoice'
  },
  parsing: { settings: { model: 'r-1' } },
});
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "reducto://your-file-id",
    "instructions": {
      "system_prompt": "Extract all the key financial information from this invoice"
    }
  }'
```

Use schema-based extraction for production workflows where you need consistent output structure. Use schemaless extraction when exploring new document types or building prototypes.

- [Schema Best Practices](/extraction/best-practices-extract): Detailed guidance on schema design, naming conventions, and descriptions.

---

## Array Extraction

Standard extraction works well for short documents, but for documents with many repeating items (hundreds of transactions, long invoice line items), you need array extraction.

The problem: LLMs have context limits. When a document is too long, items toward the end may be truncated or missed. Array extraction solves this by segmenting the document, extracting from each segment, and merging the results.

**Python**

```python
result = client.extract.run(
    input=upload.file_id,
    instructions={
        "schema": {
            "type": "object",
            "properties": {
                "transactions": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "date": {"type": "string"},
                            "description": {"type": "string"},
                            "amount": {"type": "number"}
                        }
                    }
                }
            }
        }
    },
    settings={"array_extract": True},
    parsing={"settings": {"model": "r-1"}},
)
```

**Node.js**

```javascript
const result = await client.extract.run({
  input: upload.file_id,
  instructions: {
    schema: {
      type: 'object',
      properties: {
        transactions: {
          type: 'array',
          items: {
            type: 'object',
            properties: {
              date: { type: 'string' },
              description: { type: 'string' },
              amount: { type: 'number' }
            }
          }
        }
      }
    }
  },
  settings: { array_extract: true },
  parsing: { settings: { model: 'r-1' } },
});
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "reducto://your-file-id",
    "instructions": {
      "schema": {
        "type": "object",
        "properties": {
          "transactions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {"type": "string"},
                "description": {"type": "string"},
                "amount": {"type": "number"}
              }
            }
          }
        }
      }
    },
    "settings": {"array_extract": true}
  }'
```

> **Note:** Array extraction requires at least one top-level property of type `array` in your schema. If your schema has no arrays, the endpoint returns an error.

- [Array Extraction Guide](/configs/extract/array-extraction): Detailed configuration and algorithm options.

---

## Citations

Citations link each extracted value back to its source location in the document. Enable them when you need to verify extractions or show users where values came from.

**Python**

```python
result = client.extract.run(
    input=upload.file_id,
    instructions={"schema": schema},
    settings={
        "citations": {
            "enabled": True
        }
    },
    parsing={"settings": {"model": "r-1"}},
)

# With citations enabled, result is a dict with wrapped values
field = result.result["total_amount"]
print(f"Value: {field.value}")
print(f"Found on page {field.citations[0].bbox.page}")
print(f"Confidence: {field.citations[0].confidence}")
```

**Node.js**

```javascript
const result = await client.extract.run({
  input: upload.file_id,
  instructions: { schema },
  settings: {
    citations: {
      enabled: true
    }
  },
  parsing: { settings: { model: 'r-1' } },
});

// With citations enabled, result is an object with wrapped values
const field = result.result.total_amount;
console.log(`Value: ${field.value}`);
console.log(`Found on page ${field.citations[0].bbox.page}`);
console.log(`Confidence: ${field.citations[0].confidence}`);
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "reducto://your-file-id",
    "instructions": {"schema": {...}},
    "settings": {
      "citations": {
        "enabled": true
      }
    }
  }'
```

When citations are enabled, the response format changes. Each value is wrapped in an object containing `value` and `citations`:

```json
{
  "result": {
    "total_amount": {
      "value": 23278.62,
      "citations": [
        {
          "type": "Table",
          "content": "Total: $23,278.62",
          "bbox": {"left": 0.04, "top": 0.26, "width": 0.45, "height": 0.50, "page": 3},
          "confidence": "high"
        }
      ]
    }
  }
}
```

Each citation includes:

- **Page number** where the value was found
- **Bounding box** coordinates (normalized 0-1)
- **Confidence** as `"high"` or `"low"`
- **Source text** the original text that was extracted from

- [Citations Guide](/configs/extract/citations): Working with bounding boxes and confidence scores.

---

## Troubleshooting

**Outputs differ between runs**

LLM outputs are inherently non-deterministic. Small variations are normal. To reduce variance:

1. Use enums to constrain possible values
2. Make field descriptions more specific
3. Add examples in your system prompt

If you need identical outputs for identical inputs, consider caching results by document hash.

**Only the first pages are processed**

This typically happens with long documents containing arrays. Enable `array_extract` to process the full document:

**Python**

```python
result = client.extract.run(
    input=upload.file_id,
    instructions={"schema": schema},
    settings={"array_extract": True},
    parsing={"settings": {"model": "r-1"}},
)
```

**Node.js**

```javascript
const result = await client.extract.run({
  input: upload.file_id,
  instructions: { schema },
  settings: { array_extract: true },
  parsing: { settings: { model: 'r-1' } },
});
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "reducto://your-file-id",
    "instructions": {"schema": {...}},
    "settings": {"array_extract": true}
  }'
```

You can also add guidance in your system prompt: "Process all pages in the document, not just the beginning."

**Missing values from schema**

When expected fields come back empty:

1. **Check the Parse output first.** Extract can only find what Parse sees. Run `client.parse.run(input=upload.file_id)` and verify the value appears in the content.
2. **If it's in Parse output**, refine your schema. Add better field descriptions that match how the value appears in the document.
3. **If it's not in Parse output**, adjust your parsing configuration. Check that `parsing.settings.model` is `"r-1"`, and try the HTML table output format.

For long arrays, also try enabling `array_extract`.

**Hallucinated or computed values**

Extract returns only what's on the document. If you request calculated fields (like "annual cost" when only monthly appears), the model may fabricate values.

**Solution**: Extract raw values and compute in your code:

**Python**

```python
monthly_cost = result.result["monthly_cost"].value
annual_cost = monthly_cost * 12  # Compute yourself
```

**Node.js**

```javascript
const monthlyCost = result.result.monthly_cost.value;
const annualCost = monthlyCost * 12;  // Compute yourself
```

**Go**

```go
resultMap := result.Result.(map[string]interface{})
monthlyCost := resultMap["monthly_cost"].(map[string]interface{})["value"].(float64)
annualCost := monthlyCost * 12  // Compute yourself
```

Enable citations to verify source locations for any suspicious values.

**Schema is too large**

Very large schemas may exceed LLM token limits and fail with a 422 error. Solutions:

1. Flatten deeply nested structures
2. Remove unnecessary fields
3. Split into multiple extraction calls

As a rule of thumb, keep schemas under 50 fields. If you need more, consider breaking the extraction into logical groups.

**Citations and chunking error**

If you see "Citations and chunking cannot be enabled at the same time", you have conflicting options.

When citations are enabled, chunking is automatically disabled in the parsing step. If you're explicitly setting chunking options in `parsing.retrieval.chunking`, either remove them or disable citations.

**Password-protected PDF**

Pass the document password in parsing settings:

**Python**

```python
result = client.extract.run(
    input=upload.file_id,
    instructions={"schema": schema},
    parsing={
        "settings": {"model": "r-1", "document_password": "your-password"}
    }
)
```

**Node.js**

```javascript
const result = await client.extract.run({
  input: upload.file_id,
  instructions: { schema },
  parsing: {
    settings: { model: 'r-1', document_password: 'your-password' }
  }
});
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "reducto://your-file-id",
    "instructions": {"schema": {...}},
    "parsing": {
      "settings": {"document_password": "your-password"}
    }
  }'
```

---

## Next Steps

- [Response Format](/extract/response-format): Full breakdown of the response structure.

- [Best Practices](/extraction/best-practices-extract): Schema design and prompt writing tips.

- [Array Extraction](/configs/extract/array-extraction): Handle long documents with repeating data.

- [Citations](/configs/extract/citations): Trace values back to source locations.

- [Comparing extraction tools](https://reducto.ai/guides/best-ai-data-extraction-tools-unstructured-documents): How extraction tools differ on complex PDFs, scans, and document packets.

- [Enterprise extraction requirements](https://reducto.ai/guides/best-enterprise-data-extraction-software): What to check when extraction runs on long documents and complex tables.

Source: https://docs.reducto.ai/extract/overview/index.mdx
