from retab import MIMEData, Retabclient = Retab()document = MIMEData( filename="passport.jpeg", url="https://storage.googleapis.com/retab-docs/passport.jpeg",)response = client.schemas.generate( documents=[document], model="retab-small", # or any model your plan supports)print("Generated JSON Schema:")print(response)
import { Retab } from "@retab/node";import { config } from "dotenv";config();const client = new Retab({ apiKey: process.env.RETAB_API_KEY });const document = { filename: "passport.jpeg", url: "https://storage.googleapis.com/retab-docs/passport.jpeg",};const result = await client.schemas.generate([document], "retab-small");
using Retab;using RetabClient = Retab.Retab;var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;var client = new RetabClient(apiKey);var result = await client.Schemas.GenerateAsync(new SchemasGenerateOptions());Console.WriteLine(result);
import com.retab.RetabClient;public final class Example { public static void main(String[] args) throws Exception { RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY")); var result = client.schemas().generate(null, "retab-1.5", "Extract the invoice fields", null); System.out.println(result); }}
{ "title": "Invoice Document Schema", "description": "A schema for storing structured data extracted from invoice documents, including parties, line items, and payment details.", "type": "object", "X-SchemaType": "generic", "properties": { "invoice_number": { "type": "string", "description": "Unique identifier for the invoice." }, "date_of_issue": { "type": "string", "description": "Date when the invoice was issued." }, "date_due": { "type": "string", "description": "Date when the invoice payment is due." }, "seller": { "$ref": "#/$defs/party" }, "bill_to": { "$ref": "#/$defs/party" }, "ship_to": { "$ref": "#/$defs/party" }, "line_items": { "type": "array", "description": "List of items or services billed on the invoice.", "items": { "$ref": "#/$defs/line_item" } }, "subtotal": { "type": "number", "description": "Subtotal amount before taxes or discounts." }, "total": { "type": "number", "description": "Total amount due." }, "amount_due": { "type": "number", "description": "Amount due for payment." }, "currency": { "type": "string", "description": "Currency code (e.g., USD, EUR)." } }, "required": [ "invoice_number", "date_of_issue", "date_due", "seller", "bill_to", "ship_to", "line_items", "subtotal", "total", "amount_due", "currency" ], "additionalProperties": false, "$defs": { "party": { "type": "object", "description": "Information about a party involved in the invoice (seller, buyer, or recipient).", "properties": { "name": { "type": "string", "description": "Name of the party." }, "address": { "type": "string", "description": "Full address of the party." }, "email": { "type": "string", "description": "Email address of the party." }, "tax_id": { "type": "string", "description": "Tax identification number or EIN." } }, "required": ["name", "address", "email", "tax_id"], "additionalProperties": false }, "line_item": { "type": "object", "description": "A single item or service listed on the invoice.", "properties": { "description": { "type": "string", "description": "Description of the item or service." }, "service_period": { "type": "string", "description": "Service period or date range for the item." }, "quantity": { "type": "number", "description": "Quantity of the item or service." }, "unit_price": { "type": "number", "description": "Unit price of the item or service." }, "amount": { "type": "number", "description": "Total amount for this line item." } }, "required": [ "description", "service_period", "quantity", "unit_price", "amount" ], "additionalProperties": false } }}
Schemas
Generate
Generates a JSON Schema from scratch by inferring structure from the content of the provided example documents.
POST
/
v1
/
schemas
/
generate
from retab import MIMEData, Retabclient = Retab()document = MIMEData( filename="passport.jpeg", url="https://storage.googleapis.com/retab-docs/passport.jpeg",)response = client.schemas.generate( documents=[document], model="retab-small", # or any model your plan supports)print("Generated JSON Schema:")print(response)
import { Retab } from "@retab/node";import { config } from "dotenv";config();const client = new Retab({ apiKey: process.env.RETAB_API_KEY });const document = { filename: "passport.jpeg", url: "https://storage.googleapis.com/retab-docs/passport.jpeg",};const result = await client.schemas.generate([document], "retab-small");
using Retab;using RetabClient = Retab.Retab;var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;var client = new RetabClient(apiKey);var result = await client.Schemas.GenerateAsync(new SchemasGenerateOptions());Console.WriteLine(result);
import com.retab.RetabClient;public final class Example { public static void main(String[] args) throws Exception { RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY")); var result = client.schemas().generate(null, "retab-1.5", "Extract the invoice fields", null); System.out.println(result); }}
{ "title": "Invoice Document Schema", "description": "A schema for storing structured data extracted from invoice documents, including parties, line items, and payment details.", "type": "object", "X-SchemaType": "generic", "properties": { "invoice_number": { "type": "string", "description": "Unique identifier for the invoice." }, "date_of_issue": { "type": "string", "description": "Date when the invoice was issued." }, "date_due": { "type": "string", "description": "Date when the invoice payment is due." }, "seller": { "$ref": "#/$defs/party" }, "bill_to": { "$ref": "#/$defs/party" }, "ship_to": { "$ref": "#/$defs/party" }, "line_items": { "type": "array", "description": "List of items or services billed on the invoice.", "items": { "$ref": "#/$defs/line_item" } }, "subtotal": { "type": "number", "description": "Subtotal amount before taxes or discounts." }, "total": { "type": "number", "description": "Total amount due." }, "amount_due": { "type": "number", "description": "Amount due for payment." }, "currency": { "type": "string", "description": "Currency code (e.g., USD, EUR)." } }, "required": [ "invoice_number", "date_of_issue", "date_due", "seller", "bill_to", "ship_to", "line_items", "subtotal", "total", "amount_due", "currency" ], "additionalProperties": false, "$defs": { "party": { "type": "object", "description": "Information about a party involved in the invoice (seller, buyer, or recipient).", "properties": { "name": { "type": "string", "description": "Name of the party." }, "address": { "type": "string", "description": "Full address of the party." }, "email": { "type": "string", "description": "Email address of the party." }, "tax_id": { "type": "string", "description": "Tax identification number or EIN." } }, "required": ["name", "address", "email", "tax_id"], "additionalProperties": false }, "line_item": { "type": "object", "description": "A single item or service listed on the invoice.", "properties": { "description": { "type": "string", "description": "Description of the item or service." }, "service_period": { "type": "string", "description": "Service period or date range for the item." }, "quantity": { "type": "number", "description": "Quantity of the item or service." }, "unit_price": { "type": "number", "description": "Unit price of the item or service." }, "amount": { "type": "number", "description": "Total amount for this line item." } }, "required": [ "description", "service_period", "quantity", "unit_price", "amount" ], "additionalProperties": false } }}
from retab import MIMEData, Retabclient = Retab()document = MIMEData( filename="passport.jpeg", url="https://storage.googleapis.com/retab-docs/passport.jpeg",)response = client.schemas.generate( documents=[document], model="retab-small", # or any model your plan supports)print("Generated JSON Schema:")print(response)
import { Retab } from "@retab/node";import { config } from "dotenv";config();const client = new Retab({ apiKey: process.env.RETAB_API_KEY });const document = { filename: "passport.jpeg", url: "https://storage.googleapis.com/retab-docs/passport.jpeg",};const result = await client.schemas.generate([document], "retab-small");
using Retab;using RetabClient = Retab.Retab;var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;var client = new RetabClient(apiKey);var result = await client.Schemas.GenerateAsync(new SchemasGenerateOptions());Console.WriteLine(result);
import com.retab.RetabClient;public final class Example { public static void main(String[] args) throws Exception { RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY")); var result = client.schemas().generate(null, "retab-1.5", "Extract the invoice fields", null); System.out.println(result); }}