from retab import MIMEData, Retab
client = Retab()
document = MIMEData(
filename="invoice_batch.pdf",
url="https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
)
split = client.splits.create(
document=document,
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}")
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const document = {
filename: "invoice_batch.pdf",
url: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
};
const split = await client.splits.create(document, [
{
name: "invoice",
description: "Invoice documents with billing information",
allowMultipleInstances: true,
},
{ name: "receipt", description: "Receipt documents for payments" },
{ name: "contract", description: "Legal contract documents" },
], "retab-small", "Processing Q4 2024 vendor document batch", 3, false);
split.output.forEach((sub) => {
console.log(`${sub.name}: pages ${sub.pages}`);
});
package main
import (
"context"
"fmt"
"log"
retab "github.com/retab-dev/retab/clients/go"
)
func ptr[T any](v T) *T { return &v }
func main() {
ctx := context.Background()
client, err := retab.NewClient("")
if err != nil {
log.Fatal(err)
}
document := retab.MIMEData{
Filename: "invoice_batch.pdf",
URL: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
}
split, err := client.Splits.Create(ctx, &retab.SplitsCreateParams{
Document: document,
Model: ptr("retab-small"),
Subdocuments: []*retab.Subdocument{
{Name: "invoice", Description: ptr("Invoice documents with billing information"), AllowMultipleInstances: ptr(true)},
{Name: "receipt", Description: ptr("Receipt documents for payments")},
{Name: "contract", Description: ptr("Legal contract documents")},
},
Instructions: ptr("Processing Q4 2024 vendor document batch"),
NConsensus: ptr(3),
BustCache: ptr(false),
})
if err != nil {
log.Fatal(err)
}
for _, sub := range split.Output {
fmt.Printf("%s: pages %v\n", sub.Name, sub.Pages)
}
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
document = {
filename: 'invoice_batch.pdf',
url: 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf',
}
split = client.splits.create(
document: document,
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,
)
split.output.each do |sub|
puts "#{sub.name}: pages #{sub.pages}"
end
use retab::models::Subdocument;
use retab::resources::splits::CreateParams;
use retab::{MimeData, Retab};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Retab::new(std::env::var("RETAB_API_KEY")?);
let document = MimeData::new(
"invoice_batch.pdf",
"https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
);
let subdocuments = vec![
Subdocument {
name: "invoice".into(),
description: Some("Invoice documents with billing information".into()),
allow_multiple_instances: Some(true),
},
Subdocument {
name: "receipt".into(),
description: Some("Receipt documents for payments".into()),
allow_multiple_instances: None,
},
Subdocument {
name: "contract".into(),
description: Some("Legal contract documents".into()),
allow_multiple_instances: None,
},
];
let mut params = CreateParams::new(document, subdocuments);
params.body.model = Some("retab-small".into());
params.body.instructions = Some("Processing Q4 2024 vendor document batch".into());
params.body.n_consensus = Some(3);
params.body.bust_cache = Some(false);
let split = client.splits().create(params).await?;
for sub in split.output.as_ref().unwrap() {
println!("{}: pages {:?}", sub.name, sub.pages);
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->splits()->create(
document: [
'filename' => 'invoice_batch.pdf',
'url' => 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf',
],
subdocuments: [['name' => 'invoice', 'description' => 'Invoice documents']],
);
print_r($result);
using System;
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = MimeData.FromUrl(
new Uri("https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf"));
var result = await client.Splits.CreateAsync(new SplitsCreateOptions
{
Document = document,
Model = "retab-small",
Subdocuments = new List<Subdocument>
{
new Subdocument
{
Name = "invoice",
Description = "Invoice documents with billing information",
AllowMultipleInstances = true,
},
new Subdocument { Name = "receipt", Description = "Receipt documents for payments" },
new Subdocument { Name = "contract", Description = "Legal contract documents" },
},
Instructions = "Processing Q4 2024 vendor document batch",
NConsensus = 3,
BustCache = false,
});
Console.WriteLine(result);
import com.retab.RetabClient;
import com.retab.models.MimeData;
import com.retab.models.Subdocument;
import java.net.URI;
import java.util.List;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
MimeData document = MimeData.fromUrl(
URI.create("https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf"));
List<Subdocument> subdocuments = List.of(
new Subdocument("invoice", "Invoice documents with billing information", true),
new Subdocument("receipt", "Receipt documents for payments", null),
new Subdocument("contract", "Legal contract documents", null));
var result = client.splits().create(
document,
subdocuments,
"retab-small",
"Processing Q4 2024 vendor document batch",
3L,
false,
null);
System.out.println(result);
}
}
curl -X POST \
'https://api.retab.com/v1/splits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"document": {
"filename": "invoice_batch.pdf",
"url": "https://my-bucket.s3.us-east-1.amazonaws.com/documents/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
}'
{
"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"
}
Create Split
Create a split.
Divides a document into the named subdocuments, assigning each its set of pages,
using the chosen model and optional instructions. Set n_consensus above 1 to
run multiple votes and consolidate them. Returns the stored Split with its output
page assignments, and responds with 201.
from retab import MIMEData, Retab
client = Retab()
document = MIMEData(
filename="invoice_batch.pdf",
url="https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
)
split = client.splits.create(
document=document,
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}")
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const document = {
filename: "invoice_batch.pdf",
url: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
};
const split = await client.splits.create(document, [
{
name: "invoice",
description: "Invoice documents with billing information",
allowMultipleInstances: true,
},
{ name: "receipt", description: "Receipt documents for payments" },
{ name: "contract", description: "Legal contract documents" },
], "retab-small", "Processing Q4 2024 vendor document batch", 3, false);
split.output.forEach((sub) => {
console.log(`${sub.name}: pages ${sub.pages}`);
});
package main
import (
"context"
"fmt"
"log"
retab "github.com/retab-dev/retab/clients/go"
)
func ptr[T any](v T) *T { return &v }
func main() {
ctx := context.Background()
client, err := retab.NewClient("")
if err != nil {
log.Fatal(err)
}
document := retab.MIMEData{
Filename: "invoice_batch.pdf",
URL: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
}
split, err := client.Splits.Create(ctx, &retab.SplitsCreateParams{
Document: document,
Model: ptr("retab-small"),
Subdocuments: []*retab.Subdocument{
{Name: "invoice", Description: ptr("Invoice documents with billing information"), AllowMultipleInstances: ptr(true)},
{Name: "receipt", Description: ptr("Receipt documents for payments")},
{Name: "contract", Description: ptr("Legal contract documents")},
},
Instructions: ptr("Processing Q4 2024 vendor document batch"),
NConsensus: ptr(3),
BustCache: ptr(false),
})
if err != nil {
log.Fatal(err)
}
for _, sub := range split.Output {
fmt.Printf("%s: pages %v\n", sub.Name, sub.Pages)
}
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
document = {
filename: 'invoice_batch.pdf',
url: 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf',
}
split = client.splits.create(
document: document,
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,
)
split.output.each do |sub|
puts "#{sub.name}: pages #{sub.pages}"
end
use retab::models::Subdocument;
use retab::resources::splits::CreateParams;
use retab::{MimeData, Retab};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Retab::new(std::env::var("RETAB_API_KEY")?);
let document = MimeData::new(
"invoice_batch.pdf",
"https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
);
let subdocuments = vec![
Subdocument {
name: "invoice".into(),
description: Some("Invoice documents with billing information".into()),
allow_multiple_instances: Some(true),
},
Subdocument {
name: "receipt".into(),
description: Some("Receipt documents for payments".into()),
allow_multiple_instances: None,
},
Subdocument {
name: "contract".into(),
description: Some("Legal contract documents".into()),
allow_multiple_instances: None,
},
];
let mut params = CreateParams::new(document, subdocuments);
params.body.model = Some("retab-small".into());
params.body.instructions = Some("Processing Q4 2024 vendor document batch".into());
params.body.n_consensus = Some(3);
params.body.bust_cache = Some(false);
let split = client.splits().create(params).await?;
for sub in split.output.as_ref().unwrap() {
println!("{}: pages {:?}", sub.name, sub.pages);
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->splits()->create(
document: [
'filename' => 'invoice_batch.pdf',
'url' => 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf',
],
subdocuments: [['name' => 'invoice', 'description' => 'Invoice documents']],
);
print_r($result);
using System;
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = MimeData.FromUrl(
new Uri("https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf"));
var result = await client.Splits.CreateAsync(new SplitsCreateOptions
{
Document = document,
Model = "retab-small",
Subdocuments = new List<Subdocument>
{
new Subdocument
{
Name = "invoice",
Description = "Invoice documents with billing information",
AllowMultipleInstances = true,
},
new Subdocument { Name = "receipt", Description = "Receipt documents for payments" },
new Subdocument { Name = "contract", Description = "Legal contract documents" },
},
Instructions = "Processing Q4 2024 vendor document batch",
NConsensus = 3,
BustCache = false,
});
Console.WriteLine(result);
import com.retab.RetabClient;
import com.retab.models.MimeData;
import com.retab.models.Subdocument;
import java.net.URI;
import java.util.List;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
MimeData document = MimeData.fromUrl(
URI.create("https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf"));
List<Subdocument> subdocuments = List.of(
new Subdocument("invoice", "Invoice documents with billing information", true),
new Subdocument("receipt", "Receipt documents for payments", null),
new Subdocument("contract", "Legal contract documents", null));
var result = client.splits().create(
document,
subdocuments,
"retab-small",
"Processing Q4 2024 vendor document batch",
3L,
false,
null);
System.out.println(result);
}
}
curl -X POST \
'https://api.retab.com/v1/splits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"document": {
"filename": "invoice_batch.pdf",
"url": "https://my-bucket.s3.us-east-1.amazonaws.com/documents/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
}'
{
"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"
}
/v1/partitions.
from retab import MIMEData, Retab
client = Retab()
document = MIMEData(
filename="invoice_batch.pdf",
url="https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
)
split = client.splits.create(
document=document,
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}")
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const document = {
filename: "invoice_batch.pdf",
url: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
};
const split = await client.splits.create(document, [
{
name: "invoice",
description: "Invoice documents with billing information",
allowMultipleInstances: true,
},
{ name: "receipt", description: "Receipt documents for payments" },
{ name: "contract", description: "Legal contract documents" },
], "retab-small", "Processing Q4 2024 vendor document batch", 3, false);
split.output.forEach((sub) => {
console.log(`${sub.name}: pages ${sub.pages}`);
});
package main
import (
"context"
"fmt"
"log"
retab "github.com/retab-dev/retab/clients/go"
)
func ptr[T any](v T) *T { return &v }
func main() {
ctx := context.Background()
client, err := retab.NewClient("")
if err != nil {
log.Fatal(err)
}
document := retab.MIMEData{
Filename: "invoice_batch.pdf",
URL: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
}
split, err := client.Splits.Create(ctx, &retab.SplitsCreateParams{
Document: document,
Model: ptr("retab-small"),
Subdocuments: []*retab.Subdocument{
{Name: "invoice", Description: ptr("Invoice documents with billing information"), AllowMultipleInstances: ptr(true)},
{Name: "receipt", Description: ptr("Receipt documents for payments")},
{Name: "contract", Description: ptr("Legal contract documents")},
},
Instructions: ptr("Processing Q4 2024 vendor document batch"),
NConsensus: ptr(3),
BustCache: ptr(false),
})
if err != nil {
log.Fatal(err)
}
for _, sub := range split.Output {
fmt.Printf("%s: pages %v\n", sub.Name, sub.Pages)
}
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
document = {
filename: 'invoice_batch.pdf',
url: 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf',
}
split = client.splits.create(
document: document,
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,
)
split.output.each do |sub|
puts "#{sub.name}: pages #{sub.pages}"
end
use retab::models::Subdocument;
use retab::resources::splits::CreateParams;
use retab::{MimeData, Retab};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Retab::new(std::env::var("RETAB_API_KEY")?);
let document = MimeData::new(
"invoice_batch.pdf",
"https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf",
);
let subdocuments = vec![
Subdocument {
name: "invoice".into(),
description: Some("Invoice documents with billing information".into()),
allow_multiple_instances: Some(true),
},
Subdocument {
name: "receipt".into(),
description: Some("Receipt documents for payments".into()),
allow_multiple_instances: None,
},
Subdocument {
name: "contract".into(),
description: Some("Legal contract documents".into()),
allow_multiple_instances: None,
},
];
let mut params = CreateParams::new(document, subdocuments);
params.body.model = Some("retab-small".into());
params.body.instructions = Some("Processing Q4 2024 vendor document batch".into());
params.body.n_consensus = Some(3);
params.body.bust_cache = Some(false);
let split = client.splits().create(params).await?;
for sub in split.output.as_ref().unwrap() {
println!("{}: pages {:?}", sub.name, sub.pages);
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->splits()->create(
document: [
'filename' => 'invoice_batch.pdf',
'url' => 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf',
],
subdocuments: [['name' => 'invoice', 'description' => 'Invoice documents']],
);
print_r($result);
using System;
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = MimeData.FromUrl(
new Uri("https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf"));
var result = await client.Splits.CreateAsync(new SplitsCreateOptions
{
Document = document,
Model = "retab-small",
Subdocuments = new List<Subdocument>
{
new Subdocument
{
Name = "invoice",
Description = "Invoice documents with billing information",
AllowMultipleInstances = true,
},
new Subdocument { Name = "receipt", Description = "Receipt documents for payments" },
new Subdocument { Name = "contract", Description = "Legal contract documents" },
},
Instructions = "Processing Q4 2024 vendor document batch",
NConsensus = 3,
BustCache = false,
});
Console.WriteLine(result);
import com.retab.RetabClient;
import com.retab.models.MimeData;
import com.retab.models.Subdocument;
import java.net.URI;
import java.util.List;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
MimeData document = MimeData.fromUrl(
URI.create("https://my-bucket.s3.us-east-1.amazonaws.com/documents/invoice_batch.pdf"));
List<Subdocument> subdocuments = List.of(
new Subdocument("invoice", "Invoice documents with billing information", true),
new Subdocument("receipt", "Receipt documents for payments", null),
new Subdocument("contract", "Legal contract documents", null));
var result = client.splits().create(
document,
subdocuments,
"retab-small",
"Processing Q4 2024 vendor document batch",
3L,
false,
null);
System.out.println(result);
}
}
curl -X POST \
'https://api.retab.com/v1/splits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"document": {
"filename": "invoice_batch.pdf",
"url": "https://my-bucket.s3.us-east-1.amazonaws.com/documents/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
}'
{
"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"
}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Request body to create a split.
The document to split
Show child attributes
Show child attributes
The subdocuments to split the document into
Show child attributes
Show child attributes
The model to use to split the document
Free-form instructions appended to the system prompt to steer the split.
Number of consensus split runs to perform. Uses deterministic single-pass when set to 1.
If true, skip the LLM cache and force a fresh completion
If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1//{id} until status is terminal. Mutually exclusive with stream.
Response
Successful Response
A split result: a document divided into its constituent subdocuments.
Unique identifier of the split result
Information about the split file
Show child attributes
Show child attributes
Model used for the split operation
Subdocuments used for the split operation
Show child attributes
Show child attributes
Number of consensus votes used
Free-form instructions supplied with the split request.
The list of document splits with their assigned pages. Empty [] until status == 'completed'.
Show child attributes
Show child attributes
Lifecycle status. The synchronous path returns 'completed'. Background runs progress pending -> queued -> in_progress -> completed | failed | cancelled.
pending, queued, in_progress, completed, failed, cancelled Error details when a background run fails; null otherwise. Always present so consumers can read it without an existence check.
Show child attributes
Show child attributes
Consensus metadata for multi-vote split runs
Show child attributes
Show child attributes
Usage information for the split operation
Show child attributes
Show child attributes