控制台

布局生图

POST/v1/images/generations

布局生图接口,通过元素描述和边界框指定文本和对象的位置、大小及排列关系,引导模型生成复杂图文画面。请求字段、返回值及错误码同文生图页面一致。

布局 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"
}