Skip to main content
POST
/
v1
/
splits
from retab import Retab

client = Retab()

split = client.splits.create(
    document="invoice_batch.pdf",
    model="retab-small",
    subdocuments=[
        {
            "name": "invoice",
            "description": "Invoice documents with billing information",
            "allow_multiple_instances": True,
        },
        {"name": "receipt", "description": "Receipt documents for payments"},
        {"name": "contract", "description": "Legal contract documents"},
    ],
    instructions="Processing Q4 2024 vendor document batch",
    n_consensus=3,
    bust_cache=False,
)

for sub in split.output:
    print(f"{sub.name}: pages {sub.pages}")
{
  "id": "split_01G34H8J2K",
  "file": {
    "id": "file_6dd6eb00688ad8d1",
    "filename": "invoice_batch.pdf",
    "mime_type": "application/pdf"
  },
  "model": "retab-small",
  "subdocuments": [
    {
      "name": "invoice",
      "description": "Invoice documents with billing information",
      "allow_multiple_instances": true
    },
    {
      "name": "receipt",
      "description": "Receipt documents for payments",
      "allow_multiple_instances": false
    }
  ],
  "n_consensus": 3,
  "instructions": "Processing Q4 2024 vendor document batch",
  "output": [
    {"name": "invoice", "pages": [1, 2, 3]},
    {"name": "invoice", "pages": [4, 5]},
    {"name": "receipt", "pages": [6]}
  ],
  "consensus": {
    "likelihoods": [
      {"name": 0.98, "pages": [0.99, 0.97, 0.96]},
      {"name": 0.95, "pages": [0.95, 0.93]},
      {"name": 0.99, "pages": [0.99]}
    ],
    "choices": [
      [
        {"name": "invoice", "pages": [1, 2, 3]},
        {"name": "invoice", "pages": [4, 5]},
        {"name": "receipt", "pages": [6]}
      ],
      [
        {"name": "invoice", "pages": [1, 2]},
        {"name": "invoice", "pages": [3, 4, 5]},
        {"name": "receipt", "pages": [6]}
      ],
      [
        {"name": "invoice", "pages": [1, 2, 3]},
        {"name": "invoice", "pages": [4, 5]},
        {"name": "receipt", "pages": [6]}
      ]
    ]
  },
  "usage": {
    "credits": 3.0
  },
  "created_at": "2024-03-15T10:30:00Z",
  "updated_at": "2024-03-15T10:30:00Z"
}

Documentation Index

Fetch the complete documentation index at: https://docs.retab.com/llms.txt

Use this file to discover all available pages before exploring further.

Split a multi-page document into labeled subdocuments and return the canonical split resource. This endpoint is split-only: key-based grouping belongs to /v1/partitions.
from retab import Retab

client = Retab()

split = client.splits.create(
    document="invoice_batch.pdf",
    model="retab-small",
    subdocuments=[
        {
            "name": "invoice",
            "description": "Invoice documents with billing information",
            "allow_multiple_instances": True,
        },
        {"name": "receipt", "description": "Receipt documents for payments"},
        {"name": "contract", "description": "Legal contract documents"},
    ],
    instructions="Processing Q4 2024 vendor document batch",
    n_consensus=3,
    bust_cache=False,
)

