Closed
Description
The Feature
Hello @krrishdholakia , @ishaan-jaff !
I’d like to request support for the OpenAI Image Editing and Inpainting endpoint (/v1/images/edits) using the gpt-image-1
model. Below is a minimal Python example demonstrating a direct request to OpenAI:
import os
import requests
import base64
api_key = os.getenv("OPENAI_API_KEY")
url = "https://api.openai.com/v1/images/edits"
headers = {
"Authorization": f"Bearer {api_key}"
}
# Prepare the files for image editing/inpainting
files = [
("image[]", ("body-lotion.png", open("body-lotion.png", "rb"), "image/png")),
("image[]", ("bath-bomb.png", open("bath-bomb.png", "rb"), "image/png"))
]
data = {
"model": "gpt-image-1",
"prompt": "Create a lovely gift basket with these four items in it"
}
response = requests.post(url, headers=headers, files=files, data=data)
response.raise_for_status()
# Print the x-request-id
print("x-request-id:", response.headers.get("x-request-id"))
# Decode and save the returned image
result = response.json()
b64 = result["data"][0]["b64_json"]
img_bytes = base64.b64decode(b64)
with open("gift-basket.png", "wb") as img_file:
img_file.write(img_bytes)
print("Image saved as gift-basket.png")
OpenAI doc: https://platform.openai.com/docs/api-reference/images/createEdit
Related issues requesting the same endpoint:
Thank you for considering this enhancement!
Motivation, pitch
Adding support for the /v1/images/edits endpoint in Litellm would unlock these advanced editing and inpainting workflows directly in applications, keeping Litellm at the cutting edge of AI-powered creativity.
Are you a ML Ops Team?
No
Twitter / LinkedIn details
No response