Highest quality image generation with advanced understanding:
response = client.images.generate( prompt="A photorealistic cat wearing a space suit", model="openai/dall-e-3", size="1024x1024", # 1024x1024, 1792x1024, 1024x1792 quality="hd", # standard or hd style="vivid", # vivid or natural n=1 # Only n=1 supported)
Fast and cost-effective image generation:
response = client.images.generate( prompt="A digital art of a sunset", model="openai/dall-e-2", size="512x512", # 256x256, 512x512, or 1024x1024 n=4 # Generate multiple images)
Advanced model with fine control and transparency support:
response = client.images.generate( prompt="A logo design with transparent background", model="openai/gpt-image-1", size="auto", # auto, 1024x1024, 1536x1024, 1024x1536 quality="high", # low, medium, high background="transparent", # transparent, opaque, auto output_format="png", # png, jpeg, webp moderation="low" # low or auto)
Edit images using inpainting (DALL-E 2 and GPT Image):
from pathlib import Pathfrom dedalus_labs import Dedalusclient = Dedalus()response = client.images.edit( image=Path("original.png"), prompt="Add a red hat to the person", mask=Path("mask.png"), # Optional: transparent areas indicate what to change model="openai/dall-e-2", size="1024x1024", n=1)print(response.data[0].url)
Image editing requirements:
Images must be square PNG files
Less than 4MB in size
If mask is not provided, the image must have transparency (alpha channel)
response = client.images.generate( prompt="A coffee cup logo", model="openai/gpt-image-1", background="transparent", # transparent, opaque, or auto output_format="png" # Must use png or webp for transparency)
import requestsfrom pathlib import Pathfrom dedalus_labs import Dedalusclient = Dedalus()# Generate a high-quality imageresponse = client.images.generate( prompt="A professional photograph of a modern minimalist office space with natural lighting, plants, and ergonomic furniture", model="openai/dall-e-3", size="1792x1024", # Landscape quality="hd", style="natural", n=1)image_url = response.data[0].urlprint(f"Generated image URL: {image_url}")print(f"Revised prompt: {response.data[0].revised_prompt}")# Download and save the imageimage_data = requests.get(image_url).contentoutput_path = Path("office_space.png")output_path.write_bytes(image_data)print(f"Image saved to {output_path}")