JavaScript/TypeScript SDK to interact with the Regia AI services and APIs.
npm install @regia-ai/js-sdk
import { Vision } from '@regia-ai/js-sdk';
import { z } from 'zod';
// Initialize the Vision client with your token
const vision = new Vision("your_token_here");
// Define your schema using Zod
const schema = z.object({
usageKwh: z.number().describe("The total usage in kWh"),
dueDate: z.string().describe("The due date of the invoice in the format YYYY-MM-DD"),
totalAmount: z.number().describe("The total amount of the invoice"),
})
// Extract data from the PDF file
const { usageKwh, dueDate, totalAmount } = await vision.extract('./sample.pdf', { schema });
// Log the extracted data
console.log("Usage kWh: ", usageKwh);
console.log(`Due date: ${dueDate}`);
console.log(`Total amount: ${totalAmount}`);
You define the structure of the extracted data using Zod, a TypeScript-first schema declaration and validation library.
This allows the server to understand what fields to extract using generative AI.
You can also pass a JSON Schema string to the schema
parameter.
All requests require a bearer token passed during client initialization:
const client = new Vision('your-api-token')
For more information checkout the Developer Documentation.
Option | Type | Required | Description |
---|---|---|---|
token |
string | ✅ | Your API token |
Extracts structured data from a media file.
Parameter | Type | Required | Description |
---|---|---|---|
file |
string |
✅ | Path to the local file or a base64-encoded string. |
schema |
ZodSchema |
✅ | The schema defining the desired fields to extract. |
- Node.js >= 18
- Zod for schema definition
- Access to Regia's PDF Extractor API