Understanding Multimodal Input with the OpenAI SDK

Ma Mahalakshmi V Updated 16 Sep 2026
6 min read ·Lesson 96 of 224

What "Multimodal" Actually Means

A traditional language model request contains only text: a system instruction, a user question, maybe some prior conversation turns. A multimodal request can contain other kinds of data alongside that text — most commonly images, but depending on the model also audio or documents. The model is trained to interpret pixels the way it interprets tokens: as information it reasons about, not as an opaque attachment it merely passes along.

This distinction matters because it changes what your application can do. Instead of asking a user to describe a chart in words before you can help them interpret it, you can hand the model the chart image directly and ask your question. Instead of writing a separate OCR pipeline to pull text out of a scanned form, you can send the scan itself and ask the model to extract the fields you need. The model performs the "seeing" and the "reasoning" in a single pass.

In Unit 7, Lesson 1 ("Working with Images, Files, and Audio") you saw the basic mechanics of input_image — how to pass an image URL or a base64 string as part of a request. This unit goes further: it treats vision as a production capability, not a one-off trick. You will learn how to structure multimodal requests reliably, how to reason about image size and cost, how to extract structured data from images, how to work with multiple images at once, and how to design prompts that produce consistent results rather than occasional lucky guesses.

How the Responses API Represents Multimodal Content

With the OpenAI Python SDK, a request is built around the input parameter of client.responses.create(). When your input is plain text, you can pass a string directly. The moment you need to include an image, input becomes a list of messages, and each message's content becomes a list of typed content parts.

from openai import OpenAI

client = OpenAI()

response = client.responses.create(
    model="gpt-5.6-terra",
    input=[
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "What is shown in this image?"},
                {
                    "type": "input_image",
                    "image_url": "https://example.com/photos/receipt.png",
                },
            ],
        }
    ],
)

print(response.output_text)

Each content part has a type field that tells the model how to interpret that piece of data:

  • "input_text" — a plain text fragment, equivalent to what you'd normally put in a simple string prompt.
  • "input_image" — a reference to an image, either as a URL or as base64-encoded data (covered in Lesson 2 and Lesson 3).

Why does the SDK require this list-of-parts structure instead of just letting you pass an image alongside a string? Because a single user turn can legitimately contain several unrelated pieces of information — two images and a question about how they differ, for example — and the model needs an unambiguous, ordered way to receive them. A flat string cannot represent "here is text, then an image, then more text" without inventing a fragile markup convention. The typed list is the SDK's explicit, structured alternative to that markup.

Why the Model Needs role and type at All

Beginners sometimes ask why they can't just concatenate everything into one message. Two reasons:

  1. role tells the model whose turn this is. A "user" role represents input from the person interacting with your application; a "system" role represents standing instructions you define at the developer level. Mixing these into a single undifferentiated blob would remove the model's ability to distinguish "the operator told me to behave this way" from "the end user is asking this."
  2. type tells the model how to decode each content part. Text is tokenized directly. Images go through a separate vision encoder before being merged into the model's reasoning process. Without an explicit type, the SDK (and the model) would have no way to know which decoding path a given piece of content needs.

When to Use Multimodal Input — and When Not To

Vision input is powerful, but it is not free, and it is not always the right tool.

Use multimodal input when:

  • The information genuinely lives in a visual medium: a screenshot, a scanned document, a photo of a whiteboard, a chart, a product photo.
  • You want the model to reason jointly about visual and textual context, such as "does this photo match the product description below?"
  • Building a text-extraction pipeline would require you to maintain a separate OCR or computer-vision service, and the model's built-in vision capability meets your accuracy requirements.

Avoid multimodal input when:

  • The same information is already available to you as structured text or data. Sending a screenshot of a JSON payload instead of the JSON itself adds cost and risk of misreading for no benefit.
  • You need pixel-perfect, deterministic extraction (for example, exact coordinates of a UI element for automated testing). Vision models describe and interpret; they do not guarantee exact geometric precision.
  • Latency is critical and the visual content is decorative rather than informative — including it only slows down the request without improving the answer.

Images Are Not Free: Tokens and Cost

An image you send is converted internally into a number of tokens before the model processes it, and that number depends on the image's resolution and the detail level you request (detail is covered in depth in Lesson 8). This has two practical consequences:

  • A single high-resolution image can consume more tokens than several paragraphs of text. If you are budgeting a context window or estimating cost per request, images must be accounted for explicitly, not treated as "free" attachments.
  • Downscaling an image before sending it — for example, resizing a 4000×3000 pixel photo down to something closer to what the model actually needs to answer your question — can meaningfully reduce cost without meaningfully reducing answer quality, because the model does not need more resolution than is required to distinguish the relevant details.

