创建 gpt-image-1.5

POST /v1/images/generations

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

说明

给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。

为提供的提示和参数创建完成

官方文档:https://platform.openai.com/docs/api-reference/images/create

概览

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

参数

{
  "query": [],
  "path": [],
  "cookie": [],
  "header": [
    {
      "id": "NQs7bxnpZf",
      "name": "Content-Type",
      "required": true,
      "description": "",
      "type": "string",
      "enable": true,
      "sampleValue": "application/json"
    },
    {
      "id": "qb8tEQbCty",
      "name": "Accept",
      "required": true,
      "description": "",
      "type": "string",
      "enable": true,
      "sampleValue": "application/json"
    },
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "gBxcCbXhsa",
      "enable": true,
      "name": "Authorization",
      "sampleValue": "Bearer {{YOUR_API_KEY}}"
    }
  ]
}

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "prompt": {
        "description": "所需图像的文本描述。最大长度为 1000 个字符。",
        "type": "string"
      },
      "n": {
        "description": "要生成的图像数。必须介于 1 和 10 之间。",
        "type": "integer"
      },
      "size": {
        "description": "生成图像的尺寸。对于 GPT 图像模型,必须是 1024x1024 、 1536x1024 (横版)、 1024x1536 (竖版)或 auto (默认值)之一,对于 dall-e-2 必须是 256x256 、 512x512 或 1024x1024 之一,对于 dall-e-3 必须是 1024x1024 、 1792x1024 或 1024x1792 之一。\n\n",
        "type": "string"
      }
    },
    "required": [
      "prompt",
      "n",
      "size"
    ],
    "x-apifox-orders": [
      "prompt",
      "n",
      "size"
    ]
  },
  "required": false,
  "mediaType": "",
  "examples": [
    {
      "value": "{\n    \"size\": \"1024x1536\",\n    \"prompt\": \"a man walks\",\n    \"model\": \"gpt-image-1.5\",\n    \"n\": 1\n}",
      "mediaType": "application/json"
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 666443878,
    "name": "OK",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "object": {
          "type": "string"
        },
        "created": {
          "type": "integer"
        },
        "choices": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "index": {
                "type": "integer"
              },
              "message": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  }
                },
                "required": [
                  "role",
                  "content"
                ],
                "x-apifox-orders": [
                  "role",
                  "content"
                ]
              },
              "finish_reason": {
                "type": "string"
              }
            },
            "x-apifox-orders": [
              "index",
              "message",
              "finish_reason"
            ]
          }
        },
        "usage": {
          "type": "object",
          "properties": {
            "prompt_tokens": {
              "type": "integer"
            },
            "completion_tokens": {
              "type": "integer"
            },
            "total_tokens": {
              "type": "integer"
            }
          },
          "required": [
            "prompt_tokens",
            "completion_tokens",
            "total_tokens"
          ],
          "x-apifox-orders": [
            "prompt_tokens",
            "completion_tokens",
            "total_tokens"
          ]
        }
      },
      "required": [
        "id",
        "object",
        "created",
        "choices",
        "usage"
      ],
      "x-apifox-orders": [
        "id",
        "object",
        "created",
        "choices",
        "usage"
      ]
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": [],
    "oasExtensions": ""
  }
]

响应示例

[
  {
    "name": "OK",
    "responseId": 666443878,
    "data": "{\n    \"id\": \"chatcmpl-123\",\n    \"object\": \"chat.completion\",\n    \"created\": 1677652288,\n    \"choices\": [\n        {\n            \"index\": 0,\n            \"message\": {\n                \"role\": \"assistant\",\n                \"content\": \"\\n\\nHello there, how may I assist you today?\"\n            },\n            \"finish_reason\": \"stop\"\n        }\n    ],\n    \"usage\": {\n        \"prompt_tokens\": 9,\n        \"completion_tokens\": 12,\n        \"total_tokens\": 21\n    }\n}",
    "description": "",
    "oasKey": "",
    "oasExtensions": "",
    "id": 587196258
  }
]