이미지 생성
CometAPI POST /v1/images/generations를 사용해 OpenAI 호환 이미지 모델과 모델별 제어 옵션으로 이미지를 생성합니다.
공식 레퍼런스
background,output_compression, 스트리밍(Streaming), 또는 향후 GPT 이미지 옵션과 같은 모델별 제어 기능을 사용하기 전에 OpenAI image generation guide를 읽어보세요.- 현재 파라미터 목록은 OpenAI Create image reference를 사용하세요.
먼저 모델 선택하기
output_format,quality,background같은 제어 옵션이 있는 텍스트-투-이미지 요청에는gpt-image-2와 같은 GPT 이미지 모델을 사용하세요- 해당 provider가 특별히 필요하다면
qwen-image를 사용하되,n은 1로 유지하세요 - Models page에서 현재 이미지 model ID를 선택하세요
안전한 첫 요청
gpt-image-2로 시작하세요size는1024x1024로 유지하세요- GPT 이미지 모델은
b64_json에 base64로 인코딩된 이미지 데이터를 반환하므로, 이미지 파일로 저장하려면 이를 디코딩해야 합니다 jpeg와 같은 특정 인코딩 이미지 형식이 필요할 때만output_format을 추가하세요background,output_compression, 또는 스트리밍(Streaming)을 추가하기 전에 OpenAI 이미지 생성 가이드를 확인하세요- 배치 생성이나 스타일 조정을 추가하기 전에 프롬프트(Prompt) 1개와 출력 이미지 1개로 먼저 사용해 보세요
비동기 이미지 작업 실행
클라이언트가 하나의 HTTP 연결을 계속 열어두는 대신 제출 후 폴링하는 흐름을 선호한다면, 오래 걸리는 이미지 작업에async: true를 사용하세요. 생성 요청은 data.task_id를 반환합니다.
data.status가 success 또는 failure가 될 때까지 Retrieve an image generation task를 폴링하세요.
async 필드는 이 경로에 대한 CometAPI 확장이며, OpenAI 파라미터가 아닙니다. OpenAI는 GPT 이미지 모델에 대해 stream 및 partial_images를 문서화합니다. CometAPI 비동기 작업 모드는 JSON 작업 메타데이터를 반환하고 폴링을 사용합니다.
문서화된 다음 model ID에서 async 작업 모드를 사용하세요: gpt-image-2 및 doubao-seedream-4-0-250828. 다른 이미지 모델의 경우, 해당 모델에 async 작업 지원이 문서화되어 있지 않다면 동기 생성 또는 스트리밍(Streaming)을 사용하세요.
요청에 async: true와 stream: true가 모두 포함되면 async 작업 모드가 우선 적용됩니다. 생성 요청은 SSE 스트림 대신 JSON 작업 메타데이터를 반환합니다.
모델별 요청 동작
response_format은 DALL·E 모델에만 적용되며, GPT 이미지 모델은 base64 데이터를 반환하고 이를 무시합니다- GPT 이미지 모델은
output_format,quality,background,output_compression같은 GPT 전용 제어 옵션을 사용합니다 - 최신 모델별 옵션은 OpenAI 이미지 생성 가이드를 따르세요
qwen-image는n > 1을 지원하지 않습니다
인증
Bearer token authentication. Use your CometAPI key.
본문
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.
응답
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.