创建 Image

POST /v1/images/generations

MethodPOST
Path/v1/images/generations
Typehttp
Status1
Module2102810
Folder79261575

概览

MethodPOST
Path/v1/images/generations
Typehttp
Status1
Module2102810
Folder79261575

参数

{
  "header": [
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "CVFe1FreVJ",
      "enable": true,
      "name": "Authorization",
      "sampleValue": ""
    }
  ]
}

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "prompt": {
        "type": "string",
        "description": "所需图像的文本描述。最大长度为 1000 个字符。"
      },
      "size": {
        "type": "string",
        "description": "生成图像的尺寸:960x960、720x1280、1280x720、1168x784、784x1168"
      },
      "model": {
        "type": "string",
        "description": "用于生成图像的模型。"
      },
      "aspect_ratio": {
        "type": "string",
        "description": "【可选参数】格式为:参数数量和n同步 [\n    null,\n    \"\"\n  ],\n宽高比 : \"1:1\" | \"3:4\" | \"4:3\" | \"9:16\" | \"16:9\" | \"2:3\" | \"3:2\" | \"9:19.5\" | \"19.5:9\" | \"9:20\" | \"20:9\" | \"1:2\" | \"2:1\" | \"auto\""
      },
      "n": {
        "type": "integer",
        "description": "【可选参数】生成图像的数量 默认值: 1 最小值:1 最大值:10"
      },
      "quality": {
        "type": "string",
        "description": "【可选参数】格式为:参数数量和n同步 [\n    null,\n    \"\"\n  ], 生成图像质量 \"low\" | \"medium\" | \"high\""
      },
      "resolution": {
        "type": "string",
        "description": "【可选参数】格式为:参数数量和n同步 [\n    null,\n    \"\"\n  ], 图像生成分辨率 \"1k\" | \"2k\""
      },
      "response_format": {
        "type": "string",
        "description": "【可选参数】响应格式 b64_json 或者 url"
      }
    },
    "x-apifox-orders": [
      "model",
      "prompt",
      "size",
      "aspect_ratio",
      "n",
      "quality",
      "resolution",
      "response_format"
    ],
    "required": [
      "prompt",
      "model",
      "aspect_ratio",
      "n",
      "quality",
      "resolution",
      "response_format"
    ]
  },
  "required": true,
  "mediaType": "",
  "examples": [
    {
      "name": "示例 1",
      "value": "{\n    \"model\": \"grok-3-image\",\n    \"prompt\": \"a cat\",\n    \"size\": \"960x960\",\n    \"n\": 2,\n    \"aspect_ratio\": [\n        null,\n        \"1:1\"\n    ],\n    \"quality\": [\n        null,\n        \"low\"\n    ],\n    \"resolution\": [\n        null,\n        \"1k\"\n    ],\n    \"response_format\": \"b64_json \"\n}",
      "mediaType": "application/json"
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 158285427,
    "name": "成功",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {}
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": []
  }
]

响应示例

[
  {
    "name": "示例 1",
    "responseId": 158285427,
    "data": "{\r\n    \"created\": 1773127037,\r\n    \"data\": [\r\n        {\r\n            \"url\": \"https://pub-85624410c6c44bdb802187ae2bd8afff.r2.dev/grok/8903fc79-152b-4b80-b384-d74ae6775b07.jpg\"\r\n        }\r\n    ],\r\n    \"usage\": {\r\n        \"generated_images\": 1,\r\n        \"output_tokens\": 16384,\r\n        \"total_tokens\": 16384\r\n    }\r\n}",
    "id": "019cd6a0-0434-7621-b609-6cdd2a128d43"
  }
]