Skip to content

[Feature]: Add support for OpenAI Image Editing & Inpainting endpoint (/v1/images/edits) - New model gpt-image-1 #10314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mvrodrig opened this issue Apr 25, 2025 · 3 comments
Labels
april 2025 enhancement New feature or request

Comments

@mvrodrig
Copy link

mvrodrig commented Apr 25, 2025

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

@mvrodrig mvrodrig added the enhancement New feature or request label Apr 25, 2025
@ishaan-jaff
Copy link
Contributor

This is reasonable and looks highly requested. I'm aiming to have this ready by next week.

@krrishdholakia
Copy link
Contributor

krrishdholakia commented Apr 25, 2025

should we also support this for gemini (since it has image input + output too)

@marty-sullivan
Copy link
Contributor

+1, it would be great to have support for this & token cost tracking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
april 2025 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants