The Image Edit API lets you modify images using text instructions. You can edit specific parts of an image, add new elements, or extend the image beyond its original boundaries. Just provide your source image and describe what changes you want to make.

Supported Providers

  • OpenAI: Supports dall-e-2 and gpt-image-1 models
  • Vertex AI: Supports imagen-3.0-generate-001 model
  • AWS Bedrock: Supports amazon-nova-canvas model
  • Azure OpenAI: Supports gpt-image-1 model

Requirements

ProviderModelFormatSize LimitImage Count
OpenAIgpt-image-1PNG, WebP, JPG< 50MBUp to 16 images
OpenAIdall-e-2Square PNG< 4MB1 image only
Vertex AIimagen-3.0-generate-001PNG, JPG< 20MBUp to 4 images
AWS Bedrockamazon-nova-canvasPNG, JPG< 5MBUp to 5 images
Azure OpenAIgpt-image-1PNG, WebP, JPG< 50MBUp to 16 images

Example Usage

from openai import OpenAI

BASE_URL = "https://{controlPlaneUrl}/api/llm"
API_KEY = "your-truefoundry-api-key"

# Configure OpenAI client with TrueFoundry settings
client = OpenAI(
    api_key=API_KEY,
    base_url=BASE_URL,
)

response = client.images.edit(
    model="openai-main/dall-e-2",
    image=[
        open("image1.png", "rb"),  # First source image
        open("image2.png", "rb")   # Second source image
    ],
    prompt="Replace the background with a beach scene and add palm trees on both sides",
    mask=open("mask.png", "rb")    # Optional mask to specify edit areas
)

print(response.data[0].url)

Response Format

The API returns an ImagesResponse object containing:
ImagesResponse(
    created=1755685741,
    data=[
        Image(
            url='https://oaidalleapiprodscus.blob.core.windows.net/private/org-ojH41IdW0UR2VlysxKUx8AjA/user-9QSCTtrOEHbbiQRFfFbwT8fx/img-PlwCalRpn4j5jQxG1wKvQYGc.png?st=2025-08-20T09%3A29%3A01Z&se=2025-08-20T11%3A29%3A01Z&sp=r&sv=2024-08-04&sr=b&rscd=inline&rsct=image/png&skoid=32836cae-d25f-4fe9-827b-1c8c59c442cc&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2025-08-20T10%3A01%3A35Z&ske=2025-08-21T10%3A01%3A35Z&sks=b&skv=2024-08-04&sig=g21zsMrRuM8aRjO5lLyVVwxZD7K4Ng1OoI7QZ5e8Y4Q%3D',
            b64_json=None,
            revised_prompt=None
        )
    ],
    background=None,
    output_format=None,
    quality=None,
    size=None,
    usage=None
)