for sub in split.output:
    print(f"{sub.name}: pages {sub.pages}")
{
  "id": "split_01G34H8J2K",
  "file": {
    "id": "file_6dd6eb00688ad8d1",
    "filename": "invoice_batch.pdf",
    "mime_type": "application/pdf"
  },
  "model": "retab-small",
  "subdocuments": [
    {
      "name": "invoice",
      "description": "Invoice documents with billing information",
      "allow_multiple_instances": true
    },
    {
      "name": "receipt",
      "description": "Receipt documents for payments",
      "allow_multiple_instances": false
    }
  ],
  "n_consensus": 3,
  "instructions": "Processing Q4 2024 vendor document batch",
  "output": [
    {"name": "invoice", "pages": [1, 2, 3]},
    {"name": "invoice", "pages": [4, 5]},
    {"name": "receipt", "pages": [6]}
  ],
  "consensus": {
    "likelihoods": [
      {"name": 0.98, "pages": [0.99, 0.97, 0.96]},
      {"name": 0.95, "pages": [0.95, 0.93]},
      {"name": 0.99, "pages": [0.99]}
    ],
    "choices": [
      [
        {"name": "invoice", "pages": [1, 2, 3]},
        {"name": "invoice", "pages": [4, 5]},
        {"name": "receipt", "pages": [6]}
      ],
      [
        {"name": "invoice", "pages": [1, 2]},
        {"name": "invoice", "pages": [3, 4, 5]},
        {"name": "receipt", "pages": [6]}
      ],
      [
        {"name": "invoice", "pages": [1, 2, 3]},
        {"name": "invoice", "pages": [4, 5]},
        {"name": "receipt", "pages": [6]}
      ]
    ]
  },
  "usage": {
    "credits": 3.0
  },
  "created_at": "2024-03-15T10:30:00Z",
  "updated_at": "2024-03-15T10:30:00Z"
}

Request Body

document
MIMEData
required
The document to split.
subdocuments
array[Subdocument]
required
The labeled subdocuments to split the document into. Each entry has name, optional description, and allow_multiple_instances.
model
string
default:"retab-small"
The model used for the split operation.
instructions
string
Free-form instructions appended to the system prompt to steer the split.
n_consensus
integer
default:"1"
Number of consensus split runs to perform. Max: 8.
bust_cache
boolean
default:"false"
When true, bypass the cache and force a fresh split run.

Response Fields

id
string
Unique split identifier.
file
object
File metadata: id, filename, mime_type.
model
string
Model used for the split operation.
subdocuments
array[Subdocument]
The split labels used to produce this result.
n_consensus
integer
Number of consensus votes used to produce the result.
instructions
string | null
Free-form instructions supplied with the request.
output
array[SplitResult]
The list of subdocuments with their assigned pages.
consensus
SplitConsensus | null
Consensus metadata for multi-vote runs.
usage
RetabUsage | null
Usage information for the split operation.
created_at
string | null
ISO 8601 creation timestamp.
updated_at
string | null
ISO 8601 last update timestamp.

Authorizations

Api-Key
string
header
required

Body

application/json

Canonical split request — subdocuments must be CreateSplitSubdocument (extra='forbid').

The subdocuments field below intentionally narrows the parent's list[Subdocument] to list[CreateSplitSubdocument] so that legacy-only fields (e.g. partition_key) are rejected. The override is annotated with the parent type to keep pyright happy while a field_validator enforces the stricter shape at runtime.

document
MIMEData · object
required

The document to split

subdocuments
Subdocument · object[]
required

The subdocuments to split the document into

Minimum array length: 1
model
string
default:retab-small

The model to use to split the document

instructions
string | null

Free-form instructions appended to the system prompt to steer the split.

n_consensus
integer
default:1

Number of consensus split runs to perform. Uses deterministic single-pass when set to 1.

Required range: 1 <= x <= 8
bust_cache
boolean
default:false

If true, skip the LLM cache and force a fresh completion

Response

Successful Response

Backend-internal split with organization scoping.

file
FileRef · object
required

Information about the split file

model
string
required

Model used for the split operation

subdocuments
Subdocument · object[]
required

Subdocuments used for the split operation

output
SplitResult · object[]
required

The list of document splits with their assigned pages

id
string

Unique identifier of the split

n_consensus
integer
default:1

Number of consensus votes used

instructions
string | null

Free-form instructions supplied with the split request.

consensus
SplitConsensus · object

Consensus metadata for multi-vote split runs

origin
ProcessingRequestOrigin · object

Origin of the split request

usage
RetabUsage · object

Usage information for the split operation

created_at
string<date-time> | null
updated_at
string<date-time> | null