Skip to main content
Schemas define the structured output you expect from Retab. They are standard JSON Schema objects used by extraction, processor, and workflow calls to validate the data returned from documents. Use POST /v1/schemas/generate when you want Retab to infer a schema from example documents.

Generate Schema

The schema generation endpoint accepts one or more documents and returns a JSON Schema inferred from those examples. You can pass optional instructions, model routing, and image resolution settings.
from retab import Retab

client = Retab()

schema = client.schemas.generate(
documents=[
"freight/booking_confirmation_1.jpg",
"freight/booking_confirmation_2.jpg",
],
model="retab-small",
image_resolution_dpi=192,
instructions="Capture shipment dates, parties, and reference numbers.",
)

print(schema.json_schema)

Request Fields

documents
MIMEData[]
required
Example documents used to infer the schema.
model
string
default:"retab-small"
Model or Retab router alias used for schema generation.
instructions
string
Extra guidance for fields, naming conventions, or domain-specific details.
image_resolution_dpi
integer
default:"192"
Resolution used when converting visual documents for the model.
stream
boolean
default:"false"
Whether to stream schema generation output.

Response Fields

object
string
Always "schema".
created_at
string
Timestamp for the generated schema response.
json_schema
object
The generated JSON Schema.
strict
boolean
Whether the schema should be treated as strict structured output.