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 Image Edit Partial Event

From Leeroopedia
Revision as of 13:38, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_python_Image_Edit_Partial_Event.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for representing a partial image during image editing streaming provided by the openai-python SDK.

Description

ImageEditPartialImageEvent is a Pydantic BaseModel emitted when a partial image is available during image editing streaming. It carries b64_json base64-encoded partial image data along with settings metadata: background, output_format, quality, and size. The partial_image_index field provides a 0-based index for ordering partial images during streaming. The type field is always "image_edit.partial_image".

Usage

Import ImageEditPartialImageEvent when processing streaming events from the image edit API to render progressive image updates before the final result arrives.

Code Reference

Source Location

Signature

class ImageEditPartialImageEvent(BaseModel):
    b64_json: str
    background: Literal["transparent", "opaque", "auto"]
    created_at: int
    output_format: Literal["png", "webp", "jpeg"]
    partial_image_index: int
    quality: Literal["low", "medium", "high", "auto"]
    size: Literal["1024x1024", "1024x1536", "1536x1024", "auto"]
    type: Literal["image_edit.partial_image"]

Import

from openai.types import ImageEditPartialImageEvent

I/O Contract

Fields

Name Type Required Description
b64_json str Yes Base64-encoded partial image data, suitable for rendering as an image.
background Literal["transparent", "opaque", "auto"] Yes The background setting for the requested edited image.
created_at int Yes Unix timestamp when the event was created.
output_format Literal["png", "webp", "jpeg"] Yes The output format for the requested edited image.
partial_image_index int Yes 0-based index for the partial image during streaming.
quality Literal["low", "medium", "high", "auto"] Yes The quality setting for the requested edited image.
size Literal["1024x1024", "1024x1536", "1536x1024", "auto"] Yes The size of the requested edited image.
type Literal["image_edit.partial_image"] Yes The event type. Always "image_edit.partial_image".

Usage Examples

from openai.types import ImageEditPartialImageEvent
import base64

# When processing streaming events from image edit
def handle_partial(event):
    if isinstance(event, ImageEditPartialImageEvent):
        print(f"Partial image #{event.partial_image_index}")
        print(f"Format: {event.output_format}, Size: {event.size}")
        # Render partial image for progressive display
        partial_data = base64.b64decode(event.b64_json)
        with open(f"partial_{event.partial_image_index}.png", "wb") as f:
            f.write(partial_data)

Related Pages

Page Connections

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