Skip to main content

awvision

Ask questions about images using a vision-capable model.

What it does

awvision is a lightweight client for vision-capable, OpenAI-compatible LLM services. Send an image and a question, get an answer.

The contract: Ask a question about an image and get an answer.

Installation

pip install -e .

Or with dev dependencies:

pip install -e ".[dev]"

Usage

Ask a question about an image

awvision ask image.png "What is in this image?"

Describe an image

awvision describe image.jpg

Compare two images

awvision compare image1.png image2.png

Configuration

Set environment variables to customize the endpoint and model:

export AWVISION_URL=http://localhost:8150
export AWVISION_MODEL=gpt-4-vision

Or pass them as options:

awvision --endpoint http://localhost:8150 --model gpt-4-vision ask image.png "What's this?"

Self-test

Run the self-tests to verify awvision is working correctly:

awvision --self-test

This will:

  • Test image loading and encoding
  • Verify media type detection
  • Check endpoint configuration
  • Validate error handling

Requirements

  • Python 3.10+
  • A vision-capable LLM service (e.g., OpenAI-compatible API)
  • The service must support the image_url content block format

How it works

awvision:

  1. Loads the image file and encodes it as base64
  2. Wraps it in an OpenAI-compatible chat message with image_url format
  3. Sends it to the configured vision service
  4. Returns the model's response

Important: Empty response detection

If a text-only model receives an image, it typically returns HTTP 200 with an empty response. awvision detects this and raises a clear error:

ERROR: Model 'gpt-4-vision' at http://localhost:8150 returned empty content.
This indicates the model does not support vision or cannot process image_url content blocks.
Verify that:
  1. The model 'gpt-4-vision' is vision-capable
  2. The endpoint supports the image_url format
  3. The image was properly encoded as a data URL

This prevents silent failures where an empty response looks like a successful query.

API

For programmatic use:

from awvision import ask_vision, describe_image, compare_images

# Ask a question
answer = ask_vision("image.png", "What color is this?")
print(answer)

# Describe an image
description = describe_image("image.jpg")
print(description)

# Compare two images
comparison = compare_images("image1.png", "image2.png")
print(comparison)

Error handling

awvision provides clear error messages for common issues:

  • FileNotFoundError: Image file not found
  • IOError: Image file is empty or unreadable
  • RuntimeError: Vision service is unavailable, model has no vision, or response is empty

All error messages include guidance on what to check.

Testing

Run the test suite:

pytest tests/ -v

Supported image formats

  • PNG (image/png)
  • JPEG (image/jpeg)
  • GIF (image/gif)
  • WebP (image/webp)

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awvision-0.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

awvision-0.1.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file awvision-0.1.0.tar.gz.

File metadata

  • Download URL: awvision-0.1.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for awvision-0.1.0.tar.gz
Algorithm Hash digest
SHA256 72c3177ec98331e66ab3f3158aa8613c0dc8987ea4a410fd8b7f3ae7422b017b
MD5 3e30fb191d8d51c02f9a3ec28a553b56
BLAKE2b-256 5b9b39b7d509b5523ab5a7693d804be3d26743aac42b54178ef1aa4187061e58

See more details on using hashes here.

File details

Details for the file awvision-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: awvision-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for awvision-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6dbb88bdcc3b1512fd646c48a3aef84e1d42a77dbc4c7eca6243d1d1ca0c5e18
MD5 c235c63d526dcb2ace72da0153248718
BLAKE2b-256 5c2263a774ea3e5d4ff9a7618d9217a286b84d5158a054901abc67fbff4ca038

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page