Skip to main content

Extract structured data from images using AI models.

Project description

ViscribeAI

ViscribeAI

Extract structured data from images using AI models.

X @itsperini LinkedIn itsperini Discord Docs docs.viscribe.ai Python 3.10+ Node.js 20+ License MIT

Define the output schema, pass the image, pick the AI model, and get parsed structured output back instead of free-form text.

⭐ If Viscribe helps your project, please leave a star. ⭐

📦 Installation

Python:

pip install viscribe

TypeScript:

npm install viscribe

🚀 Features

  • 🖼️ AI-powered image description, extraction, classification, VQA (Visual Question Answering), and comparison
  • 🔄 Both sync and async clients
  • 📊 Structured output with Pydantic schemas
  • 🔍 Detailed logging
  • ⚡ Automatic retries

🎯 Quick Start

from viscribe.images import describe

result = describe(
    image_path="examples/venice.png",
    # image_base64="...",
    generate_tags=True,
    model_config={
        "model": "gpt-5-mini",
        "api_key": "sk-...",
        "temperature": 1,
    },
)

print(result)

# ImageResult(
#     data={
#         "image_description": "A scenic view of Venice...",
#         "tags": ["Venice", "canal", "gondolas"],
#     },
#     raw=<OpenAI response>,
#     usage_metadata={"input_tokens": 123, "output_tokens": 45, ...},
# )
TypeScript
import { images } from "viscribe";

