Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Response Input Image Param

From Leeroopedia
Knowledge Sources
Domains API_Types, Responses_API
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete TypedDict parameter type for supplying an image input to the model provided by the openai-python SDK.

Description

ResponseInputImageParam is a TypedDict used to construct image input items for the Responses API. Both detail (image resolution: "low", "high", or "auto") and type ("input_image") are required fields. The image can be referenced by file_id (an uploaded file) or by image_url (a fully qualified URL or base64-encoded data URL). Unlike ResponseInputImageContentParam, both detail and type are required in this variant. Learn more about image inputs.

Usage

Import this type when constructing standalone image input parameters for the Responses API where detail level must be explicitly specified.

Code Reference

Source Location

Signature

class ResponseInputImageParam(TypedDict, total=False):
    """An image input to the model."""

    detail: Required[Literal["low", "high", "auto"]]
    type: Required[Literal["input_image"]]
    file_id: Optional[str]
    image_url: Optional[str]

Import

from openai.types.responses import ResponseInputImageParam

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 base64
import openai

client = openai.OpenAI()

# Using a URL
image_param = {
    "type": "input_image",
    "detail": "high",
    "image_url": "https://example.com/photo.jpg",
}

# Using base64-encoded data
with open("photo.png", "rb") as f:
    b64 = base64.b64encode(f.read()).decode("utf-8")

image_param_b64 = {
    "type": "input_image",
    "detail": "auto",
    "image_url": f"data:image/png;base64,{b64}",
}

response = client.responses.create(
    model="gpt-4o",
    input=[
        {
            "role": "user",
            "content": [
                image_param,
                {"type": "input_text", "text": "What is in this image?"},
            ],
        }
    ],
)
print(response.output_text)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment