Analyze images in batch with AI vision

Run the same AI prompt against multiple images automatically, without writing loops or managing API calls.

Images · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

How it works

You add a computed column that applies openai.chat_completions() with multimodal messages to every image in your table. Pixeltable handles the API calls, retries, and result storage automatically.

When you insert new images, the analysis runs automatically—no extra code needed.

What it covers

  • Analyze multiple images with a single prompt using openai.chat_completions()
  • Get all results at once, stored in your table
  • No loops or manual API calls

What it uses

Install
terminal
pip install pixeltable openai
Environment variables it names
OPENAI_API_KEY
Pixeltable calls
openai.chat_completions()pxt.create_table()insert()add_computed_column()

A look at the code

vision-batch-analysis.ipynb
# Define the prompt
messages = [
{
'role': 'user',
'content': [
{
'type': 'text',
'text': 'Describe this image in one sentence.',
},
{'type': 'image_url', 'image_url': t.image},
],
}
]
# Add computed column for AI analysis using openai.chat_completions()
t.add_computed_column(
description=openai.chat_completions(messages, model='gpt-4o-mini')
)

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103