/images/edits
Edit images using AI models. Supports both single and multiple image editing.
| Feature | Supported | Notes |
|---|---|---|
| Cost Tracking | ✅ | Works with all supported models |
| Logging | ✅ | Works across all integrations |
| Fallbacks | ✅ | Works between supported models |
| Loadbalancing | ✅ | Works between supported models |
| Supported Providers | OpenAI, Gemini (Google AI Studio), Vertex AI, Stability AI, AWS Bedrock (Stability) |
Quick Start
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.images.edit(
model="openai/gpt-image-1",
image=open("original_image.png", "rb"),
prompt="Add a red hat to the person in the image",
n=1,
size="1024x1024"
)
print(response.data[0].url)
cURL
curl https://api.haimaker.ai/v1/images/edits \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=openai/gpt-image-1" \
-F "image=@original_image.png" \
-F "prompt=Add a beautiful sunset in the background" \
-F "n=1" \
-F "size=1024x1024"
Image Edit with Mask
Use a mask to specify which areas of the image should be edited:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.images.edit(
model="openai/gpt-image-1",
image=open("original_image.png", "rb"),
mask=open("mask_image.png", "rb"), # Transparent areas will be edited
prompt="Replace the background with a beach scene",
n=1,
size="1024x1024"
)
print(response.data[0].url)
Using Different Models
OpenAI GPT-Image-1
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.images.edit(
model="openai/gpt-image-1",
image=open("portrait.png", "rb"),
prompt="Add sunglasses and a smile",
n=1,
size="1024x1024"
)
print(response.data[0].url)
Gemini
import base64
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.images.edit(
model="gemini/gemini-2.5-flash-image",
image=open("original_image.png", "rb"),
prompt="Add aurora borealis to the night sky",
size="1792x1024"
)
# Gemini returns base64-encoded images
edited_image_bytes = base64.b64decode(response.data[0].b64_json)
with open("edited_image.png", "wb") as f:
f.write(edited_image_bytes)
Vertex AI
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.images.edit(
model="vertex_ai/imagen-3.0-capability-001",
image=open("original_image.png", "rb"),
mask=open("mask_image.png", "rb"),
prompt="Turn this into watercolor style scenery",
n=2,
size="1024x1024"
)
for i, image_data in enumerate(response.data):
print(f"Image {i+1}: {image_data.url}")
Input Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
image | file | The image to edit. Must be a valid PNG file, less than 4MB, and square. | Yes |
prompt | string | A text description of the desired image edit. | Yes |
model | string | The model to use for image editing. | No (defaults to dall-e-2) |
mask | file | An additional image whose fully transparent areas indicate where the original image should be edited. | No |
n | integer | The number of images to generate. Must be between 1 and 10. | No (defaults to 1) |
size | string | The size of the generated images. | No (defaults to 1024x1024) |
response_format | string | The format in which images are returned (url or b64_json). | No (defaults to url) |
user | string | A unique identifier representing your end-user. | No |
Response Format
{
"created": 1677649800,
"data": [
{
"url": "https://example.com/edited_image_1.png"
}
]
}
For b64_json format:
{
"created": 1677649800,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}