IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python class

OutputImageContent

OutputImageContent​

class max.pipelines.request.OutputImageContent(*, type='output_image', image_url=None, image_data=None, format=None, detail=None)

source

Bases: BaseModel

Image content generated by the model in output messages.

Parameters:

detail​

detail: ImageDetail | None

source

format​

format: str | None

source

from_numpy()​

classmethod from_numpy(array, format='png', detail=None)

source

Create an OutputImageContent from a numpy array.

Converts a numpy array containing image data to base64-encoded format suitable for the OpenResponses API.

For example, create a simple red image and encode it as PNG:

import numpy as np

from max.pipelines.request.open_responses import OutputImageContent

img_array = np.zeros((100, 100, 3), dtype=np.uint8)
img_array[:, :, 0] = 255  # Set red channel to max
output = OutputImageContent.from_numpy(img_array, format="png")

Parameters:

  • array (ndarray[tuple[Any, ...], dtype[uint8]]) – A uint8 numpy array with values in [0, 255]. Expected shapes:
    • [H, W, C] for color images (C=3 for RGB, C=4 for RGBA)
    • [H, W] for grayscale images
  • format (str) – The image format to use for encoding (such as "png", "jpeg", or "webp"). Defaults to "png".
  • detail (ImageDetail | None) – Optional detail level for the generated image.

Returns:

An OutputImageContent instance with base64-encoded image data.

Raises:

Return type:

OutputImageContent

image_data​

image_data: str | None

source

image_url​

image_url: str | None

source

model_config​

model_config: ClassVar[ConfigDict] = {'frozen': True}

source

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type​

type: Literal['output_image']

source