Skip to content
English

GPT Image 2 Image-to-Image

POST Base URL: 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–6 references. This reference covers input fields, route differences, callbacks, polling, and code examples.

Request parameters

Route

Default route. Its canonical model ID is gpt-image-2/image-to-image. Pass 1–6 references in input_urls; price varies by resolution.

model string required

Fixed value gpt-image-2/image-to-image.

example gpt-image-2/image-to-image
route string optional

Omit for the default route, or pass default explicitly.

example default
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. Pass at least 1 and at most 6 images.

aspect_ratio enum optional

Generated image aspect ratio. Default auto.

default auto enum: auto1:13:22:34:33:45:44:516:99:16 +6
resolution enum optional

Image output resolution.

Auto aspect ratio
Only 1K when aspect ratio is auto or unspecified
2K unavailable
5:44:53:11:39:21
4K unavailable
1:13:11:39:21
default 1K enum: 1K2K4K
background enum optional

Background is supported only at 1K; omit this field for 2K/4K.

enum: autoopaquetransparent
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.

example https://your-domain.com/hiapi/callback
when enum optional

Callback trigger timing. Use final for terminal-state notifications.

default final enum: final

Request example

Productize a reference

Restyle a reference image into a clean product visual.

Request body
{
  "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"
  }
}
Success response

Response body
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "tk-hiapi-..."
  }
}

Getting the result

  1. A successful submission returns data.taskId immediately without waiting for generation to finish.
  2. In production, prefer the top-level callback.url for terminal delivery. For local debugging, poll GET /v1/tasks/:id.
  3. On status=success, download data.output[].url and retain it before expireAt.
  4. For synchronous 4xx responses, fix authentication, balance, or schema errors. For asynchronous status=fail, log data.error and do not blindly retry invalid input.