Görüntü oluşturun
OpenAI uyumlu görüntü modelleri ve modele özgü denetimlerle görüntü oluşturmak için CometAPI POST /v1/images/generations kullanın.
Resmî referans
- Şunu okuyun: OpenAI görüntü oluşturma kılavuzu
background,output_compression, streaming veya gelecekteki GPT görüntü seçenekleri gibi modele özgü denetimlere güvenmeden önce. - Güncel parametre listesi için OpenAI Create image referansını kullanın.
Önce bir model seçin
gpt-image-2gibi bir GPT görüntü modelini,output_format,qualityveyabackgroundgibi denetimlerle metinden görüntü istekleri için kullanın- Şeffaf arka planlara ya da
gpt-image-2.5-sunburstvegpt-image-2.5-flarekalite düzeylerine ihtiyacınız olduğundaxhighveyamaxkullanın - Özellikle o sağlayıcıya ihtiyacınız olduğunda
qwen-imagekullanın, ancakndeğerini 1 olarak tutun - Şuradan güncel bir görüntü modeli kimliği seçin: Models sayfası
Güvenli ilk istek
gpt-image-2ile başlayınsizedeğerini1024x1024olarak tutun- GPT görüntü modelleri, base64 ile kodlanmış görüntü verilerini
b64_jsoniçinde döndürür; görüntü dosyasını kaydetmek için kodunu çözün - Yalnızca
output_formatgibi belirli bir kodlanmış görüntü türüne ihtiyacınız olduğundajpegekleyin - Toplu oluşturma veya stil ayarlaması eklemeden önce tek bir Prompt ve tek bir çıktı görüntüsü kullanın
Eşzamansız bir görüntü görevi çalıştırın
İstemciniz tek bir HTTP bağlantısını açık tutmak yerine gönderip yoklama akışını tercih ettiğinde, uzun süren görüntü işleri içinasync: true kullanın. Oluşturma isteği data.task_id döndürür.
Yoklayın Bir görüntü oluşturma görevini alın data.status, success veya failure olana kadar.
async alanı, OpenAI parametresi değil, bu rota için bir CometAPI uzantısıdır. OpenAI, GPT görüntü modelleri için stream ve partial_images belgelerini sağlar. CometAPI eşzamansız görev modu JSON görev meta verileri döndürür ve yoklama kullanır.
Belgelendirilmiş şu model kimlikleriyle eşzamansız görev modunu kullanın: gpt-image-2 ve doubao-seedream-4-0-250828. Diğer görüntü modelleri için, o model için eşzamansız görev desteği belgelenmedikçe eşzamanlı oluşturma veya streaming kullanın.
Bir istek hem async: true hem de stream: true içerdiğinde, eşzamansız görev modu önceliklidir. Oluşturma isteği SSE akışı yerine JSON görev meta verileri döndürür.
Modele özgü istek davranışı
response_formatyalnızca DALL·E modelleri için geçerlidir; GPT görüntü modelleri base64 verisi döndürür ve bunu yoksayar- GPT görüntü modelleri GPT-only denetimlerini kullanır; bunlara
output_format,quality,backgroundveoutput_compressiondahildir qualityGPT görüntü modellerindelow,medium,highveautokabul eder;gpt-image-2.5-sunburstvegpt-image-2.5-flareayrıcaxhighvemaxdeğerlerini de kabul ederoutput_compressionoutput_format,webpveyajpegolduğunda geçerlidir;pngüzerinde etkisi yokturpartial_imagesyalnızcastream,trueolduğunda geçerlidir- En güncel modele özgü seçenekler için OpenAI görüntü oluşturma kılavuzunu izleyin
qwen-imagen > 1desteklemez
Şeffaf arka plan oluşturma
Arka plan dolgusu olmayan, yalıtılmış bir konu oluşturmak içinbackground değerini transparent olarak ayarlayın. Bu, gpt-image-2.5-sunburst ve gpt-image-2.5-flare üzerinde desteklenir.
Şeffaflık için alfa kanalı içeren bir çıktı biçimi gerekir. output_format değerini png veya webp olarak ayarlayın. JPEG’de alfa kanalı yoktur; bu nedenle output_format: "jpeg" ile yapılan şeffaflık isteği reddedilir.
Yanıt, alfa kanalıyla birlikte b64_json içinde base64 görüntü verisi döndürür. Dosyayı kaydetmek için kodunu çözün:
background değerini opaque olarak ayarlayın veya modelin karar vermesine izin vermek için auto olarak ayarlayın. Yanıt, uygulanan değeri üst düzey background alanında tekrarlar.
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. 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.
"low"
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.
transparent, opaque, auto 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.
0 <= x <= 100Content moderation level for GPT image models. low is less restrictive; auto is the default.
low, auto 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.
0 <= x <= 3Requested 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.