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 Create Variation Params

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

Overview

Concrete tool for defining parameters when creating image variations provided by the openai-python SDK.

Description

ImageCreateVariationParams is a TypedDict that specifies the parameters for generating variations of a given image. The only required field is image, which must be a valid PNG file under 4MB and square. Optional fields control the model (only dall-e-2 supported), n (number of variations, 1-10), response_format (URL or base64), size (256x256, 512x512, or 1024x1024), and user (end-user identifier for abuse monitoring).

Usage

Import ImageCreateVariationParams when you need to type-annotate or construct parameters for client.images.create_variation().

Code Reference

Source Location

Signature

class ImageCreateVariationParams(TypedDict, total=False):
    image: Required[FileTypes]
    model: Union[str, ImageModel, None]
    n: Optional[int]
    response_format: Optional[Literal["url", "b64_json"]]
    size: Optional[Literal["256x256", "512x512", "1024x1024"]]
    user: str

Import

from openai.types import ImageCreateVariationParams

I/O Contract

Fields

Name Type Required Description
image FileTypes Yes The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
model Union[str, ImageModel, None] No The model to use for image generation. Only dall-e-2 is supported.
n Optional[int] No Number of images to generate. Must be between 1 and 10.
response_format Optional[Literal["url", "b64_json"]] No Format of returned images. URLs are valid for 60 minutes after generation.
size Optional[Literal["256x256", "512x512", "1024x1024"]] No The size of the generated images.
user str No Unique identifier for end-user, used by OpenAI to monitor and detect abuse.

Usage Examples

from openai import OpenAI

client = OpenAI()

# Create image variations
response = client.images.create_variation(
    image=open("original.png", "rb"),
    n=3,
    size="512x512",
    response_format="url",
)

for img in response.data:
    print(img.url)

Related Pages

Page Connections

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