
Overview
extract turns an image into structured data. You provide an output_schema
and an optional instruction, and ViscribeAI asks the model for strict JSON that
matches that schema.
Use simple fields for quick extraction. Use JSON Schema, or a Pydantic model in
Python, when your application needs richer types or nested objects. In
TypeScript, you can also pass a Zod schema directly.
Pydantic models
Python can accept a Pydantic model class asoutput_schema.
Simple fields
Simple fields supporttext, number, array_text, and array_number.
ViscribeAI converts them into a strict object schema. A maximum of 10 fields is
supported.
- Python
- TypeScript
JSON Schema
Use JSON Schema when you need explicit schema control.- Python
- TypeScript
Zod schemas
TypeScript can accept Zod schemas asoutputSchema. ViscribeAI converts the
schema to JSON Schema for the model request, then validates the parsed response
with Zod before returning result.data.
Result and validation
result.data contains the parsed object. Python returns a Pydantic instance when
the output schema is a Pydantic model; otherwise it returns a dictionary.
TypeScript returns the parsed object, or Zod-parsed data when the output schema
is a Zod schema.
With strict mode enabled, ViscribeAI asks the provider for strict structured
output and fills required properties for object schemas. Strict mode is enabled
by default.
Strict schemas are checked against the OpenAI Structured Outputs subset before
the request is sent. Unsupported schemas raise StructuredOutputSchemaError
with a schema path and suggested fix.
ViscribeAI also validates parsed model output locally before returning
result.data. Invalid output raises StructuredOutputValidationError.
Output Schema Validation
Learn how Python and TypeScript validate extracted data against your output schema.