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/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)