Implementation:Openai Openai python Response Input Image
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Responses_API |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete response type for representing an image input item returned by the Responses API, provided by the openai-python SDK.
Description
ResponseInputImage is a Pydantic model representing an image input to the model as returned in API responses. It includes a required detail field indicating the resolution level ("low", "high", or "auto"), and a type field always set to "input_image". The image can be referenced either by file_id (an uploaded file) or by image_url (a fully qualified URL or base64-encoded data URL). Learn more about image inputs.
Usage
Import this type when you need to inspect image input content items returned within Responses API output, for example when processing multi-turn conversations that include image references.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/response_input_image.py
Signature
class ResponseInputImage(BaseModel):
"""An image input to the model."""
detail: Literal["low", "high", "auto"]
type: Literal["input_image"]
file_id: Optional[str] = None
image_url: Optional[str] = None
Import
from openai.types.responses import ResponseInputImage
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| detail | Literal["low", "high", "auto"] | Yes | The detail level of the image. One of high, low, or auto. Defaults to auto.
|
| type | Literal["input_image"] | Yes | The type of the input item. Always input_image.
|
| file_id | Optional[str] | No | The ID of the file to be sent to the model. |
| image_url | Optional[str] | No | The URL of the image to be sent to the model. A fully qualified URL or base64-encoded data URL. |
Usage Examples
import openai
client = openai.OpenAI()
response = client.responses.create(
model="gpt-4o",
input=[
{
"role": "user",
"content": [
{
"type": "input_image",
"image_url": "https://example.com/photo.jpg",
"detail": "auto",
},
{"type": "input_text", "text": "What is in this image?"},
],
}
],
)
# Inspect input image items from a retrieved response
for item in response.input:
if hasattr(item, "content"):
for content in item.content:
if content.type == "input_image":
print(f"Detail: {content.detail}")
print(f"Image URL: {content.image_url}")