from retab import Retab
client = Retab()
response = client.edit.agent.fill(
document="form.pdf",
instructions="Fill this form with: Name: John Doe, Date: 2025-01-02, Email: john@example.com",
model="retab-small"
)
# Save the filled document
with open("filled_form.pdf", "wb") as f:
import base64
pdf_bytes = base64.b64decode(response.filled_document.url.split(",")[1])
f.write(pdf_bytes)
{
"form_data": [
{
"key": "full_name",
"description": "Full name of the applicant",
"type": "text",
"value": "John Doe",
"bbox": {
"left": 0.15,
"top": 0.22,
"width": 0.32,
"height": 0.03,
"page": 1
}
},
{
"key": "date",
"description": "Date of submission",
"type": "date",
"value": "2025-01-02",
"bbox": {
"left": 0.15,
"top": 0.28,
"width": 0.18,
"height": 0.03,
"page": 1
}
},
{
"key": "email",
"description": "Email address",
"type": "text",
"value": "john@example.com",
"bbox": {
"left": 0.15,
"top": 0.34,
"width": 0.32,
"height": 0.03,
"page": 1
}
}
],
"filled_document": {
"filename": "form_filled.pdf",
"mime_type": "application/pdf",
"url": "data:application/pdf;base64,JVBERi0xLjQK..."
}
}
from retab import Retab
client = Retab()
response = client.edit.agent.fill(
document="form.pdf",
instructions="Fill this form with: Name: John Doe, Date: 2025-01-02, Email: john@example.com",
model="retab-small"
)
# Save the filled document
with open("filled_form.pdf", "wb") as f:
import base64
pdf_bytes = base64.b64decode(response.filled_document.url.split(",")[1])
f.write(pdf_bytes)
{
"form_data": [
{
"key": "full_name",
"description": "Full name of the applicant",
"type": "text",
"value": "John Doe",
"bbox": {
"left": 0.15,
"top": 0.22,
"width": 0.32,
"height": 0.03,
"page": 1
}
},
{
"key": "date",
"description": "Date of submission",
"type": "date",
"value": "2025-01-02",
"bbox": {
"left": 0.15,
"top": 0.28,
"width": 0.18,
"height": 0.03,
"page": 1
}
},
{
"key": "email",
"description": "Email address",
"type": "text",
"value": "john@example.com",
"bbox": {
"left": 0.15,
"top": 0.34,
"width": 0.32,
"height": 0.03,
"page": 1
}
}
],
"filled_document": {
"filename": "form_filled.pdf",
"mime_type": "application/pdf",
"url": "data:application/pdf;base64,JVBERi0xLjQK..."
}
}
instructions.
This endpoint supports PDF, DOCX, XLSX, and PPTX inputs.
from retab import Retab
client = Retab()
response = client.edit.agent.fill(
document="form.pdf",
instructions="Fill this form with: Name: John Doe, Date: 2025-01-02, Email: john@example.com",
model="retab-small"
)
# Save the filled document
with open("filled_form.pdf", "wb") as f:
import base64
pdf_bytes = base64.b64decode(response.filled_document.url.split(",")[1])
f.write(pdf_bytes)
{
"form_data": [
{
"key": "full_name",
"description": "Full name of the applicant",
"type": "text",
"value": "John Doe",
"bbox": {
"left": 0.15,
"top": 0.22,
"width": 0.32,
"height": 0.03,
"page": 1
}
},
{
"key": "date",
"description": "Date of submission",
"type": "date",
"value": "2025-01-02",
"bbox": {
"left": 0.15,
"top": 0.28,
"width": 0.18,
"height": 0.03,
"page": 1
}
},
{
"key": "email",
"description": "Email address",
"type": "text",
"value": "john@example.com",
"bbox": {
"left": 0.15,
"top": 0.34,
"width": 0.32,
"height": 0.03,
"page": 1
}
}
],
"filled_document": {
"filename": "form_filled.pdf",
"mime_type": "application/pdf",
"url": "data:application/pdf;base64,JVBERi0xLjQK..."
}
}