Skip to main content
POST
Create image generation
gpt-image-2 is the DimiLinks image generation model. It supports text-to-image and image-to-image workflows, with up to nine reference images supplied through image_urls.
We recommend adding ?async=true. Synchronous mode waits for image generation to finish before returning and is more likely to be interrupted by a gateway or client timeout.

Request URL

Text-to-image example

Image-to-image example

Asynchronous response

After receiving task_id, call Retrieve image task to retrieve the result.

Synchronous response

Synchronous mode returns after the image is ready:

Result fields

data[].url is not always a public image URL. Support all three forms:
  • /p/img/...: a relative path. Prefix it with https://api-direct.dimilinks.com before displaying or downloading it. The path requires no Bearer token because the URL includes a signature and expiration time.
  • https://...: a complete image URL that can be requested or displayed directly.
  • data:image/...;base64,...: a Data URL containing the image itself. A webpage can use it directly as <img src>; a server-side script must decode the base64 before saving it as a file.

Parameters

Enable asynchronous mode

Any one of the following enables asynchronous mode:
  • Query parameter: ?async=true
  • Query parameter: ?wait_for_result=false
  • Request header: Prefer: respond-async
  • Request body: "wait_for_result": false

Reference-image format

We recommend image_urls:
The API also accepts reference_images, images, image, image_url, input_image, and input_images.

Reference-image limits

  • A request can include up to nine reference images.
  • Each reference image can be up to 20 MB.
  • HTTP(S) URLs, Data URLs, and raw base64 are supported.
  • Browser blob: URLs cannot be submitted directly. Upload the image to your server or convert it to a Data URL first.

Differences between resolution tiers

See the Pricing page in the console for current prices. Each resolution tier is priced independently.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

async
boolean

Set to true to submit an async image task.

wait_for_result
boolean

Set to false to submit an async image task.

Body

application/json
prompt
string
required
model
string
default:gpt-image-2
n
integer
default:1

1k resolution allows n=1 only; 2k and 4k allow up to 4.

Required range: 1 <= x <= 4
size
string
Examples:

"1:1"

"16:9"

"3840x2160"

resolution
enum<string>
Available options:
1k,
2k,
4k
output_format
string
Examples:

"png"

"jpeg"

"webp"

output_compression
integer
background
string
Examples:

"auto"

"transparent"

"opaque"

moderation
string
Examples:

"auto"

"low"

wait_for_result
boolean
image_urls
mask_url
string
response_format
string
Example:

"b64_json"

user
string

Response

Image generation result or async submission

task_id
string
required
Example:

"img_xxx"

data
object[]
required
Example:
created
integer
Example:

1777080000