Skip to main content

Install

pip install viscribe
npm install viscribe

Configure a model

Viscribe uses OpenAI-compatible chat completions with vision support. Set OPENAI_API_KEY in your environment or pass api_key / apiKey directly.
export OPENAI_API_KEY=sk-...
export OPENAI_MODEL=gpt-5-mini

Extract structured data

from pydantic import BaseModel, Field
from viscribe.images import extract

class Receipt(BaseModel):
merchant_name: str | None = Field(description="Store or business name")
total_amount: float | None = Field(description="Final total on the receipt")
date: str | None = Field(description="Receipt date if visible")
line_items: list[str] = Field(description="Visible purchased items")

result = extract(
image_path="examples/receipt.png",
output_schema=Receipt,
instruction="Extract the receipt fields visible in the image.",
model_config={
"model": "gpt-5-mini",
"temperature": 1,
},
)

print(result.data.model_dump())

import { images } from "viscribe";

const result = await images.extract({
  imagePath: "examples/receipt.png",
  outputSchema: [
    { name: "merchant_name", type: "text", description: "Store or business name" },
    { name: "total_amount", type: "number", description: "Final total on the receipt" },
    { name: "date", type: "text", description: "Receipt date if visible" },
    { name: "line_items", type: "array_text", description: "Visible purchased items" },
  ],
  instruction: "Extract the receipt fields visible in the image.",
  modelConfig: {
    model: "gpt-5-mini",
    temperature: 1,
  },
});

console.log(result.data);

Image inputs

Exactly one image source is required.
extract(image_path="examples/receipt.png", output_schema=Receipt)
extract(image_url="https://example.com/receipt.png", output_schema=Receipt)
extract(image_base64="iVBORw0KGgo...", output_schema=Receipt)
await images.extract({
  imagePath: "examples/receipt.png",
  outputSchema: [{ name: "total_amount", type: "number" }],
});
await images.extract({
  imageUrl: "https://example.com/receipt.png",
  outputSchema: [{ name: "total_amount", type: "number" }],
});
await images.extract({
  imageBase64: "iVBORw0KGgo...",
  outputSchema: [{ name: "total_amount", type: "number" }],
});