GPT-1 Image Edit

openai-image-edit

OpenAI Image Edit lets you modify images by removing, adding, or changing parts. It uses AI to fill in the selected area naturally.

Fast Inference
REST API

Model Information

Response Time~40 sec
StatusActive
Version
0.0.1
Updated6 days ago

Prerequisites

  • Create an API Key from the Eachlabs Console
  • Install the required dependencies for your chosen language (e.g., requests for Python)

API Integration Steps

1. Create a Prediction

Send a POST request to create a new prediction. This will return a prediction ID that you'll use to check the result. The request should include your model inputs and API key.

import requests
import time
API_KEY = "YOUR_API_KEY" # Replace with your API key
HEADERS = {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
def create_prediction():
response = requests.post(
"https://api.eachlabs.ai/v1/prediction/",
headers=HEADERS,
json={
"model": "openai-image-edit",
"version": "0.0.1",
"input": {
"image_url_16": "your image url 15 here",
"image_url_15": "your image url 14 here",
"image_url_14": "your image url 13 here",
"image_url_13": "your image url 12 here",
"image_url_12": "your image url 11 here",
"image_url_11": "your image url 10 here",
"image_url_10": "your image url 9 here",
"image_url_9": "your image url 8 here",
"image_url_8": "your image url 7 here",
"image_url_7": "your image url 6 here",
"image_url_6": "your image url 5 here",
"image_url_5": "your image url 4 here",
"image_url_4": "your image url 3 here",
"image_url_3": "your image url 2 here",
"image_url_2": "your image url 1 here",
"mask_url": "your mask url here",
"image_url_1": "your image url here",
"image_size": "auto",
"background": "auto",
"quality": "auto",
"number_of_images": 1,
"prompt": "your prompt here"
},
"webhook_url": ""
}
)
prediction = response.json()
if prediction["status"] != "success":
raise Exception(f"Prediction failed: {prediction}")
return prediction["predictionID"]

2. Get Prediction Result

Poll the prediction endpoint with the prediction ID until the result is ready. The API uses long-polling, so you'll need to repeatedly check until you receive a success status.

def get_prediction(prediction_id):
while True:
result = requests.get(
f"https://api.eachlabs.ai/v1/prediction/{prediction_id}",
headers=HEADERS
).json()
if result["status"] == "success":
return result
elif result["status"] == "error":
raise Exception(f"Prediction failed: {result}")
time.sleep(1) # Wait before polling again

3. Complete Example

Here's a complete example that puts it all together, including error handling and result processing. This shows how to create a prediction and wait for the result in a production environment.

try:
# Create prediction
prediction_id = create_prediction()
print(f"Prediction created: {prediction_id}")
# Get result
result = get_prediction(prediction_id)
print(f"Output URL: {result['output']}")
print(f"Processing time: {result['metrics']['predict_time']}s")
except Exception as e:
print(f"Error: {e}")

Additional Information

  • The API uses a two-step process: create prediction and poll for results
  • Response time: ~40 seconds
  • Rate limit: 60 requests/minute
  • Concurrent requests: 10 maximum
  • Use long-polling to check prediction status until completion