Skip to content
API Reference

Image to Image (Edits)

SIRAYA Model Router provides a unified API for image editing and transformation. This interface allows you to modify existing images or combine multiple images using natural language prompts.

Parameters below are the ones shared across editing models. For the full, model-specific parameter set of the GPT Image family, see GPT Image (Edits).

Editing models on /v1/images/generations

Qwen Image Edit (qwen-image-edit-spicy) and Face Swap & Head Swap (face-swap, head-swap) take their input images on POST /v1/images/generations, not on this endpoint — see their pages.

POST https://llm.siraya.ai/v1/images/edits
Authorization string Required
Your API Key (e.g., Bearer <API_KEY>).

Body

model string Required
The ID of the image editing model (e.g., gpt-image-2, gpt-image-2.5-flare).
prompt string Required
Instructions for the edit or transformation.
image_urls array Required
A list of input image URLs or base64 data URLs for editing or reference.
mask_url string
A mask URL or base64 data URL marking the region to edit. For GPT Image models it must be an RGBA PNG (with an alpha channel) of the same size as the input image; transparent pixels mark the region to edit.
n integer Default: 1
The number of images to generate.
output_format string Default: png
The encoding of the returned image (png or jpeg).
curl https://llm.siraya.ai/v1/images/edits \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <API_KEY>" \
  --data-raw '{
    "model": "gpt-image-2",
    "prompt": "Replace the first image with the same style as the second image.",
    "image_urls": [
        "https://example.com/your-image-1.png",
        "https://example.com/your-image-2.png"
    ],
    "n": 1
}'
import requests

url = "https://llm.siraya.ai/v1/images/edits"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API_KEY>"
}
data = {
    "model": "gpt-image-2",
    "prompt": "Apply the style of the reference image.",
    "image_urls": [
        "https://example.com/your-image-1.png",
        "https://example.com/your-image-2.png"
    ]
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

Example Response

{
    "created": 1774716098,
    "data": [
        {
            "b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAAAAg3..."
        }
    ]
}

Image Inputs

The edits endpoint takes images as references, not file uploads — they travel in the application/json body, in image_urls (and mask_url for a mask). Every entry accepts either form:

Form Value When to use
Public URL https://example.com/photo.png The image is already hosted; the router fetches it.
Base64 data URL data:image/png;base64,<BASE64> The image is a local file.

A data URL is the MIME type plus the base64-encoded bytes — e.g. data:image/png;base64,iVBORw0KGgoAAAANSUhEU... or data:image/jpeg;base64,/9j/4AAQSkZJRg.... Raw base64 without the data: prefix is not accepted.

Sending a local file as base64

import base64
import requests

def to_data_url(path, mime="image/png"):
    with open(path, "rb") as f:
        return f"data:{mime};base64," + base64.b64encode(f.read()).decode()

response = requests.post(
    "https://llm.siraya.ai/v1/images/edits",
    headers={
        "Content-Type": "application/json",
        "Authorization": "Bearer <API_KEY>"
    },
    json={
        "model": "gpt-image-2",
        "prompt": "Apply the style of the reference image.",
        "image_urls": [to_data_url("base_image.png")]
    },
)

print(response.json())

Base64 grows the payload by roughly a third, so prefer URLs for large images or when sending many inputs at once.

Visit the Models Directory to see all supported image-to-image models.