Edit and transform images using text prompts via TrueFoundry AI Gateway
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.
from openai import OpenAIBASE_URL = "https://{controlPlaneUrl}/api/llm"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 ], 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)