How to Use the GPT-4o Vision API

GPT-4o’s vision capabilities allow you to send images alongside text prompts and receive detailed, contextually aware responses about what the model sees. Released as part of GPT-4o in mid-2024, the vision API accepts standard image formats, handles multiple images per request, and produces responses that range from simple descriptions to complex reasoning about visual content. This guide covers the API’s capabilities, how to use it effectively, the prompt patterns that work best, and where it fits in the landscape of vision AI tools.

What GPT-4o Vision Can Do

GPT-4o’s vision is a general-purpose capability rather than a specialised computer vision model. It does not produce bounding boxes, pixel masks, or classification scores — it produces natural language responses to natural language questions about images. This makes it useful for a broad range of tasks that benefit from visual understanding combined with language reasoning:

  • Image description and captioning — describe what is in an image, suitable for alt text generation, content moderation review, or visual search indexing
  • Document and chart analysis — extract data from charts, read text from documents, interpret tables, and answer questions about financial reports or scientific figures
  • Product and object analysis — identify products, assess condition, compare items, or answer questions about objects in a scene
  • Code and diagram interpretation — read architecture diagrams, flowcharts, whiteboard sketches, and screenshots of UIs or error messages
  • Multi-image reasoning — compare two images, track changes between before/after photos, or reason across a sequence of frames

The key distinction from specialised vision models: GPT-4o vision understands context and nuance in a way that narrow models do not. Asking “is there anything unusual about this X-ray?” or “does this diagram match the description in this document?” requires general intelligence, not just pattern matching, and GPT-4o handles these well where a specialised model would not.

API Basics

The GPT-4o vision API is accessed through the standard Chat Completions endpoint by including image content blocks in the user message. Images can be provided as base64-encoded data or as publicly accessible URLs. URL-based access is simpler for development; base64 is necessary for private images that cannot be publicly hosted.

A few important constraints to know before building:

  • Maximum image size is 20MB per image via base64, and images are automatically resized to fit within the model’s vision resolution limits
  • Up to 10 images can be included in a single request
  • Images are priced by resolution — low-detail mode costs a flat 85 tokens per image; high-detail mode tiles the image and costs more depending on dimensions
  • The model cannot produce images, only describe and reason about them — image generation requires DALL-E or a separate model

Figure 1 — GPT-4o vision: detail modes and when to use each

Dimension Low detail High detail Token cost85 tokens flat512–1000+ tokens (tiled) Best forScene classification, quick Q&ADocuments, charts, fine detail Small text readable?NoYes (with sufficient resolution) Recommended whenProcessing many images at scaleAccuracy on details matters

Detail Mode: Low vs High

GPT-4o vision offers two detail modes that significantly affect both cost and capability. Low detail mode resizes the image to 512×512 and processes it as a single tile — fast, cheap (85 tokens), and appropriate for tasks that do not require reading text or discerning fine visual detail. High detail mode tiles the image at full resolution (up to 2048×2048 in 512×512 tiles) and processes each tile, then combines the results — more expensive but capable of reading small text, interpreting detailed charts, and noticing fine visual features.

Use low detail for bulk image classification tasks where you are asking questions that a lower-resolution view answers adequately: “is this image suitable for a family audience?”, “does this photo show indoor or outdoor content?”, “what is the dominant colour in this image?” Use high detail when the answer depends on fine visual content: reading text from a document, interpreting a technical diagram, checking a label for specific information, or counting small objects in a dense scene.

Prompt Patterns That Work Well

Vision prompting shares the same principles as text prompting, with a few additions specific to image input. Being specific about what region or aspect to focus on consistently improves results — “describe the chart in the upper-right quadrant of this image” outperforms “describe this image” when the chart is what you care about. Providing visual context helps when the image might be ambiguous — “this is a thermal imaging scan of a building facade; identify any areas of heat loss” gives the model the context to interpret the image correctly.

For structured output from images, asking for JSON in the prompt is reliable: “Extract all text from this receipt and return it as JSON with fields: merchant_name, date, items (array of name and price), total.” GPT-4o follows JSON output instructions consistently for well-defined extraction tasks, making it practical to build pipelines that process images and route the structured results to databases or downstream systems without further parsing logic.

