Skip to main content
Lesson 11 of 12 · Grok Vision: Understanding Images

Unlimited Images per Request

Lesson 11 of 12 Updated July 30, 2026 Beginner
On this page
  1. A Competitive Advantage of the xAI API
  2. What “Unlimited” Really Means
  3. Practical Recommendations by Volume
  4. Multi-Image Architectures in Production
  5. Error Handling with Large Image Sets
  6. Key Takeaways

A Competitive Advantage of the xAI API

The xAI API stands out from competitors on one key technical point: it imposes no limit on the number of images sent in a single request. Where other APIs limit you to 4, 10, or 20 images, Grok accepts as many as you want.

This flexibility unlocks use cases impossible elsewhere, but it also requires a solid understanding of the practical implications.

What “Unlimited” Really Means

No limit on image count doesn’t mean no constraints. Several factors naturally limit how many images you can send effectively:

Context Window

The model has a fixed context window. Each image consumes between 256 and 1792 tokens. If you send 50 images in high mode, you potentially use 89,600 tokens for images alone, leaving little room for text and the response.

Analysis Quality

Beyond a certain number of images, analysis quality drops. The model must spread its attention across all images, which can lead to superficial descriptions or omissions.

Latency and Timeout

The more images you send, the longer processing takes. With a recommended timeout of 3600 seconds for reasoning models, very large requests can approach this limit.

Practical Recommendations by Volume

Number of Images Recommendation Suggested Detail
1-3 Detailed analysis possible high
4-10 Efficient comparison auto
11-20 Batch classification low
20+ Split into sub-requests low

Multi-Image Architectures in Production

Pattern: Sequential Processing with Aggregation

To analyze a large number of images, process them in batches then aggregate the results:

import json

def analyser_catalogue(images, taille_lot=8):
    """Analyzes an image catalogue in batches."""
    tous_resultats = []

    for i in range(0, len(images), taille_lot):
        lot = images[i:i + taille_lot]

        input_data = []
        for j, img in enumerate(lot, 1):
            input_data.append({
                "type": "input_text",
                "text": f"Image {i + j}:"
            })
            input_data.append({
                "type": "input_image",
                "image_url": img,
                "detail": "low"
            })

        input_data.append({
            "type": "input_text",
            "text": """For each image, identify in JSON:
{"number": N, "category": "...", "short_description": "..."}
Return a JSON array."""
        })

        response = client.responses.create(
            model="grok-4.5",
            input=input_data,
            store=False
        )

        try:
            resultats_lot = json.loads(response.output_text)
            tous_resultats.extend(resultats_lot)
        except json.JSONDecodeError:
            tous_resultats.append({"batch": i, "raw": response.output_text})

    return tous_resultats

Pattern: Funnel Filtering

Start with a quick sort across all images, then deep dive only into those that are relevant:

def entonnoir_analyse(images, critere):
    """Filters then analyzes in depth."""
    # Step 1: Quick filtering
    input_data = []
    for i, img in enumerate(images):
        input_data.append({"type": "input_image", "image_url": img, "detail": "low"})

    input_data.append({
        "type": "input_text",
        "text": f"""Among these {len(images)} images, which ones
match the criteria: "{critere}"?
Return only the numbers (0-based index) in JSON: [0, 3, 7]"""
    })

    response = client.responses.create(
        model="grok-4.5", input=input_data, store=False
    )

    indices = json.loads(response.output_text)

    # Step 2: In-depth analysis of filtered images
    resultats = []
    for idx in indices:
        response_detail = client.responses.create(
            model="grok-4.5",
            input=[
                {"type": "input_image", "image_url": images[idx], "detail": "high"},
                {"type": "input_text", "text": "Detailed analysis of this image."}
            ],
            store=False
        )
        resultats.append({"index": idx, "analysis": response_detail.output_text})

    return resultats

Error Handling with Large Image Sets

When working with a large number of images, errors are more likely. Implement robust handling:

import time

def requete_avec_retry(input_data, max_retries=3):
    for tentative in range(max_retries):
        try:
            response = client.responses.create(
                model="grok-4.5",
                input=input_data,
                store=False
            )
            return response
        except Exception as e:
            if tentative < max_retries - 1:
                delai = 2 ** tentative  # Exponential backoff
                time.sleep(delai)
            else:
                raise e

Key Takeaways

  • The xAI API accepts an unlimited number of images, but the context window remains finite
  • Beyond 10 images, use detail: "low" to preserve analysis quality
  • Beyond 20 images, split into sub-requests for reliability
  • The “funnel” pattern (quick filtering then detailed analysis) is most effective for large volumes
  • Implement retries with exponential backoff for large requests