Image Generations
Use CometAPI with OpenAI POST /v1/images/generations to create images from text prompts and follow the official image generation guide for model-specific controls.
Official reference
- Read the OpenAI image generation guide before you rely on model-specific controls such as
background,output_compression, streaming, or future GPT image options. - Use the OpenAI Create image reference for the current parameter list.
Choose a model first
- Use a GPT image model such as
gpt-image-2for text-to-image requests with controls likeoutput_format,quality, orbackground - Use
qwen-imagewhen you need that provider specifically, but keepnat 1 - Pick a current image model ID from the Models page
Safe first request
- Start with
gpt-image-2 - Keep
sizeat1024x1024 - GPT image models return base64-encoded image data in
b64_json; decode it to save the image file - Add
output_formatonly when you need a specific encoded image type such asjpeg - Check the OpenAI image generation guide before you add
background,output_compression, or streaming - Use one prompt and one output image before you add batch generation or style tuning
Model-specific request behavior
response_formatapplies 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, andoutput_compression - Follow the OpenAI image generation guide for the latest model-specific options
qwen-imagedoes not supportn > 1
Authorizations
Bearer token authentication. Use your CometAPI key.
Body
The image generation model to use. Choose a current model from the Models page.
Text description of the image you want to generate.
"A paper boat floating on calm water at sunrise."
Number of images to generate. Keep this at 1 for the broadest compatibility.
Quality setting for models that support it. See the OpenAI image generation guide for the latest model-specific values.
Requested output size. Supported values depend on the selected model. See the OpenAI image generation guide for the latest model-specific ranges.
"1024x1024"
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.
url, b64_json 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.
"jpeg"
Response
Image generation result.
Unix timestamp for the completed generation.
Background mode returned by models that expose it.
Encoded image type returned by GPT image models.
Quality level returned by models that expose it.
Output size returned by models that expose it.