コンソール

レイアウトから画像生成

POST/v1/images/generations

レイアウトから画像を生成するAPIです。要素の説明とバウンディングボックスでテキストやオブジェクトの位置・サイズ・配置を指定し、テキストを含む複雑な構図の画像をモデルに生成させます。リクエストのフィールド、レスポンス、エラーコードはテキストから画像生成のページと同じです。

レイアウトJSONの構造

レイアウトJSONはpromptフィールドに渡す入力です。レイアウトJSON全体を文字列にシリアライズして渡してください。その他のリクエストパラメータはテキストから画像生成と同じです。

フィールド型説明
summary.caption: string

シーン全体とスタイル。

items: array

各要素の種類(label)、説明(caption)、バウンディングボックス(bbox)、および描画するテキスト(text)。

bbox_format: string

"yxyx"を指定します。バウンディングボックスは[y_min, x_min, y_max, x_max]の順に並べます。

bbox_coord_space: string

"abs_centralized"を指定し、キャンバス中心を基準としたピクセル座標を使用します。キャンバス中心を原点とし、x軸は右方向、y軸は下方向に増加します。1024×1024のキャンバスでは、両軸とも-512〜512の範囲です。幅W・高さHのキャンバスで左上基準の座標を中心基準に変換するには、xからW/2、yからH/2を引きます。

レイアウトJSONの例

JSON
{
  "summary": {
    "meta": ["poster"],
    "canvas": "single",
    "caption": "A minimalist travel poster with a cream background, a blue mountain illustration, and the title EXPLORE at the top."
  },
  "items": [
    {
      "label": "text",
      "caption": "Large dark-blue uppercase title centered at the top.",
      "text": "EXPLORE",
      "bbox": [-416, -384, -288, 384]
    },
    {
      "label": "object",
      "caption": "A flat blue mountain illustration in the lower center.",
      "bbox": [-192, -288, 384, 288]
    }
  ],
  "bbox_coord_space": "abs_centralized",
  "bbox_format": "yxyx"
}