codecamp

OpenAI 图像编辑流式事件

图像编辑流式事件

通过服务端发送事件实时流式传输图像生成和编辑结果。了解图像流式处理。

image_edit.partial_image

图像编辑流式处理中有部分图像可用时发出。

结构定义

结构名称:ImageEditPartialImageEvent

  • b64_json: string

Base64编码的部分图像数据,可用于渲染图像。

  • background: "transparent" or "opaque" or "auto"

请求编辑图像的背景设置。

  • "transparent"

  • "opaque"

  • "auto"

  • created_at: integer(Unix 时间戳)

事件创建时的Unix时间戳。

  • output_format: "png" or "webp" or "jpeg"

请求编辑图像的输出格式。

  • "png"

  • "webp"

  • "jpeg"

  • partial_image_index: integer

部分图像的从0开始的索引,用于流式处理。

  • quality: "low" or "medium" or "high" or 3 more

请求编辑图像的质量设置。

  • "low"

  • "medium"

  • "high"

  • "xhigh"

  • "max"

  • "auto"

  • size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"

以WIDTHxHEIGHT表示的图像尺寸,例如1536x864。

  • string

  • "1024x1024" or "1024x1536" or "1536x1024" or "auto"

以WIDTHxHEIGHT表示的图像尺寸,例如1536x864。

  • "1024x1024"

  • "1024x1536"

  • "1536x1024"

  • "auto"

  • type: "image_edit.partial_image"

事件类型,固定为image_edit.partial_image。

  • "image_edit.partial_image"

示例

中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。

{
  "type": "image_edit.partial_image",
  "b64_json": "...",
  "created_at": 1620000000,
  "size": "1024x1024",
  "quality": "high",
  "background": "transparent",
  "output_format": "png",
  "partial_image_index": 0
}

image_edit.completed

图像编辑完成且最终图像可用时发出。

结构定义

结构名称:ImageEditCompletedEvent

  • b64_json: string

经过Base64编码的最终编辑图像数据,可用于渲染为图像。

  • background: "transparent" or "opaque" or "auto"

编辑后图像的背景设置。

  • "transparent"

  • "opaque"

  • "auto"

  • created_at: integer(Unix 时间戳)

事件创建时的Unix时间戳。

  • output_format: "png" or "webp" or "jpeg"

编辑后图像的输出格式。

  • "png"

  • "webp"

  • "jpeg"

  • quality: "low" or "medium" or "high" or 3 more

编辑后图像的质量设置。

  • "low"

  • "medium"

  • "high"

  • "xhigh"

  • "max"

  • "auto"

  • size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"

以WIDTHxHEIGHT表示的图像尺寸,例如1536x864。

  • string

  • "1024x1024" or "1024x1536" or "1536x1024" or "auto"

以WIDTHxHEIGHT表示的图像尺寸,例如1536x864。

  • "1024x1024"

  • "1024x1536"

  • "1536x1024"

  • "auto"

  • type: "image_edit.completed"

事件类型,固定为image_edit.completed。

  • "image_edit.completed"

  • usage: object { input_tokens, input_tokens_details, output_tokens, total_tokens }

图像生成的词元用量信息,仅GPT图像模型提供。

  • input_tokens: integer

输入提示词中的词元数量,包括图像与文本词元。

  • input_tokens_details: object { image_tokens, text_tokens }

图像生成的输入词元详情。

  • image_tokens: integer

输入提示词中的图像词元数量。

  • text_tokens: integer

输入提示词中的文本词元数量。

  • output_tokens: integer

输出图像中的图像词元数量。

  • total_tokens: integer

图像生成使用的词元总数,包括图像与文本词元。

  • safety_identifier: optional string or null

用于安全监控和滥用检测的有效安全标识。采用请求中的非空safety_identifier;若其省略、为null或为空,则使用已弃用的user值。

示例

中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。

{
  "type": "image_edit.completed",
  "b64_json": "...",
  "created_at": 1620000000,
  "size": "1024x1024",
  "quality": "high",
  "background": "transparent",
  "output_format": "png",
  "usage": {
    "total_tokens": 100,
    "input_tokens": 50,
    "output_tokens": 50,
    "input_tokens_details": {
      "text_tokens": 10,
      "image_tokens": 40
    }
  }
}
OpenAI 创建音频转录接口
OpenAI 图像生成流式事件
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

其他能力与进阶指南

Embeddings 接口参考

审计日志接口参考

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }