Skip to content
OpenRelay is in early access, and the /v1 API is stable. New capabilities ship in the changelog.
Skip to Content
API ReferenceInferenceImages

Edit an image from a prompt

Edits an input image as a text prompt asks, in the OpenAI Images shape, and returns the result inline as base64. In preview for selected organizations. Call it with a model whose supported_apis on GET /v1/models include images_edits; the model's images block lists its sizes and limits. Send multipart/form-data with the image as a file part, as the OpenAI SDKs do, or application/json with the image as a base64 data URL. Input images are PNG, JPEG or WebP, at most 10 MiB each; a URL to fetch, a file id and a mask are refused with unsupported_value. With size auto or no size, the output takes the model's size nearest the input image's aspect ratio, read after the image's EXIF orientation is applied, so a portrait photo comes back portrait; the response's size names it. Sizes are a closed list per model: a size off it is refused with invalid_size. Never streams. Requires a funded balance. Billed on the output pixels delivered (usage.pixels) at the model's price per megapixel; input images are not billed. A request returns all n images or an error and bills nothing on an error, a content policy refusal included. The prompt, the input images and every output pass content checks that a request cannot adjust. The request body is capped at 16 MiB.

Required permission

Requires the inference.invoke permission. See Permissions for the roles and API key permissions that include it.

Command line

The orl CLI wraps this endpoint:

Guided workflow: orl images edit

orl images edit --image <image> --model <model> --prompt <prompt>
POST
/v1/images/edits

Authorization

apiKey
headerAuthorizationBearer <token>

OpenRelay API key. Send it as Authorization: Bearer or_… (legacy vl_… keys still work).

Request Body

  1. body

An OpenAI Images edits request as multipart/form-data, the form the OpenAI SDKs send. Every field of the JSON form is a form field of the same name and meaning, except the input images, which are file parts: one part named image, or one part named image[] per image. A mask part is refused with unsupported_value.

model*string

An OpenRelay public model id whose supported_apis include images_edits.

prompt*string

The edit to make, up to the model's prompt limit (prompt_too_long over it).

image?file

The input image, when there is one: a PNG, JPEG or WebP file of at most 10 MiB. Send this or image[], at least one image in all.

Formatbinary
image[]?array<>

The input images, one part each, 1 to the model's limit (too_many_images outside it). An error about one names it as images[i], counting from 0.

n?integer

Images to return, 1 to the model's limit (invalid_n outside it). Default 1. A request returns all n images or an error, never fewer.

Range1 <= value
size?string

auto, or one of the model's sizes as WxH (invalid_size otherwise). auto and absence take the model's size nearest the first input image's aspect ratio, read after the image's EXIF orientation is applied; the response's size names it.

response_format?"b64_json"

b64_json only; url is refused with unsupported_value.

Value in"b64_json"
output_format?ImageRequestOutputFormat

Encoding of each image. Default png.

Value in"png""jpeg""webp"
output_compression?ImageRequestOutputCompression

Compression for jpeg and webp; ignored for png.

Range0 <= value <= 100
seed?ImageRequestSeed

Seed of the first image; image i of the request uses seed + i, wrapping past 4294967295 to 0. The server picks one when absent. Each image's seed is returned in data.

Formatint64
Range0 <= value <= 4294967295
background?ImageRequestBackground

auto and opaque are accepted; transparent is refused with unsupported_value.

Value in"auto""opaque""transparent"
input_fidelity?ImageRequestInputFidelity

Accepted and ignored.

quality?ImageRequestQuality

Accepted and ignored: steps are fixed per model, so the price is known before the run.

moderation?ImageRequestModeration

Accepted and ignored: the content checks are not adjustable.

stream?ImageRequestStream

false or absent; true is refused with unsupported_value.

partial_images?ImageRequestPartialImages

0 or absent; any other value is refused with unsupported_value.

user?ImageRequestUser

Accepted, not forwarded and not stored.

safety_identifier?string

Accepted, not forwarded and not stored.

Response Body

OK

application/json
  1. response

An images response. Every image is inline base64.

created?integer

Unix timestamp (seconds) the images were made.

Formatint64
data?array<>

The images, n of them, in order.

output_format?string

The encoding of every image.

Value in"png""jpeg""webp"
size?string

The size every image was made at, WxH. For a request sent with size auto or none, the size it resolved to.

usage?

OpenRelay's own image usage: no token counts.

openrelay?

What the request is billed, on every online inference response.

Example Request
curl -X POST 'https://inference.openrelay.inc/v1/images/edits' \  -H 'Content-Type: application/json' \  -d '{  "model": "string",  "prompt": "string",  "images": [    {      "image_url": "string"    }  ]}'
Example Response
{  "created": 0,  "data": [    {      "b64_json": "string",      "seed": 0    }  ],  "output_format": "png",  "size": "string",  "usage": {    "images": 0,    "pixels": 0  },  "openrelay": {    "cost_nano_usd": 0,    "priced_at": "string"  }}