const result = await images.describe({
  imagePath: "examples/venice.png",
  generateTags: true,
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

console.log(result);

Note: Viscribe works with OpenAI-compatible endpoints (more support coming soon). It is recommended to load your API key from an environment variable instead of hardcoding it in your code.

📚 Image Endpoints

Method Description
describe Generate an objective image description with optional tags.
classify Classify an image into one or more allowed or free-form categories.
ask Ask a visual question and get an answer grounded in the image.
extract Extract structured data from an image using simple fields, JSON Schema, or a Pydantic model in Python.
compare Compare two images and describe their similarities and differences.

1. Describe Image

Generate a natural language description of an image, optionally with tags.

from viscribe.images import describe

result = describe(
    image_path="examples/venice.png",
    generate_tags=True,
    model_config={
        "model": "gpt-5-mini",
        "api_key": "sk-...",
        "temperature": 1,
    },
)

print(result.data)
TypeScript
import { images } from "viscribe";

const result = await images.describe({
  imagePath: "examples/venice.png",
  generateTags: true,
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

console.log(result.data);

2. Classify Image

Classify an image into one or more categories.

from viscribe.images import classify

result = classify(
    image_path="examples/venice.png",
    classes=["canal", "city", "landmark", "interior"],
    multi_label=True,
    model_config={
        "model": "gpt-5-mini",
        "api_key": "sk-...",
        "temperature": 1,
    },
)

print(result.data)
TypeScript
import { images } from "viscribe";

const result = await images.classify({
  imagePath: "examples/venice.png",
  classes: ["canal", "city", "landmark", "interior"],
  multiLabel: true,
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

console.log(result.data);

3. Visual Question Answering (VQA)

Ask a question about the content of an image and get an answer.

from viscribe.images import ask

result = ask(
    image_path="examples/venice.png",
    question="What kind of place is shown in this image?",
    model_config={
        "model": "gpt-5-mini",
        "api_key": "sk-...",
        "temperature": 1,
    },
)

print(result.data)
TypeScript
import { images } from "viscribe";

const result = await images.ask({
  imagePath: "examples/venice.png",
  question: "What kind of place is shown in this image?",
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

console.log(result.data);

4. Extract Structured Data from Image

Extract structured data from an image using either a simple or more complex output schema.

Simple Schema

Use a simple schema for straightforward data extraction.

from viscribe.images import extract

result = extract(
    image_path="examples/venice.png",
    output_schema=[
        {"name": "location", "type": "text", "description": "Likely place shown"},
        {"name": "visible_elements", "type": "array_text", "description": "Objects and structures"},
        {"name": "colors", "type": "array_text", "description": "Dominant colors"},
    ],
    model_config={
        "model": "gpt-5-mini",
        "api_key": "sk-...",
        "temperature": 1,
    },
)

print(result.data)
TypeScript
import { images } from "viscribe";

const result = await images.extract({
  imagePath: "examples/venice.png",
  outputSchema: [
    { name: "location", type: "text", description: "Likely place shown" },
    {
      name: "visible_elements",
      type: "array_text",
      description: "Objects and structures",
    },
    { name: "colors", type: "array_text", description: "Dominant colors" },
  ],
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

console.log(result.data);

Field Types:

  • text: Single text value
  • number: Single numeric value
  • array_text: Array of text values
  • array_number: Array of numeric values

More Complex Schema

Use a Pydantic model as the output_schema when you need complex or nested structures.

from pydantic import BaseModel
from viscribe.images import extract


class Scene(BaseModel):
    location: str
    visible_elements: list[str]
    specifications: dict


result = extract(
    image_path="examples/venice.png",
    output_schema=Scene,
    model_config={
        "model": "gpt-5-mini",
        "api_key": "sk-...",
        "temperature": 1,
    },
)

print(result.data)
TypeScript
import { images } from "viscribe";

const result = await images.extract({
  imagePath: "examples/venice.png",
  outputSchema: {
    title: "Scene",
    type: "object",
    properties: {
      location: { type: "string" },
      visible_elements: {
        type: "array",
        items: { type: "string" },
      },
      specifications: { type: "object" },
    },
    required: ["location", "visible_elements", "specifications"],
    additionalProperties: false,
  },
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

console.log(result.data);

Note: output_schema can be either a simple list of field definitions or a Pydantic model.

5. Compare Images

Compare two images and get a description of their similarities and differences.

from viscribe.images import compare

result = compare(
    image1_path="examples/venice.png",
    image2_path="examples/venice.png",
    model_config={
        "model": "gpt-5-mini",
        "api_key": "sk-...",
        "temperature": 1,
    },
)

print(result.data)
TypeScript
import { images } from "viscribe";

const result = await images.compare({
  image1Path: "examples/venice.png",
  image2Path: "examples/venice.png",
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

console.log(result.data);

⚡ Async Usage

All Python endpoints support async operations with direct a* helpers:

import asyncio
from viscribe.images import adescribe


async def main() -> None:
    result = await adescribe(
        image_path="examples/venice.png",
        generate_tags=True,
        model_config={
            "model": "gpt-5-mini",
            "api_key": "sk-...",
            "temperature": 1,
        },
    )

    print(result.data)


asyncio.run(main())

You can also reuse an async client:

import asyncio
from viscribe import ViscribeAI


async def main() -> None:
    client = ViscribeAI(
        model_config={
            "model": "gpt-5-mini",
            "api_key": "sk-...",
            "temperature": 1,
        }
    )

    result = await client.images.adescribe(
        image_path="examples/venice.png",
        generate_tags=True,
    )

    print(result.data)


asyncio.run(main())
TypeScript

TypeScript is async-native, so use the same methods with await:

import { images, ViscribeAI } from "viscribe";

const result = await images.describe({
  imagePath: "examples/venice.png",
  generateTags: true,
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

console.log(result.data);

const client = new ViscribeAI({
  modelConfig: {
    model: "gpt-5-mini",
    apiKey: "sk-...",
    temperature: 1,
  },
});

const clientResult = await client.images.describe({
  imagePath: "examples/venice.png",
  generateTags: true,
});

console.log(clientResult.data);

📖 Documentation

For detailed documentation, visit docs.viscribe.ai

🛠️ Development

For information about setting up the development environment and contributing to the project, see our Contributing Guide.

💬 Support & Feedback

🤝 Contributing

Feel free to contribute and join our Discord server to discuss with us improvements and give us suggestions!

Please see the contributing guidelines.

My Skills My Skills My Skills

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🔗 Links

⭐ If Viscribe helps your project, please leave a star. ⭐


Made with ❤️ by ViscribeAI

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

viscribe-1.0.5.tar.gz (5.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viscribe-1.0.5-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file viscribe-1.0.5.tar.gz.

File metadata

  • Download URL: viscribe-1.0.5.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

Hashes for viscribe-1.0.5.tar.gz
Algorithm Hash digest
SHA256 741881336086d369fba5b815baca890ee91fb248dc390dda8a149bbc8aebb89a
MD5 a248a6fc8d0d4059fbc5ed095c73248e
BLAKE2b-256 4e2d7d13fd1c5d7548e54983fac987f005b3ab7827ab8085ebe2e76e5b222d9d

See more details on using hashes here.

File details

Details for the file viscribe-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: viscribe-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for viscribe-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 16df7d83b95de73fedb344af16adb2bd1b55c9e569eef9329e9b402cdc943bbb
MD5 9e9c361a327e83cf51e3948383020f1d
BLAKE2b-256 87474e7f1a221e501de82a412504de2626578e24c4a5ba7debcbe574bb81afd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page