Including Images in Prompts to Multimodal Models
This lesson explains how to include images in a prompt to a multimodal model deployed in Foundry, and how to write prompts that produce reliable visual answers.
Learning outcomes
After completing this lesson, you will be able to:
- Include an image in a request with an input_image content part.
- Explain how the detail setting affects tokens and cost.
- Write prompts that produce reliable answers about images.
Including images
In the Foundry playground, you attach an image to a chat message and ask about it. In code, the Responses API's user message has a content list that mixes parts: input_text parts for text and input_image parts for images. An image is given either as a URL that the service can reach or as a data URL containing the base64-encoded file (data:image/jpeg;base64,...). Several images can be sent in one message, for example to compare a product photo with a reference.
import base64
b64 = base64.b64encode(open("shelf.jpg", "rb").read()).decode()
response = openai.responses.create(
model="gpt-5.4-mini",
input=[{"role": "user", "content": [
{"type": "input_text", "text": "Which products on this shelf are out of stock?"},
{"type": "input_image", "image_url": f"data:image/jpeg;base64,{b64}", "detail": "high"},
]}],
)
print(response.output_text)An image the model never sees
Image detail and cost
Images are converted into tokens, and larger, more detailed images cost more tokens and take longer. The detail setting controls this: low processes a small version of the image, which is enough for overall descriptions and classification; high processes more detail, which is needed for small text or fine features; and auto lets the service decide.
The following diagram compares low and high detail.

Low or high detail?
Prompting with images
Visual prompts follow the same rules as text prompts. State precisely what to look for and how to answer; ask for structured output when code will use the answer; and instruct the model to say when the image does not show the information rather than guessing, because models can misread small text or infer details that are not visible. For accessibility, ask for alt text that conveys the image's purpose in context.
Reducing cost
An application sorts 100,000 product photos a day into five categories such as shoes and bags, using a multimodal model with detail set to high. The team wants to cut cost without changing models.
Broad categorization does not need fine detail, so setting detail to low reduces the image tokens per request substantially. A structured output with an enum of the five categories also keeps responses short. Increasing max_output_tokens would not reduce image token cost.
Why should a vision prompt tell the model to say when the image does not show the answer?
Show answer
Otherwise the model may guess, giving an answer that the image does not support.
Exam Tips
Remember for the exam
- Send images as input_image parts with a URL or base64 data URL, alongside input_text.
- detail=low for broad tasks, high for small text and fine detail.
- Instruct the model to say when the image does not show the answer.