Skip to main content

Overview

Generate images from text prompts. Pure image generation models only (DALL-E, GPT Image). For multimodal models like gemini-2.5-flash-image, use /v1/chat/completions.

Method Signature

client.images.generate(
    prompt: str,
    background: Optional[Literal["transparent", "opaque", "auto"]] = None,
    model: Optional[str] = None,
    moderation: Optional[Literal["low", "auto"]] = None,
    n: Optional[int] = None,
    output_compression: Optional[int] = None,
    output_format: Optional[Literal["png", "jpeg", "webp"]] = None,
    partial_images: Optional[int] = None,
    quality: Optional[Literal["auto", "high", "medium", "low", "hd", "standard"]] = None,
    response_format: Optional[Literal["url", "b64_json"]] = None,
    size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "1792x1024", "1024x1792", "auto"]] = None,
    stream: Optional[bool] = None,
    style: Optional[Literal["vivid", "natural"]] = None,
    user: Optional[str] = None,
) -> ImagesResponse

Parameters

prompt
string
required
A text description of the desired image(s). Maximum lengths:
  • gpt-image-1: 32000 characters
  • dall-e-2: 1000 characters
  • dall-e-3: 4000 characters
background
string
Set transparency for the background of generated images. Only supported for gpt-image-1.Options: transparent, opaque, or auto (default)If transparent, the output format must support transparency (png or webp).
model
string
The model to use for image generation:
  • openai/dall-e-2
  • openai/dall-e-3
  • openai/gpt-image-1
Defaults to openai/dall-e-2 unless a parameter specific to gpt-image-1 is used.
moderation
string
Content moderation level for gpt-image-1 images. Options: low (less restrictive) or auto (default).
n
integer
Number of images to generate (1-10). For dall-e-3, only n=1 is supported.
output_compression
integer
Compression level (0-100%) for generated images. Only supported for gpt-image-1 with webp or jpeg formats. Defaults to 100.
output_format
string
Format for generated images. Only supported for gpt-image-1. Options: png, jpeg, or webp.
partial_images
integer
Number of partial images to generate for streaming (0-3). When set to 0, a single image is sent in one streaming event.The final image may be sent before all partial images are generated.
quality
string
Image quality setting:
  • auto (default): Automatically select best quality for the model
  • high, medium, low: Supported for gpt-image-1
  • hd, standard: Supported for dall-e-3
  • standard: Only option for dall-e-2
response_format
string
Format for dall-e-2 and dall-e-3 images: url or b64_json. URLs are valid for 60 minutes.Not supported for gpt-image-1 which always returns base64-encoded images.
size
string
Size of generated images:
  • gpt-image-1: 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default)
  • dall-e-2: 256x256, 512x512, or 1024x1024
  • dall-e-3: 1024x1024, 1792x1024, or 1024x1792
stream
boolean
Generate image in streaming mode. Defaults to false. Only supported for gpt-image-1.
style
string
Style of generated images. Only supported for dall-e-3:
  • vivid: Hyper-real and dramatic images
  • natural: More natural, less hyper-real images
user
string
Unique identifier for your end-user, for monitoring and abuse detection.

Response

created
integer
Unix timestamp when the images were created.
data
array
List of generated images.

Example

import dedalus_labs

client = dedalus_labs.Client(api_key="your-api-key")

response = client.images.generate(
    prompt="A sunset over mountains in watercolor style",
    model="openai/dall-e-3",
    size="1024x1024",
    quality="hd",
    n=1
)

print(response.data[0].url)

Build docs developers (and LLMs) love