Skip to main content
POST
CometAPI üzerinde OpenAI uyumlu istek biçimleriyle metinden image oluşturmak için bu rotayı kullanın.

Resmi referans

Önce bir model seçin

  • output_format, quality veya background gibi kontrollerle text-to-image istekleri için gpt-image-2 gibi bir GPT image modeli kullanın
  • Özellikle o sağlayıcıya ihtiyacınız olduğunda qwen-image kullanın, ancak n değerini 1 olarak tutun
  • Models sayfasından güncel bir image model ID seçin

Güvenli ilk istek

  • gpt-image-2 ile başlayın
  • size değerini 1024x1024 olarak tutun
  • GPT image modelleri image verisini b64_json içinde base64 kodlu olarak döndürür; image dosyasını kaydetmek için bunu decode edin
  • output_format alanını yalnızca jpeg gibi belirli bir kodlanmış image türüne ihtiyacınız olduğunda ekleyin
  • background, output_compression veya 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çin async: 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_format yalnı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, background ve output_compression gibi 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 > 1 desteklemez
Oluşturulan image’lar sağlayıcının kullanım politikalarına uymalıdır. Yasadışı, şiddet içeren, pornografik veya telif hakkını ihlal eden prompt’lar göndermeyin.

Yetkilendirmeler

Authorization
string
header
gerekli

Bearer token authentication. Use your CometAPI key.

Gövde

application/json
model
string
varsayılan:gpt-image-2
gerekli

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

prompt
string
gerekli

Text description of the image you want to generate.

Örnek:

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

n
integer
varsayılan:1

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

quality
string

Quality setting for models that support it. See the OpenAI image generation guide for the latest model-specific values.

size
string

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

Örnek:

"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.

Mevcut seçenekler:
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.

Örnek:

"jpeg"

stream
boolean
varsayılan: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
varsayılan: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.

Yanıt

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

created
integer
gerekli

Unix timestamp for the completed generation.

data
object[]
gerekli
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.