Multi-Image Requests

GPT-4o can process multiple images in a single request, which enables comparison and relationship reasoning that single-image models cannot do. Useful patterns:

  • Before/after comparison — send two images and ask what changed: “These are photos of the same product before and after shipping. What damage, if any, has occurred?”
  • Consistency checking — send multiple images and verify they share a property: “Do all of these product photos show the item on a white background?”
  • Sequence reasoning — send a series of frames from a process and ask about the sequence: “These are frames from an assembly process. Identify which step, if any, was performed incorrectly.”
  • Document + image pairing — send a text document and a related image together: “Does this product image match the description in this spec sheet?”

Cost Management

Vision API costs are driven primarily by image resolution and volume. For high-volume pipelines, a few practices significantly reduce costs without meaningfully degrading quality. First, use low detail mode as the default and only escalate to high detail when the task requires it — many classification and description tasks work well at low detail. Second, resize images before sending rather than relying on the API to resize them — sending a 4K photograph when a 768×768 crop would answer the question wastes tokens. Third, consider a two-tier pipeline where a cheap, fast model handles initial triage and only routes images that meet specific criteria to GPT-4o vision — a conventional CV model that detects whether a document is present, for example, before sending only confirmed documents to GPT-4o for detailed extraction.

GPT-4o Vision vs Other Vision Models

GPT-4o vision sits in a competitive landscape. Claude 3.5/3.7 Sonnet has comparable vision capability and is often preferred for tasks requiring careful, nuanced reasoning about image content or detailed document analysis — its instruction-following on structured output from images is particularly strong. Gemini 1.5/2.0 Pro offers a larger context window and native multi-image handling, and is the best choice when processing many images simultaneously or working with very long documents that include images. For tasks requiring local processing, InternVL2 and LLaVA provide open-source alternatives that run on consumer hardware, though at lower quality than the frontier APIs. GPT-4o vision’s main advantages are its broad capability across diverse image types, its mature API with reliable structured output, and the ecosystem of tooling built around the OpenAI API.

GPT-4o vision is a practical starting point for most image understanding tasks — mature, well-documented, and capable across a wide range of use cases. Its combination of general visual understanding with strong language reasoning makes it the right default for tasks that require more than pattern classification, and its structured output reliability makes it straightforward to integrate into production pipelines. Evaluate it against Claude and Gemini on your specific task before committing to a model at scale — the right choice depends on the image types and question complexity your pipeline handles.

Handling Sensitive and Ambiguous Images

GPT-4o vision follows OpenAI’s content policies and will decline to describe certain categories of images — graphic violence, explicit content, and images that appear to involve minors in unsafe contexts. For production pipelines, design for graceful handling of these refusals: check the response for refusal language before attempting to parse structured output, log the image identifier for manual review, and continue processing the rest of the batch rather than failing the entire pipeline on a single refusal. The refusal rate on typical business content is very low, but building the handler before you hit the first refusal in production prevents a confusing failure mode that appears only in edge cases.

Ambiguous images — where the model genuinely cannot determine the answer — are handled differently from refusals. The model typically expresses uncertainty in its response (“it is not possible to determine from this image…”) rather than refusing outright. For pipelines that need a clear answer, prompt explicitly for a confidence level and a fallback response: “If you cannot determine the answer with confidence, respond with confidence: low and explanation: [reason].” This transforms uncertain responses from an unhandled edge case into a structured output you can route to a human review queue with the model’s explanation of why it was uncertain — more useful than a generic “could not process” flag.

Practical Evaluation Before Production

Before deploying a GPT-4o vision pipeline to production, build a labelled evaluation set from real examples of the images your pipeline will process — not stock photos or synthetic examples, but the actual image types from your use case. Evaluate accuracy, structured output compliance (does the model always return valid JSON in the format you specified), refusal rate, and latency across this set. Run the evaluation after any prompt change, model version update, or change in image preprocessing. GPT-4o model versions update periodically and while OpenAI generally maintains backward compatibility, vision behaviour on edge cases can shift between versions. A small, representative evaluation set run regularly is the most reliable way to catch regressions before they reach production users.

Leave a Comment