Note: Exact image tokenization formulas and default detail behavior are model-specific and can change between model versions. Confirm the current values in the official OpenAI documentation before using them to plan production cost budgets.

A Minimal Mental Model for the Rest of This Unit

Keep this mental model as you move through the rest of the unit:

  1. A multimodal request is a list of messages.
  2. Each message has a role and a content list.
  3. Each content part has a type that tells the model how to decode it — text, image URL, or image data.
  4. Images cost tokens, and how many depends on resolution and detail level.
  5. The model reasons over text and image content jointly, in the order the parts appear, not as separate isolated tasks.

Every lesson from here forward builds on this structure: sending images from different sources, extracting structured data from them, handling multiple images, and writing prompts that make the model's visual reasoning dependable rather than inconsistent.

0 Comments

Reviewed before they appear

No comments yet.

OpenAI SDK
Introduction to the OpenAI SDK Setting Up Python Creating an API Key Your First Call — client.responses.create() and response.output_text Understanding Billing, Credits, and What a Request Costs Why Responses Replaced Chat Completions Anatomy of a Request: model, input, and instructions Anatomy of a Response: The Typed output Array, Not Just Text Roles: User, Assistant, and Developer/System Choosing a Model, and Reading the Models Page Instead of Memorizing Names Instructions vs. Input Writing Prompts That Get Consistent Results Few-Shot Examples Reasoning Models and the reasoning Parameter Debugging a Prompt That Misbehaves Why Streaming Matters for User Experience stream=True and Iterating Over Events Handling the Event Types You Actually Care About Background Mode for Long-Running Jobs Project — Add Live Streaming to Your Chatbot The Problem With Parsing Free Text JSON Schema and Strict Mode Pydantic Models With the SDK's Parse Helpers Handling Refusals and Validation Failures Project — A Resume-to-JSON Extractor Working With input_image input_file, PDFs, and the Files API Image Generation Speech-to-Text and Text-to-Speech Project: A PDF Question-Answering Script What Function Calling Is Defining a Tool Schema The Full Loop Multiple Tools Errors, Timeouts, and Untrusted Arguments Project: A Weather Assistant Web Search File Search and Vector Stores Code Interpreter Remote MCP Servers and Connectors Project: A Research Assistant What an Embedding Is, Without the Maths Generating and Storing Embeddings Similarity Search From Scratch Hosted Vector Stores vs. Rolling Your Own A Small RAG App Over a Folder of Notes Agents vs. a Single API Call — When You Need One pip install openai Giving Agents Tools Handoffs and Multi-Agent Triage Guardrails and Approvals Tracing and Observing What Your Agent Did A Multi-Agent Support Desk Error Codes and What Each One Means Retries, Timeouts, and Backoff Rate Limits and Spend Limits Prompt Caching and Cost Optimisation The Batch API for Bulk Work Async Clients and Concurrency Moderation and Safety Best Practices Designing the App Backend With FastAPI Streaming to a Simple Frontend Deploying and a Cost/Safety Checklist Why Web Search Is Useful for Current Information Using the Web Search Tool with the Responses API Configuring Search Behavior for Application Use Cases Understanding Citations and Source Attribution Where to Go Next Building a Research Assistant with Web Search Combining Web Search with Structured Outputs Handling Conflicting or Low-Quality Web Sources Reducing Unsupported Claims with Grounded Generation Testing Freshness-Sensitive AI Answers Production Considerations for Web-Grounded Applications Understanding File Search and Retrieval-Augmented Generation Creating and Organizing Vector Stores Uploading Documents for Retrieval Connecting Vector Stores to Responses API Requests Designing Document Metadata and Filtering Strategies Building a PDF Question-Answering Application Improving Retrieval Quality With Better Document Preparation Handling Missing Evidence and Retrieval Failures Combining File Search With Web Search Building a Production Knowledge-Base Assistant What the Code Interpreter Tool Is Designed For Running Python-Based Analysis Through the OpenAI SDK Uploading Datasets for Analysis Analyzing CSV and Spreadsheet Data Generating Charts and Data Summaries Handling Generated Files and Downloadable Artifacts Building a Data-Analysis Assistant Combining Code Execution with Structured Outputs Validating Generated Calculations and Results Security and Sandbox Considerations for Code Execution Understanding Multimodal Input with the OpenAI SDK Sending Images to a Model Image Analysis from URLs and Uploaded Files Extracting Text and Information from Screenshots Building an Image-Question-Answering Application Combining Image Input with Structured Output Analyzing Multiple Images in One Request Handling Image Quality and Input Limitations Designing Multimodal Prompts for Reliable Results Building a Practical Vision-Powered Python Application Understanding Speech-to-Text and Text-to-Speech Workflows Transcribing Audio with the OpenAI SDK Working with Uploaded Audio Files Handling Timestamps and Transcription Metadata Building a Meeting Transcription Workflow Generating Spoken Responses from Text Handling Long Audio and Processing Failures Combining Audio with Text and Tool Calling Building an End-to-End Python Voice Application What Embeddings Are and When to Use Them Generating Embeddings With the OpenAI API Preparing Text for Embedding Comparing Vectors With Cosine Similarity Building a Simple Semantic Search Engine in Python Storing Embeddings in a Database Metadata Filtering for Semantic Search Chunking Strategies for Better Retrieval Evaluating Semantic Search Quality Building a Document Similarity Application When Batch Processing Makes Sense Designing Large-Volume AI Processing Pipelines Using Asynchronous Python with the OpenAI SDK Running Concurrent Requests Safely Controlling Concurrency and Avoiding Rate Limits Tracking Batch Job Progress Handling Partial Failures in Bulk Workloads Retrying Failed Items Without Duplicating Successful Work Designing Resumable AI Processing Jobs Building a Production Batch-Processing Pipeline Batch Processing Makes Sense Large-Scale AI Processing Pipelines Async Python with OpenAI SDK Safe Concurrent Requests Concurrency & Rate Limits Batch Progress Tracking Partial Failure Handling Safe Retry Handling Resumable AI Jobs Production Batch Pipeline System–User Data Separation Reusable App Instructions Prompt Templates & Variables Extraction & Classification Prompts Summarization & Transformation Prompts Explicit Output Requirements Prompt Version Management Prompt Testing & Evaluation Reusable Python Prompt Library API Key Security Secure API Key Storage Secure Secret Management Prompt Injection Prevention Trusted vs. Untrusted Content Tool Argument Validation Sensitive Data Handling Secure Logging AI Action Authorization Production AI Security Checklist Why AI Applications Need Evaluation Beyond Unit Tests Unit Testing OpenAI SDK Integration Code Mocking API Responses in Python Tests Testing Structured Outputs Against Schemas Testing Tool-Calling Workflows Building a Small Evaluation Dataset Measuring Accuracy, Consistency, and Failure Rates Regression Testing Prompts and Model Changes Human Evaluation Versus Automated Evaluation Creating a Repeatable Evaluation Pipeline AI Request Monitoring Token Cost Management Usage Metrics Design Reducing Model Calls Prompt & Context Optimization Model Selection & Optimization AI Caching Strategies Interactive Latency Optimization Usage Dashboards & Budget Alerts Performance & Cost Checklist Every API Call Starts Fresh Fixing API Statelessness Server-Side Conversation Memory Limits of Response Chaining What We're Building Conversation Memory Challenges Preparing an OpenAI SDK Application for Deployment Environment-Specific Configuration for Development and Production Deploying a Python AI Service with Docker Container Health Checks and Startup Configuration Managing Secrets in Cloud Deployments Background Workers for Long-Running AI Tasks Queues and Asynchronous Job Architectures Scaling AI Workloads Horizontally Monitoring Production Incidents and Failures Production Deployment Checklist for OpenAI SDK Applications Reusable OpenAI Service Classes AI Client Dependency Injection Typed AI Responses Python Configuration Management AI Request Decorators Centralized AI Error Handling Clean SDK Abstractions Reusable OpenAI Utilities Internal AI Python Libraries SDK Integration Maintenance Production AI Chatbot Document Q&A System Web Research Assistant Customer Support Agent AI Data Analysis Assistant Image Analysis App Meeting Transcription & Summary Semantic Document Search Multi-Tool AI Agent Production OpenAI SDK App Why "It Looked Fine When I Tested It" Isn't Enough Timing Note Status Note Pre-Decision Status Note Current Availability Note
Ask about this post
AI Ask about this post

Ask questions about Understanding Multimodal Input with the OpenAI SDK and get answers drawn from it.

Signed-in readers only.