Skip to main content
POST
このルートを使用すると、CometAPI で OpenAI 互換のリクエスト形式によりテキストから画像を生成できます。

公式リファレンス

  • backgroundoutput_compression、ストリーミング、または今後の GPT 画像オプションのようなモデル固有の制御に依存する前に、OpenAI image generation guide を確認してください。
  • 現在のパラメータ一覧については、OpenAI Create image reference を使用してください。

まずモデルを選ぶ

  • output_formatqualitybackground などの制御を使ったテキストから画像へのリクエストには、gpt-image-2 のような GPT 画像モデルを使用します
  • そのプロバイダーが特に必要な場合は qwen-image を使用しますが、n は 1 のままにしてください
  • Models page から現在の image model ID を選んでください

安全な最初のリクエスト

  • gpt-image-2 から始めてください
  • size1024x1024 のままにしてください
  • GPT 画像モデルは b64_json に base64 エンコードされた画像データを返します。画像ファイルとして保存するにはこれをデコードしてください
  • jpeg のような特定のエンコード済み画像形式が必要な場合にのみ output_format を追加してください
  • backgroundoutput_compression、またはストリーミングを追加する前に、OpenAI image generation guide を確認してください
  • バッチ生成やスタイル調整を追加する前に、1 つのプロンプト(Prompt)と 1 枚の出力画像で試してください

非同期画像タスクを実行する

長時間実行される画像ジョブで、1 つの HTTP 接続を開いたままにする代わりに送信してポーリングするフローをクライアントが望む場合は、async: true を使用してください。作成リクエストは data.task_id を返します。 data.statussuccess または failure になるまで、Retrieve an image generation task をポーリングしてください。 async フィールドはこのルートに対する CometAPI 独自拡張であり、OpenAI のパラメータではありません。OpenAI は GPT 画像モデル向けに streampartial_images をドキュメント化しています。CometAPI の非同期タスクモードは JSON のタスクメタデータを返し、ポーリングを使用します。 非同期タスクモードは、ドキュメント化された次の model ID で使用してください: gpt-image-2doubao-seedream-4-0-250828。その他の画像モデルでは、そのモデルで async タスク対応がドキュメント化されていない限り、同期生成またはストリーミングを使用してください。 リクエストに async: truestream: true の両方が含まれる場合、非同期タスクモードが優先されます。作成リクエストは SSE ストリームではなく JSON のタスクメタデータを返します。

モデル固有のリクエスト動作

  • response_format は DALL·E モデルにのみ適用されます。GPT 画像モデルは base64 データを返し、これを無視します
  • GPT 画像モデルは、output_formatqualitybackgroundoutput_compression などの GPT 専用制御を使用します
  • 最新のモデル固有オプションについては、OpenAI image generation guide に従ってください
  • qwen-imagen > 1 をサポートしていません
生成された画像は、プロバイダーの利用ポリシーに準拠している必要があります。違法、暴力的、ポルノ的、または著作権を侵害するプロンプトは送信しないでください。

承認

Authorization
string
header
必須

Bearer token authentication. Use your CometAPI key.

ボディ

application/json
model
string
デフォルト:gpt-image-2
必須

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

prompt
string
必須

Text description of the image you want to generate.

:

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

n
integer
デフォルト: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.

:

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

利用可能なオプション:
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.

:

"jpeg"

stream
boolean
デフォルト: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
デフォルト: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.

レスポンス

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

created
integer
必須

Unix timestamp for the completed generation.

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