Extract structured data from images using AI models.
Project description
Define the output schema, pass the image, pick the AI model, and get parsed structured output back instead of free-form text.
📦 Installation
pip install viscribe
🚀 Features
- 🖼️ One schema-driven
extracthelper for image workflows - 🔄 Sync and async helpers:
extractandaextract - 📊 Pydantic models, JSON Schema dictionaries, and simple field definitions
- 📁 Local image paths, base64 images, and remote image URLs
- ⚙️ Reusable
ViscribeAI().images.extractclient namespace - 🧩 OpenAI-compatible model configuration
🎯 Quick Start
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",
"api_key": "sk-...",
"temperature": 1,
},
)
print(result.data.model_dump())
🧱 Schema Options
output_schema accepts:
- simple field definitions
- JSON Schema dictionaries
- Pydantic model classes
Simple field types are text, number, array_text, and array_number.
Strict schemas are checked against the OpenAI Structured Outputs subset before
the request is sent. Unsupported schemas raise StructuredOutputSchemaError
with the schema path and a suggested fix.
⚡ Async
from viscribe.images import aextract
result = await aextract(
image_url="https://example.com/receipt.png",
output_schema=[{"name": "total_amount", "type": "number"}],
instruction="Extract the visible receipt total.",
)
♻️ Reusable Client
from viscribe import ViscribeAI
client = ViscribeAI(model_config={"model": "gpt-5-mini", "temperature": 1})
result = client.images.extract(
image_path="examples/receipt.png",
output_schema=[{"name": "total_amount", "type": "number"}],
)
💬 Support & Feedback
- 📧 Email: support@viscribe.ai
- 💻 GitHub Issues: Create an issue
- 💬 Discord: Join the community
🤝 Contributing
Please see the contributing guidelines.
🛠️ Development
uv sync
uv run ruff check .
uv run python -m pytest
uv build
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file viscribe-1.2.0.tar.gz.
File metadata
- Download URL: viscribe-1.2.0.tar.gz
- Upload date:
- Size: 5.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a4c00af21fb764f834e394e5d1d3b5f38a72dcbaa70ed008caec5a5873b66f7
|
|
| MD5 |
fbc91816a97557ee0463f8e2c55547df
|
|
| BLAKE2b-256 |
771519532bac21fa932c3396b5dc8c7f59563a2df24bf27fb4f00abb6b366dca
|
File details
Details for the file viscribe-1.2.0-py3-none-any.whl.
File metadata
- Download URL: viscribe-1.2.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e224e4d739e2d62d7a5ae39fbb8bd71e5b8186ef390f6e4c4ba0a11ab61919b2
|
|
| MD5 |
7ed5e8fc087b438a09411e30852712ac
|
|
| BLAKE2b-256 |
2bb9bb74a532fba617c2ad44aa255c56b45c950ba6a6802f76ab83508b29ae4d
|