---
title: "Analyze images in batch with AI vision"
description: "Run the same AI prompt against multiple images automatically, without writing loops or managing API calls."
url: "https://www.pixeltable.com/notebooks/vision-batch-analysis"
updated: "2026-04-10"
---

# Analyze images in batch with AI vision

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

- **Type:** Notebook
- **Group:** Images

## 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:** `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

```python
# 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')
)
```

## Open it

- **Open in Colab:** https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/images/vision-batch-analysis.ipynb
- **Docs page:** https://docs.pixeltable.com/howto/cookbooks/images/vision-batch-analysis
- **Source on GitHub:** https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/images/vision-batch-analysis.ipynb
