AIAPIAIAPI API

GPT Image 2 Edit

Model ID openai/gpt-image-2/edit

Overview

Natural-language image editing from one to ten source images.

OpenAI · image-to-image

Endpoint

POST /v1/images/generations/async

Authentication

Authorization: Bearer <AIAPIAIAPI_API_KEY>

Request Body

ParameterTypeRequiredNullableDefaultConstraintsDescription
modelstringYesNo-values: openai/gpt-image-2/editModel ID used to route the request.
promptstringYesNo--Text prompt describing the desired output.
imagesarrayYesNo-min_items: 1; max_count: 10; accepts: URL, Base64 data URL1–10 source images to edit.
sizestringNoNo`1024x1024`-auto or WIDTHxHEIGHT; dimensions must be divisible by 16, aspect ratio between 1:3 and 3:1, maximum edge 3840 and maximum area 3840x2160 pixels. Resolutions above 2560x1440 are experimental.
output_formatstringNoNo`jpeg`values: jpeg, pngOutput file format.
qualitystringNoNo`medium`values: low, medium, highImage rendering quality tier.
moderationstringNoNo-values: lowOptional moderation setting shown in the provider's request examples.

model

Type: string · Required: Yes · Nullable: No

Model ID used to route the request.

prompt

Type: string · Required: Yes · Nullable: No

Text prompt describing the desired output.

images

Type: array · Required: Yes · Nullable: No

1–10 source images to edit.

size

Type: string · Required: No · Nullable: No

auto or WIDTHxHEIGHT; dimensions must be divisible by 16, aspect ratio between 1:3 and 3:1, maximum edge 3840 and maximum area 3840x2160 pixels. Resolutions above 2560x1440 are experimental.

output_format

Type: string · Required: No · Nullable: No

Output file format.

quality

Type: string · Required: No · Nullable: No

Image rendering quality tier.

moderation

Type: string · Required: No · Nullable: No

Optional moderation setting shown in the provider's request examples.

Request Example

curl --request POST \
  --url https://aiapiaiapi.com/v1/images/generations/async \
  --header 'Authorization: Bearer $AIAPIAIAPI_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
      "model": "openai/gpt-image-2/edit",
      "prompt": "A cinematic camera movement through a forest",
      "images": ["https://example.com/reference.jpg"]
    }'

JSON

{
  "model": "openai/gpt-image-2/edit",
  "prompt": "A cinematic camera movement through a forest",
  "images": ["https://example.com/reference.jpg"]
}

Response

{
  "code": "success",
  "message": "",
  "data": { "task_id": "image_01K2ABC123" }
}

Task Status

Use the task_id from the create response:

GET /v1/images/generations/async/{task_id}

{
  "code": "success",
  "message": "",
  "data": {
    "task_id": "image_01K2ABC123",
    "status": "SUCCESS",
    "progress": "100%",
    "outputs": ["https://cdn.example.com/images/image_01K2ABC123.png"],
    "start_time": 1786960805,
    "finish_time": 1786960900,
    "submit_time": 1786960800,
    "fail_reason": ""
  }
}

Error Responses

Validation errors return HTTP 400 with a stable error code.

{
  "code": "unsupported_parameter",
  "message": "The parameter is not supported by this model.",
  "data": null
}

Documentation Index

Fetch the complete documentation index at:

https://aiapiaiapi.com/llms.txt

Use this file to discover all available API documentation.