The platform
Extract
Pull the fields you need out of a parsed document, shaped by your own JSON schema.
An extract job reads a completed parse job and returns JSON shaped by a schema you define: the invoice number, the total, the line items. Parse the document first, then extract from it.
Define the schema and extract
Section titled “Define the schema and extract”The schema is a JSON Schema object. In Python, ExtractionSchema builds it from a class: see the
Python SDK.
curl -X POST "https://byteit.ai/v1/jobs/extract-jobs/" \ -H "X-API-Key: $BYTEIT_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "parse_job_id": "3f9a1c2e-5b7d-4e8f-9a0b-1c2d3e4f5a6b", "schema": { "type": "object", "properties": { "invoice_number": { "type": "string", "description": "Invoice number" }, "total": { "type": "string", "description": "Total amount due" } } }, "extraction_complexity": "medium"}'import os
from byteit import ByteIt
client = ByteIt(api_key=os.environ["BYTEIT_API_KEY"])
client.extract_jobs.create( parse_job_id="3f9a1c2e-5b7d-4e8f-9a0b-1c2d3e4f5a6b", schema={ "type": "object", "properties": { "invoice_number": { "type": "string", "description": "Invoice number", }, "total": { "type": "string", "description": "Total amount due", }, }, }, extraction_complexity="medium",)import { ByteItClient } from "@byteit/sdk";
const client = new ByteItClient({ apiKey: process.env.BYTEIT_API_KEY! });
await client.extractJobs.create({ parse_job_id: "3f9a1c2e-5b7d-4e8f-9a0b-1c2d3e4f5a6b", schema: { type: "object", properties: { invoice_number: { type: "string", description: "Invoice number", }, total: { type: "string", description: "Total amount due", }, }, }, extraction_complexity: "medium",});using ByteIt;
var client = new ByteItClient(Environment.GetEnvironmentVariable("BYTEIT_API_KEY")!);
await client.ExtractJobs.CreateAsync(new CreateExtractJobRequest{ ParseJobId = "3f9a1c2e-5b7d-4e8f-9a0b-1c2d3e4f5a6b", Schema = new Dictionary<string, object?> { ["type"] = "object", ["properties"] = new Dictionary<string, object?> { ["invoice_number"] = new Dictionary<string, object?> { ["type"] = "string", ["description"] = "Invoice number", }, ["total"] = new Dictionary<string, object?> { ["type"] = "string", ["description"] = "Total amount due", }, }, }, ExtractionComplexity = ExtractionComplexityEnum.Medium,});Give every field a description: it tells the extraction what the field means.
Complexity
Section titled “Complexity”extraction_complexity sets the tier of the extraction: low, medium (the default) or high.
The result
Section titled “The result”When the job is completed, download its result: a JSON document with the fields of your schema.
{ "number": "HF-0418", "total": "4280.00" }Save schemas to reuse them
Section titled “Save schemas to reuse them”Save a schema once under a name and reuse it across jobs and in Studio: POST /v1/schemas/ with a
name and the schema_json. See Schemas in the API reference.