Once you’ve tested your schema in the playground, you can export code for your preferred language:
Copy
import { Parsefy } from 'parsefy';import * as z from 'zod';const client = new Parsefy();// Schema exported from playgroundconst schema = z.object({ // REQUIRED - triggers fallback if below confidence threshold invoice_number: z.string().describe('The invoice number'), total: z.number().describe('Total amount including tax'), // OPTIONAL - won't trigger fallback if missing date: z.string().optional().describe('Invoice date'), vendor: z.string().optional().describe('Vendor name'),});const { object, metadata, verification } = await client.extract({ file: './invoice.pdf', schema, confidenceThreshold: 0.85, enableVerification: true,});console.log(`Confidence: ${object?._meta.confidence_score}`);if (verification) { console.log(`Verification: ${verification.status}`);}
Remember: All fields are required by default. Mark fields as optional if they might be missing in >20% of your documents to avoid triggering the expensive fallback model.