Create Image
Creates an image given a prompt using a GPT Image model.
Endpoint
POST /v1/images/generationsNote
This endpoint supports text-to-image generation only and does not accept reference images (any image parameters in the request will be ignored). To generate or edit images based on reference images, use the Edit Image endpoint POST /v1/images/edits.
Authentication
| Type | Description |
|---|---|
| Bearer Token | Include Authorization: Bearer <API_key> in the request header for account verification. |
Request Headers
| Name | Type | Required | Description |
|---|---|---|---|
Content-Type | string | Yes | Set request media type to application/json |
Authorization | string | Yes | Bearer API_key, used for account verification |
Request Body
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | - | The GPT image model to use for image generation; must be specified explicitly. See "Supported Model IDs" below |
prompt | string | Yes | - | A text description of the desired image(s), up to 32000 characters |
background | string | No | auto | Background of the generated image(s): transparent, opaque, or auto. See Parameter Details below |
moderation | string | No | auto | Content-moderation level: low (less restrictive) or auto. Only supported for GPT image models |
n | integer | No | 1 | Number of images to generate, between 1 and 10 |
output_compression | integer | No | 100 | Compression level (0-100%), only for GPT image models with webp or jpeg output formats |
output_format | string | No | png | Format of the returned images: png, jpeg, or webp. Only supported for GPT image models |
partial_images | integer | No | 0 | Number of partial images in streaming responses, 0-3; when 0, a single image is sent in one streaming event |
quality | string | No | auto | Quality of the generated image. See Parameter Details below |
response_format | string | No | - | Legacy parameter for retired image models. Unsupported for GPT image models (always return base64-encoded images) |
safety_identifier | string | No | - | A stable end-user identifier for safety monitoring, max 128 characters. See Parameter Details below |
size | string | No | auto | Size of the generated images. See Parameter Details below |
stream | boolean | No | false | Whether to generate the image in streaming mode. Only supported for GPT image models |
style | string | No | - | Legacy parameter for retired image models. Unsupported for GPT image models; describe the desired style in the prompt instead |
user | string | No | - | Deprecated: use safety_identifier instead. Used when safety_identifier is omitted, null, or empty |
Supported Model IDs:
gp-im-1.5gp-im-2gp-im-2-2026-04-21gp-im-2.5-sugp-im-2.5-su-2026-09-08gp-im-2.5-flgp-im-2.5-fl-2026-09-08gp-im-1-minigp-im-1(shut down on October 23, 2026; usegp-im-2.5-suorgp-im-2.5-flinstead)dall-e-2dall-e-3
Parameter Details
background
This parameter is only supported for the GPT image models. When auto is used, the model will automatically determine the best background for the image.
gp-im-2.5-su and gp-im-2.5-fl, including their 2026-09-08 snapshots, support opaque and transparent backgrounds. For gp-im-2 and gp-im-2-2026-04-21, transparent background support is in preview. When using transparent, set output_format to png or webp.
quality Enum Values
auto: automatically selects the best quality for the given model (default)low/medium/high: supported for the GPT image modelsxhigh/max: only supported forgp-im-2.5-suandgp-im-2.5-fl, including their2026-09-08snapshotsstandard/hd: legacy enum values for retired image models
size
For gp-im-2, gp-im-2-2026-04-21, gp-im-2.5-su, gp-im-2.5-su-2026-09-08, gp-im-2.5-fl, and gp-im-2.5-fl-2026-09-08, arbitrary resolutions are supported as WIDTHxHEIGHT strings, for example 1536x864. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above 2560x1440 are experimental, and the maximum supported resolution is 3840x2160. The requested size must also satisfy the model's current pixel and edge limits.
Standard sizes: 1024x1024, 1536x1024, 1024x1536; auto is supported for models that allow automatic sizing. Legacy enum values: 256x256, 512x512, 1792x1024, 1024x1792.
safety_identifier
A stable identifier for an end user in your organization, used for safety monitoring and abuse detection. Hash a username or email address to avoid sending identifying information. A non-empty value takes precedence over the deprecated user parameter. If omitted, null, or empty, the API uses user when available.
Example Request
curl --request POST \
--url https://neolink.com/api/v1/images/generations \
--header 'Authorization: Bearer <API Key>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gp-im-2",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}'curl --request POST \
--url https://neolink.com/api/v1/images/generations \
--header 'Authorization: Bearer <API Key>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gp-im-2",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024",
"stream": true
}'curl --request POST \
--url https://neolink.com/api/v1/images/generations \
--header 'Authorization: Bearer <API Key>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gp-im-2.5-fl",
"prompt": "A cute baby sea otter",
"background": "transparent",
"moderation": "low",
"n": 1,
"output_compression": 100,
"output_format": "png",
"partial_images": 1,
"quality": "medium",
"safety_identifier": "user-1234",
"size": "1024x1024"
}'Response Body
| Name | Type | Description |
|---|---|---|
created | integer | The Unix timestamp (in seconds) of when the image was created |
background | string | The background parameter used: transparent or opaque |
data | array | The list of generated images |
data.b64_json | string | The base64-encoded JSON of the generated image, returned by default for GPT image models |
data.revised_prompt | string | The revised prompt used to generate the image, for models that support prompt revision. Not returned by GPT image models |
data.url | string | The URL of the generated image (returned when the legacy response_format is url). Unsupported for GPT image models |
output_format | string | The output format: png, webp, or jpeg |
quality | string | The quality of the image: low, medium, high, xhigh, or max |
safety_identifier | string | The effective safety identifier: the non-empty safety_identifier from the request, or the deprecated user value when it is omitted, null, or empty |
size | string | The image dimensions as a WIDTHxHEIGHT string, for example 1536x864 |
usage | object | Token usage information, for gp-im-1 only |
usage.input_tokens | integer | The number of tokens (images and text) in the input prompt |
usage.input_tokens_details.image_tokens | integer | The number of image tokens in the input prompt |
usage.input_tokens_details.text_tokens | integer | The number of text tokens in the input prompt |
usage.output_tokens | integer | The number of output tokens generated by the model |
usage.total_tokens | integer | The total number of tokens (images and text) used for the image generation |
usage.output_tokens_details.image_tokens | integer | The number of image output tokens generated by the model |
usage.output_tokens_details.text_tokens | integer | The number of text output tokens generated by the model |
Response Example
{
"created": 1713833628,
"data": [
{
"b64_json": "..."
}
],
"usage": {
"total_tokens": 100,
"input_tokens": 50,
"output_tokens": 50,
"input_tokens_details": {
"text_tokens": 10,
"image_tokens": 40
}
}
}Streaming Response
When stream: true is set, the response is returned as an SSE event stream with the following events:
image_generation.partial_image: a partial image, withpartial_image_indexindicating its index; the final image may be sent before the full number ofpartial_imagesis reached if it is generated more quicklyimage_generation.completed: the final full image with token usage
event: image_generation.partial_image
data: {"type":"image_generation.partial_image","b64_json":"...","partial_image_index":0}
event: image_generation.completed
data: {"type":"image_generation.completed","b64_json":"...","usage":{"total_tokens":100,"input_tokens":50,"output_tokens":50,"input_tokens_details":{"text_tokens":10,"image_tokens":40}}}