The table below summarizes gateway support for this endpoint by provider.
Legend:
✅ Supported by Provider and Truefoundry
Provided by provider, but not by Truefoundry
Provider does not support this feature
Provider
Edit
OpenAI
✅
Azure OpenAI
✅
Bedrock
✅
Vertex
✅
Anthropic
Cohere
Gemini
Groq
Together-AI
xAI
DeepInfra
For every gateway endpoint and provider, see Supported APIs.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.
OpenAI supports both gpt-image-1 (up to 16 images, PNG/WebP/JPG, <50MB) and dall-e-2 (1 square PNG image, <4MB). The meaning of the parameters are present in the OpenAI API documentation.
from openai import OpenAIBASE_URL = "{GATEWAY_BASE_URL}"API_KEY = "your-truefoundry-api-key"# Configure OpenAI client with TrueFoundry settingsclient = OpenAI( api_key=API_KEY, base_url=BASE_URL,)response = client.images.edit( model="openai-main/gpt-image-1", image=[ open("image1.png", "rb"), # First source image open("image2.png", "rb") # Second source image (up to 16 images supported) ], 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)
gpt-image-1 supports up to 16 images in PNG, WebP, or JPG format with a 50MB size limit per image. dall-e-2 requires a single square PNG image under 4MB.
Vertex AI (imagen-3.0-capability-001)
Vertex AI’s Imagen 3.0 model supports editing a single image in PNG or JPG format (max 20MB). The meaning of the parameters are present in the Google Vertex documentation.
from openai import OpenAIBASE_URL = "{GATEWAY_BASE_URL}"API_KEY = "your-truefoundry-api-key"# Configure OpenAI client with TrueFoundry settingsclient = OpenAI( api_key=API_KEY, base_url=BASE_URL,)response = client.images.edit( model="image-edit/imagen-3.0-capability-001", image=open("image.png", "rb"), # REQUIRED, source image prompt="Replace the background with a beach scene and add palm trees on both sides", # Optional mask=open("mask.png", "rb"), # REQUIRED n = 2, extra_body={ "maskMode": "MASK_MODE_BACKGROUND", "maskClasses": [162, 170], # ONLY if maskMode="MASK_MODE_SEMANTIC" "dilation": 0.01, "baseSteps": 35, "editMode": "EDIT_MODE_INPAINT_REMOVAL" }print(response.data[0].b64_json)
Vertex AI supports a single image in PNG or JPG format with a maximum size of 20MB.
AWS Bedrock (amazon-nova-canvas)
AWS Bedrock’s Nova Canvas model supports editing a single image in PNG or JPG format (max 5MB).
from openai import OpenAIBASE_URL = "{GATEWAY_BASE_URL}"API_KEY = "your-truefoundry-api-key"# Configure OpenAI client with TrueFoundry settingsclient = OpenAI( api_key=API_KEY, base_url=BASE_URL,)response = client.images.edit( model="tfy-ai-bedrock/amazon-nova-canvas" image=open("image.png", "rb"), # REQUIRED, source image prompt="Replace the background with a beach scene and add palm trees on both sides", # Mask image OR mask prompt is required, not both mask=open("mask.png", "rb") # Mask image to specify edit areas extra_body={ "taskType": "OUTPAINTING" # Optional: defaults to INPAINTING "maskPrompt": "Box in the center." # Required if mask image is not specified, should NOT be included if mask image is specified "negativeText": "dogs, cats" # Optional: A text prompt to define what not to include in the image. # If taskType=OUTPAINTING "outPaintingMode": "PRECISE" # Optional: DEFAULT | PRECISE # For VIRTUAL_TRY_ON, need to use curl request only })print(response.data[0].b64_json)
from openai import OpenAIBASE_URL = "{GATEWAY_BASE_URL}"API_KEY = "your-truefoundry-api-key"# Configure OpenAI client with TrueFoundry settingsclient = OpenAI( api_key=API_KEY, base_url=BASE_URL,)response = client.images.edit( model="tfy-ai-bedrock/stable-image-inpaint1", image=open("image.png", "rb"), # REQUIRED, source image prompt="Replace the background with a beach scene and add palm trees on both sides", # REQUIRED output_format="jpeg", # Optional mask=open(filePath, "rb"), # Optional extra_body={ "style_preset": "anime", # Optional "negative_prompt": "dogs", # Optional "seed": 42, # Optional "grow_mask": 7 # Optional }print(response.data[0].b64_json)
AWS Bedrock supports a single image in PNG or JPG format with a maximum size of 5MB.
Azure OpenAI (gpt-image-1)
Azure OpenAI’s gpt-image-1 model supports up to 16 images in PNG, WebP, or JPG format (max 50MB each). The meaning of the parameters are present in the Azure OpenAI documentation.
from openai import OpenAIBASE_URL = "{GATEWAY_BASE_URL}"API_KEY = "your-truefoundry-api-key"# Configure OpenAI client with TrueFoundry settingsclient = OpenAI( api_key=API_KEY, base_url=BASE_URL,)response = client.images.edit( model="azure-main/gpt-image-1", image=[ open("image1.png", "rb"), # First source image open("image2.png", "rb") # Second source image (up to 16 images supported) ], 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)
Azure OpenAI supports up to 16 images in PNG, WebP, or JPG format with a 50MB size limit per image.