Skip to main content

Python class

GenerationOutput

GenerationOutput

class max.interfaces.GenerationOutput(*, request_id, final_status, output)

source

Bases: BaseModel

Output container for image generation pipeline operations.

This class holds a list of generated images in OpenResponses API format, along with request tracking and status information. It implements the PipelineOutput protocol by providing the required is_done property.

Example:

import numpy as np
from max.interfaces.generation import GenerationOutput
from max.interfaces.request import RequestID
from max.interfaces.request.open_responses import OutputImageContent
from max.interfaces.status import GenerationStatus

img_array1 = (np.random.rand(512, 512, 3) * 255).astype(np.uint8)
img_array2 = (np.random.rand(512, 512, 3) * 255).astype(np.uint8)

result = GenerationOutput(
    request_id=RequestID(value="req-123"),
    final_status=GenerationStatus.END_OF_SEQUENCE,
    output=[
        OutputImageContent.from_numpy(img_array1, format="png"),
        OutputImageContent.from_numpy(img_array2, format="jpeg"),
    ]
)

# Or create from URLs
result_from_urls = GenerationOutput(
    request_id=RequestID(value="req-456"),
    final_status=GenerationStatus.END_OF_SEQUENCE,
    output=[
        OutputImageContent(
            type="output_image",
            image_url="https://example.com/image1.png",
            format="png"
        )
    ]
)

# Check if generation is complete
if result.is_done:
    print(f"Generated {len(result.output)} images")

Parameters:

  • request_id (RequestID)
  • final_status (GenerationStatus)
  • output (list[Annotated[OutputTextContent | RefusalContent | ReasoningSummaryContent | OutputImageContent, FieldInfo(annotation=NoneType, required=True, discriminator='type')]])

final_status

final_status: GenerationStatus

source

The final status of the generation process.

is_done

property is_done: bool

source

Indicates whether the pipeline operation has completed.

Returns:

True if the generation is done (status is not ACTIVE), False otherwise.

model_config

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

source

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

output

output: list[OutputContent]

source

List of OutputContent objects (text, images, etc.) representing generated content.

request_id

request_id: RequestID

source

The unique identifier for the generation request.