Edit Image (OpenAI)
Edit or remix images you supply with the OpenAI Images API request format, on every image model that accepts image input.
Edit, remix or restyle images you supply, using the OpenAI Images API
request format. Point the OpenAI SDK at https://api.aivene.com/v1 and
images.edit works unchanged, on every image model that accepts image
input.
POST /v1/images/editsThis endpoint is a compatibility layer over
POST /v1/images: the images you send
become input_references on the same call, so model support, billing and
the response are identical. The differences are in the request:
- Images are uploaded as files in a
multipart/form-databody (image), or listed by URL orfile_idin a JSON body (images). - The output shape is set with
size(WIDTHxHEIGHT), which is matched to one of the model's aspect ratios. There is noaspect_ratioorresolutionparameter here; usePOST /v1/imageswhen you need them. - At least one image is required. For text to image, use
POST /v1/images/generations.
Authentication
AuthorizationBearerrequiredAPI key as bearer token in the Authorization header. Create keys at
Manage API Keys.
Headers
Content-Typestringrequiredmultipart/form-data to upload image files, or application/json to
pass images by URL or file_id.
Body
modelstringrequiredImage model id from GET /v1/models. The model must list image in
architecture.input_modalities. Example: gpt-image-2,
gemini-3-pro-image.
promptstringrequiredThe instruction to apply to the images.
imagefile | file[]optionalMultipart only. The image file to edit. To send several, repeat the
field as image[] (the OpenAI SDKs do this when you pass a list). Send
image or images; at least one image is required.
imagesobject[]optionalJSON only. Images to edit, each { "image_url": "..." } or
{ "file_id": "..." }. image_url is an https:// or http:// URL or
a data: URL; file_id is an id from POST /v1/files.
nintegeroptionalDefault 1Number of images to generate, 1 to 10. A model with a lower limit
declares it in architecture.image_max_n (many only support 1).
sizestringoptionalDefault autoOutput shape as WIDTHxHEIGHT (for example 1024x1024 or 1536x1024),
or auto to leave it to the model. Any size whose ratio is in the
model's architecture.image_aspect_ratios is accepted, and the image is
generated at that aspect ratio. The pixel dimensions are the model's own
and can differ from the requested size; the response size reports
them. A ratio the model doesn't support returns 400 listing the
supported ones.
qualitystringoptionalHow much rendering effort the model spends. Declared per model in
architecture.image_qualities. auto leaves the choice to the model.
autolowmediumhighoutput_formatstringoptionalOutput image format. Declared per model in
architecture.image_output_formats; svg is for vector models.
pngjpegwebpsvgoutput_compressionintegeroptionalCompression level (0-100) for jpeg or webp output.
backgroundstringoptionalBackground of the output. Declared per model in
architecture.image_backgrounds. transparent needs png or webp.
auto leaves the choice to the model.
autotransparentopaqueresponse_formatstringoptionalOnly b64_json is accepted. url returns 400.
b64_jsonuserstringoptionalEnd-user identifier for abuse tracking.
Responses are always base64
Images come back as data[].b64_json, on every model. Leave
response_format unset or send b64_json.
Rejected, not ignored
These OpenAI parameters return 400 instead of being dropped, so a
request never silently produces something other than what you asked for:
mask, stream: true, response_format: "url", and any value other
than auto for moderation, style or input_fidelity.
The model catalogue decides
GET /v1/models reports each model's architecture.input_modalities,
max_input_references, image_aspect_ratios, image_qualities,
image_backgrounds, image_output_formats and image_max_n. A model
without image input, more images than max_input_references, or a
value outside those lists returns 400.
Response
idstringoptionalAivene-assigned response identifier (avn_...). Used across logs,
billing, and feedback.
createdintegeroptionalUnix timestamp (seconds) when the images were generated.
modelstringoptionalThe model id you sent in the request.
dataImage[]optionalArray of generated images. Each contains b64_json, plus
revised_prompt if the model rewrote your prompt.
sizestringoptionalPixel dimensions of the result, when the model reports them.
usageobjectoptionalToken usage (input_tokens, output_tokens, total_tokens, plus
input_tokens_details/output_tokens_details image vs. text
breakdowns) for token-billed models. When the model hits its prompt
cache, input_tokens_details also carries cached_tokens (and
cache_write_tokens where the model bills cache writes), counted inside
input_tokens. Models billed per image report all-zero usage plus an
image_count.
Errors
All errors share one shape:
{ "error": { "message": "...", "type": "invalid_request_error" } }| Status | error.type | Meaning |
|---|---|---|
400 | validation_error | The body failed schema validation. The message names the offending field. |
400 | invalid_request_error | No image sent, an image that can't be read or fetched, an invalid file_id, unknown model, a model not available on this endpoint or without image input, too many images for the model, a size or other value the model does not support, a rejected parameter (see above), or a content policy rejection. |
401 | authentication_error | Missing or invalid API key. |
402 | invalid_request_error | Not enough credit for the request, an unpaid balance, or a spend limit was reached. |
403 | permission_denied_error | The account is suspended, an Admin key was used, or the model isn't included in your organization's tier. |
404 | not_found_error | The model is deprecated. The message names its replacement. |
408 | timeout_error | The model did not finish before the request timed out. |
429 | rate_limit_error | Your organization hit its rate limit for this model. Back off and retry. |
500 | internal_server_error | Unexpected server error. |
502 / 503 | upstream_error | The model is temporarily unavailable. Safe to retry. |
When the model itself rejects a request, the response keeps the model's
4xx status with type upstream_error or invalid_request_error, and
error.code names the cause when it is known (context_length_exceeded,
content_filter, request_too_large).