Skip to main content
POST
Use this route to create images from text with OpenAI-compatible request shapes on CometAPI.

Official reference

Choose a model first

  • Use a GPT image model such as gpt-image-2 for text-to-image requests with controls like output_format, quality, or background
  • Use gpt-image-2.5-sunburst or gpt-image-2.5-flare when you need transparent backgrounds or the xhigh and max quality levels
  • Use qwen-image when you need that provider specifically, but keep n at 1
  • Pick a current image model ID from the Models page

Safe first request

  • Start with gpt-image-2
  • Keep size at 1024x1024
  • GPT image models return base64-encoded image data in b64_json; decode it to save the image file
  • Add output_format only when you need a specific encoded image type such as jpeg
  • Use one prompt and one output image before you add batch generation or style tuning

Run an async image task

Use async: true for long-running image jobs when your client prefers a submit-and-poll flow instead of holding one HTTP connection open. The create request returns data.task_id. Poll Retrieve an image generation task until data.status is success or failure. The async field is a CometAPI extension for this route, not an OpenAI parameter. OpenAI documents stream and partial_images for GPT image models. CometAPI asynchronous task mode returns JSON task metadata and uses polling. Use async task mode with these documented model IDs: gpt-image-2 and doubao-seedream-4-0-250828. For other image models, use synchronous generation or streaming unless async task support is documented for that model. When a request includes both async: true and stream: true, async task mode takes precedence. The create request returns JSON task metadata instead of an SSE stream.

Model-specific request behavior

  • response_format applies to DALL·E models only; GPT image models return base64 data and ignore it
  • GPT image models use GPT-only controls such as output_format, quality, background, and output_compression
  • quality accepts low, medium, high, and auto on GPT image models; gpt-image-2.5-sunburst and gpt-image-2.5-flare also accept xhigh and max
  • output_compression applies when output_format is webp or jpeg; it has no effect on png
  • partial_images applies only when stream is true
  • Follow the OpenAI image generation guide for the latest model-specific options
  • qwen-image does not support n > 1

Generate a transparent background

Set background to transparent to generate an isolated subject with no background fill. This is supported on gpt-image-2.5-sunburst and gpt-image-2.5-flare. Transparency needs an output format with an alpha channel. Set output_format to png or webp. JPEG has no alpha channel, so a transparent request with output_format: "jpeg" is rejected. The response returns base64 image data in b64_json with an alpha channel. Decode it to save the file:
Set background to opaque to force a solid background, or auto to let the model decide. The response echoes the applied value in the top-level background field.
Generated images must comply with provider usage policies. Do not send illegal, violent, pornographic, or copyright-infringing prompts.

Authorizations

Authorization
string
header
required

Bearer token authentication. Use your CometAPI key.

Body

application/json
model
string
default:gpt-image-2
required

The image generation model to use. Choose a current model from the Models page.

prompt
string
required

Text description of the image you want to generate.

Example:

"A paper boat floating on calm water at sunrise."

n
integer
default:1

Number of images to generate. Keep this at 1 for the broadest compatibility.

quality
string

Quality setting for models that support it. GPT image models accept low, medium, high, and auto. gpt-image-2.5-sunburst and gpt-image-2.5-flare also accept xhigh and max. dall-e-3 accepts standard and hd. See the OpenAI image generation guide for the latest model-specific values.

Example:

"low"

background
enum<string>

Background mode for the generated image. Set transparent to generate an isolated subject with no background fill; this requires output_format set to png or webp, and returns an error with jpeg. Set opaque for a solid background, or auto to let the model decide. Supported on gpt-image-2.5-sunburst and gpt-image-2.5-flare.

Available options:
transparent,
opaque,
auto
output_compression
integer
default:100

Compression level for the output image, from 0 to 100. Applies when output_format is webp or jpeg. Lower values produce smaller files with more compression artifacts.

Required range: 0 <= x <= 100
moderation
enum<string>
default:auto

Content moderation level for GPT image models. low is less restrictive; auto is the default.

Available options:
low,
auto
partial_images
integer

Number of partial images to emit while a streaming response is in progress, from 0 to 3. Each partial image arrives as an image_generation.partial_image event before the final image_generation.completed event. Applies when stream is true.

Required range: 0 <= x <= 3
size
string

Requested output size. Supported values depend on the selected model. See the OpenAI image generation guide for the latest model-specific ranges.

Example:

"1024x1024"

response_format
enum<string>

The response container for dall-e-2 and dall-e-3. This parameter is not supported for GPT image models, which return base64-encoded image data.

Available options:
url,
b64_json
output_format
string

The encoded image type for GPT image model results, such as png, jpeg, or webp. See the OpenAI image generation guide for current GPT image output controls.

Example:

"jpeg"

stream
boolean
default:false

Set this to true to receive server-sent image generation events instead of waiting for the completed JSON response. Streaming responses use text/event-stream and can include final events such as image_generation.completed. When stream and async are both true, async task mode takes precedence and the create request returns JSON instead of a streaming image response.

async
boolean
default:false

CometAPI asynchronous task mode. Set this to true to return immediately with data.task_id, then poll GET /v1/images/generations/{task_id} for the final image data. Documented model IDs for this mode: gpt-image-2 and doubao-seedream-4-0-250828. This is a CometAPI extension, not an OpenAI parameter. When async and stream are both true, async takes precedence and returns JSON task metadata instead of an SSE stream.

Response

Image generation result. Synchronous requests return completed image data. Async requests return a task response with data.task_id.

created
integer
required

Unix timestamp for the completed generation.

data
object[]
required
background
string

Background mode returned by models that expose it.

output_format
string

Encoded image type returned by GPT image models.

quality
string

Quality level returned by models that expose it.

size
string

Output size returned by models that expose it.

usage
object

Token usage details when returned by the selected model.

Last modified on September 11, 2026