Skip to main content

Image editing

Image editing allows you to modify an existing image using a text prompt. The extension supports image editing through providers that expose an OpenAI-compatible /images/edits endpoint.

Supported providers

ProviderEditing support
OpenAIYes
GeminiYes
Cloud TempleYes
Azure OpenAINo
Grok (X-AI)No
LumaNo
HiveNo

Plugin configuration

Add the Cloud APIM - Image edition backend plugin to your route:

{
"enabled": true,
"plugin": "cp:otoroshi_plugins.com.cloud.apim.otoroshi.extensions.aigateway.plugins.OpenAICompatImagesEdit",
"config": {
"refs": ["image-model-entity-id"],
"max_size_upload": 104857600
}
}
ParameterTypeDefaultDescription
refsarray[]List of Image Model entity IDs (must support editing)
max_size_uploadnumber104857600 (100MB)Maximum upload file size in bytes

API

The editing endpoint accepts multipart form data:

curl --request POST \
--url http://myroute.oto.tools:8080/v1/images/edits \
--header 'content-type: multipart/form-data' \
-F "image=@photo.png" \
-F "prompt=add a red hat to the person" \
-F "model=gpt-image-1" \
-F "n=1" \
-F "size=1024x1024"

Parameters

ParameterTypeDescription
imagefileThe image to edit (uploaded as multipart file)
promptstringA text description of the desired edit
modelstringModel name (can include provider prefix)
nintegerNumber of images to generate
sizestringImage dimensions (e.g., 1024x1024)
qualitystringImage quality (standard, hd)
backgroundstringBackground setting
response_formatstringurl or b64_json

Response

{
"created": 1762441013,
"data": [
{
"url": "https://...",
"b64_json": null,
"revised_prompt": null
}
]
}

Entity configuration

To enable editing on a provider, set edition.enabled to true in the entity options:

{
"provider": "openai",
"config": {
"connection": {
"base_url": "https://api.openai.com/v1",
"token": "sk-xxx",
"timeout": 180000
},
"options": {
"generation": {
"enabled": true,
"model": "gpt-image-1"
},
"edition": {
"enabled": true,
"model": "gpt-image-1",
"n": 1,
"quality": "hd",
"size": "1024x1024"
}
}
}
}