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

# Reducto

> Parse, extract, and split documents with the Reducto API

## Overview

The Reducto tools let you process documents (PDFs, images, spreadsheets, and other formats) using the [Reducto](https://reducto.ai/) API. Reducto provides OCR, layout detection, table extraction, and content chunking optimized for RAG applications, so you can turn unstructured documents into text, structured JSON, or logical sections inside your flows.

## Key Features

* `REDUCTO_UPLOAD`
  * Upload a file to Reducto and get back a `reducto://` URL for use with the other Reducto tools.
  * Inputs: `file_url` (publicly accessible or presigned URL), optional `extension` hint (e.g. `pdf`, `docx`).
  * Outputs: `file_id` and `reducto_url`.
* `REDUCTO_PARSE`
  * Parse a document to extract text, tables, and figures with layout-aware chunking.
  * Inputs: `document_url` (public URL, presigned S3 URL, or `reducto://` URL), plus options such as `chunk_mode` (`variable`, `section`, `page`, `disabled`, `block`, `page_sections`; default `disabled`), `chunk_size` (250–1500 characters), `table_output_format` (`html`, `json`, `md`, `jsonbbox`, `dynamic`, `csv`; default `dynamic`), `add_page_markers`, `merge_tables`, `ocr_system` (`standard` / `legacy`), `extraction_mode` (`ocr` / `hybrid`), `page_range` (e.g. `"1-5"`, `"1,3,5"`, `"1-3,7-9"`), and `document_password` for encrypted files.
  * Outputs: `job_id`, `num_pages`, and an array of `chunks` with their content blocks.
* `REDUCTO_EXTRACT`
  * Extract specific fields from a document into structured JSON using a user-defined JSON Schema. Ideal for invoices, forms, and contracts.
  * Inputs: `document_url`, `schema` (JSON Schema string), optional `system_prompt`, `array_extract` (repeating data such as invoice line items), `include_images`, `optimize_for_latency`, and `citations_enabled`.
  * Outputs: `extracted_data`, plus `job_id`, `num_pages`, and `num_fields`.
* `REDUCTO_SPLIT`
  * Split a document into sections using natural language category descriptions.
  * Inputs: `document_url`, `split_description` (JSON array of `{"name": ..., "description": ...}` categories), optional `split_rules` (natural language splitting rules), and `table_cutoff` (`truncate` / `preserve` for tables at page boundaries).
  * Outputs: `num_pages` and `splits` (each with `name`, `pages`, and `confidence`).

## Authentication

All Reducto tools require a Reducto API key, set in each step's config as `api_key`. Store the key as a secret (e.g. `REDUCTO_API_KEY`) and reference it with `{{secrets.REDUCTO_API_KEY}}`.

**Note**: Treat API keys as sensitive information and never commit them to public repositories.

### Example: Parse a PDF and Summarize It

```yaml theme={null}
- id: upload_report
  name: upload_report
  tool: REDUCTO_UPLOAD
  config:
    - name: api_key
      value: "{{secrets.REDUCTO_API_KEY}}"
  input:
    - name: file_url
      value: "{{steps.input_file.result.url}}"
    - name: extension
      value: pdf

- id: parse_report
  name: parse_report
  tool: REDUCTO_PARSE
  config:
    - name: api_key
      value: "{{secrets.REDUCTO_API_KEY}}"
  input:
    - name: document_url
      value: "{{steps.upload_report.result.reducto_url}}"
    - name: chunk_mode
      value: page
    - name: table_output_format
      value: md
    - name: add_page_markers
      value: true

- id: summarize_report
  name: summarize_report
  tool: OPENAI_INVOKE
  config:
    - name: version
      value: gpt-4
  input:
    - name: prompt
      value: |
        Summarize the following document. Highlight key figures and tables.

        {{steps.parse_report.result.chunks}}
```

### Example: Extract Structured Data from an Invoice

```yaml theme={null}
- id: extract_invoice
  name: extract_invoice
  tool: REDUCTO_EXTRACT
  config:
    - name: api_key
      value: "{{secrets.REDUCTO_API_KEY}}"
  input:
    - name: document_url
      value: "https://example.com/invoice.pdf"
    - name: schema
      value: '{"type":"object","properties":{"invoice_number":{"type":"string"},"total":{"type":"number"}}}'
    - name: array_extract
      value: true
```

## Notes

* `document_url` accepts public URLs, presigned S3 URLs, and `reducto://` URLs. Use `REDUCTO_UPLOAD` first when the file is not directly reachable by Reducto, then pass the returned `reducto_url` to the other tools.
* `REDUCTO_PARSE` defaults: chunking is `disabled`, table format is `dynamic`, OCR system is `standard` (multilingual; `legacy` supports Germanic languages only), and extraction mode is `hybrid` (OCR combined with native text).
* `page_range` is 1-indexed and accepts ranges and comma-separated lists (e.g. `"1-3,7-9"`).
* `schema` (`REDUCTO_EXTRACT`) and `split_description` (`REDUCTO_SPLIT`) must be valid JSON strings; the step fails with an error if they cannot be parsed.
* On API errors the tools return an error object with the HTTP status and the raw response, which you can inspect in the run log.
