Bir image oluştur
OpenAI uyumlu image modelleri ve modele özgü kontrollerle image oluşturmak için CometAPI POST /v1/images/generations kullanın.
Resmi referans
background,output_compression, streaming veya gelecekteki GPT image seçenekleri gibi modele özgü kontrollere güvenmeden önce OpenAI image generation rehberini okuyun.- Güncel parametre listesi için OpenAI Create image referansını kullanın.
Önce bir model seçin
output_format,qualityveyabackgroundgibi kontrollerle text-to-image istekleri içingpt-image-2gibi bir GPT image modeli kullanın- Özellikle o sağlayıcıya ihtiyacınız olduğunda
qwen-imagekullanın, ancakndeğerini 1 olarak tutun - Models sayfasından güncel bir image model ID seçin
Güvenli ilk istek
gpt-image-2ile başlayınsizedeğerini1024x1024olarak tutun- GPT image modelleri image verisini
b64_jsoniçinde base64 kodlu olarak döndürür; image dosyasını kaydetmek için bunu decode edin output_formatalanını yalnızcajpeggibi belirli bir kodlanmış image türüne ihtiyacınız olduğunda ekleyinbackground,output_compressionveya streaming eklemeden önce OpenAI image generation rehberini kontrol edin- Batch generation veya stil ayarına geçmeden önce tek bir prompt ve tek bir çıktı image kullanın
Async bir image görevi çalıştırın
İstemciniz tek bir HTTP bağlantısını açık tutmak yerine gönder-ve-sorgula akışını tercih ettiğinde, uzun süren image işleri içinasync: true kullanın. Oluşturma isteği data.task_id döndürür.
data.status değeri success veya failure olana kadar Bir image generation görevini getir uç noktasını sorgulayın.
async alanı bu rota için bir CometAPI uzantısıdır, OpenAI parametresi değildir. OpenAI, GPT image modelleri için stream ve partial_images alanlarını belgeler. CometAPI asynchronous task modu JSON görev metadatası döndürür ve polling kullanır.
Async task modunu şu belgelenmiş model ID’lerle kullanın: gpt-image-2 ve doubao-seedream-4-0-250828. Diğer image modelleri için, o model için async task desteği belgelenmedikçe synchronous generation veya streaming kullanın.
Bir istek hem async: true hem de stream: true içerdiğinde, async task modu öncelikli olur. Oluşturma isteği SSE stream yerine JSON görev metadatası döndürür.
Modele özgü istek davranışı
response_formatyalnızca DALL·E modelleri için geçerlidir; GPT image modelleri base64 veri döndürür ve bunu yok sayar- GPT image modelleri
output_format,quality,backgroundveoutput_compressiongibi yalnızca GPT’ye özgü kontroller kullanır - En güncel modele özgü seçenekler için OpenAI image generation rehberini izleyin
qwen-image,n > 1desteklemez
Yetkilendirmeler
Bearer token authentication. Use your CometAPI key.
Gövde
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"
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.
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.
Yanıt
Image generation result. Synchronous requests return completed image data. Async requests return a task response with data.task_id.
- Completed image response
- Async task response
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.
Token usage details when returned by the selected model.