GPT Image 2 Image-to-Image
https://api.hiapi.ai /v1/tasks Submit a text-to-image or image-to-image task, then query it with GET /v1/tasks/:id.
Send model=gpt-image-2/image-to-image to POST /v1/tasks to edit images from 1–16 references. This reference covers input fields, route differences, callbacks, polling, and code examples.
Request parameters
Default route. Its canonical model ID is gpt-image-2/image-to-image. Pass 1–16 references in input_urls; price varies by resolution.
model string required Fixed value gpt-image-2/image-to-image.
route string optional Omit for the default route, or pass default explicitly.
input object required Business parameters for references and generation settings.
prompt string required Text prompt, up to 20000 characters.
input_urls string[] required Reference image URL array, 1 to 16 images. PNG, JPEG/JPG, and WebP are supported; SVG, GIF, BMP, and TIFF are not. Each image must be at most 20 megapixels and 30 MB, served from a publicly reachable, directly downloadable http(s) URL. Data URIs are also accepted.
aspect_ratio enum optional Generated image aspect ratio. Default auto.
resolution enum optional Image output resolution.
- Auto aspect ratio
- Only 1K when aspect ratio is auto or unspecified
- 2K unavailable
- 4K unavailable
background enum optional Background is supported only at 1K; omit this field for 2K/4K.
callback object optional Optional callback configuration. In production, pass callback.url so HiAPI can notify your service when the task reaches a terminal state.
url string required HTTPS URL that receives terminal task notifications.
when enum optional Callback trigger timing. Use final for terminal-state notifications.
The HiAPI ext multi-ratio 4K route resolves to the canonical model ID gpt-image-2/image-to-image@ext. Pass 1–6 references in image_urls; resolution and quality are required, and reference count participates in dynamic pricing. Prefer route: "ext" at the top level.
model string required Fixed value gpt-image-2/image-to-image, combined with route to select the ext route.
route string required Fixed value ext.
input object required Business parameters.
prompt string required Image edit instruction, up to 20000 characters.
image_urls string[] required Reference image URL array, 1 to 6 images; count participates in ext dynamic pricing. PNG, JPEG/JPG, and WebP are supported; SVG, GIF, and other formats are not. Each image must be at most 20 MB, and 20 megapixels or less is recommended. URLs must be publicly reachable and directly downloadable http(s) links; data URIs are also accepted. The ext field is image_urls, while Standard uses input_urls.
aspect_ratio enum optional Output aspect ratio; default auto follows the input image, an explicit value forces that ratio.
resolution enum required HiAPI ext route resolution tier: 1K, 2K, or 4K. Actual pixel dimensions vary by aspect ratio.
quality enum required Quality tier, affects pricing: low is clean and sharp for volume, medium adds visible detail, high is cinematic.
callback object optional Optional callback configuration. In production, pass callback.url so HiAPI can notify your service when the task reaches a terminal state.
url string required HTTPS URL that receives terminal task notifications.
when enum optional Callback trigger timing. Use final for terminal-state notifications.
Request example
Restyle a reference image into a clean product visual.
{
"model": "gpt-image-2/image-to-image",
"input": {
"prompt": "Keep the main subject and remove the background.",
"input_urls": [
"https://example.com/reference.png"
],
"aspect_ratio": "1:1",
"resolution": "1K",
"background": "transparent"
}
}Create the task, then wait for callback.url to receive the terminal notification.
{
"model": "gpt-image-2/image-to-image",
"route": "ext",
"input": {
"prompt": "Keep the product unchanged and replace the background with a premium studio set",
"image_urls": [
"https://example.com/reference.png"
],
"aspect_ratio": "4:5",
"resolution": "1K",
"quality": "medium"
}
}{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-..."
}
}Getting the result
- A successful submission returns data.taskId immediately without waiting for generation to finish.
- In production, prefer the top-level callback.url for terminal delivery. For local debugging, poll GET /v1/tasks/:id.
- On status=success, download data.output[].url and retain it before expireAt.
- For synchronous 4xx responses, fix authentication, balance, or schema errors. For asynchronous status=fail, log data.error and do not blindly retry invalid input.