当前位置: 首页 > news >正文

openAI图像生成开发文档

图像生成

了解如何使用我们的 DALL·E 型号

介绍

图像 API 提供了三种与图像交互的方法:

  1. 根据文本提示从头开始创建图像
  2. 根据新的文本提示创建现有图像的编辑
  3. 创建现有图像的变体

本指南介绍了使用这三个 API 终结点的基础知识以及有用的代码示例。要了解它们的实际效果,请查看我们的 DALL·E 预览应用程序。

图像 API 处于测试阶段。在此期间,API 和模型将根据你的反馈进行改进。为了确保所有用户都能舒适地制作原型,默认速率限制为每分钟 50 张图像。您可以在我们的速率限制指南中了解有关[速率限制](https://platform.openai.com/docs/guides/rate-limits)的更多信息。

创建图像

在这里插入图片描述

编辑图像

在这里插入图片描述

图像变化

在这里插入图片描述

API

Create image

给定提示符和/或输入图像,模型将生成新图像。

Example request

curl https://api.openai.com/v1/images/generations \-H "Content-Type: application/json" \-H "Authorization: Bearer $OPENAI_API_KEY" \-d '{"prompt": "A cute baby sea otter","n": 2,"size": "1024x1024"}'

Parameters

{"prompt": "A cute baby sea otter","n": 2,"size": "1024x1024"
}
{"created": 1589478378,"data": [{"url": "https://..."},{"url": "https://..."}]
}

Request body

prompt string Required
A text description of the desired image(s). The maximum length is 1000 characters.n integer Optional Defaults to 1
The number of images to generate. Must be between 1 and 10.size string Optional Defaults to 1024x1024
The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.response_format string Optional Defaults to url
The format in which the generated images are returned. Must be one of url or b64_json.user string Optional
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. 

Create image edit

根据原始图像和提示创建编辑或扩展的图像。

Example request

curl https://api.openai.com/v1/images/edits \-H "Authorization: Bearer $OPENAI_API_KEY" \-F image="@otter.png" \-F mask="@mask.png" \-F prompt="A cute baby sea otter wearing a beret" \-F n=2 \-F size="1024x1024"

Response

{"created": 1589478378,"data": [{"url": "https://..."},{"url": "https://..."}]
}

Request body

image string Required
The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.mask string Optional
An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as image.prompt string Required
A text description of the desired image(s). The maximum length is 1000 characters.n integer Optional Defaults to 1
The number of images to generate. Must be between 1 and 10.size string Optional Defaults to 1024x1024
The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.response_format string Optional Defaults to url
The format in which the generated images are returned. Must be one of url or b64_json.user string Optional
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

Create image variation

创建给定图像的变体。

Example request

curl https://api.openai.com/v1/images/variations \-H "Authorization: Bearer $OPENAI_API_KEY" \-F image="@otter.png" \-F n=2 \-F size="1024x1024"

Response

{"created": 1589478378,"data": [{"url": "https://..."},{"url": "https://..."}]
}

Request body

image string Required
The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.n integer Optional Defaults to 1
The number of images to generate. Must be between 1 and 10.size string Optional Defaults to 1024x1024
The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.response_format string Optional Defaults to url
The format in which the generated images are returned. Must be one of url or b64_json.user string Optional
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
http://www.lryc.cn/news/67979.html

相关文章:

  • Python综合案例—利用tkinter实现计算器的程序
  • canvas学习笔记
  • Navicat Premium 15安装注教程
  • yolo v8
  • 2022IDEA的下载、安装、配置与使用
  • 实验十 超市订单管理系统综合实验
  • 微服架构基础设施环境平台搭建 -(二)Docker私有仓库Harbor服务搭建
  • springboot+freemarker+restful
  • 基于Kubernetes集群构建大中型企业CICD应用平台(1)-- devOps
  • 什么是模型鲁棒性和泛化能力
  • AI翻译工具分享
  • 选男友最好的方式就是爬山
  • C++面经:初始化全局变量和未初始化全局变量有什么区别
  • vue-2 指令:
  • 非常提效的7款原型工具推荐
  • 最新Kafka和RabbitMQ消息队列经典面试题汇总(含答案)
  • 软件测试行业对新人友好吗?
  • Python requests 模块
  • IOC理论推导
  • 我的一些感悟
  • NC 人力薪酬管理怎么结账?
  • JavaWeb编程面试题——Spring Boot
  • Educational Codeforces Round 148 (Rated for Div. 2) A,B,C
  • C#串口通信从入门到精通(15)——流量控制(XON/XOFF协议实现)
  • 基于Kubernetes集群构建大中型企业CICD应用平台(2)--code阶段工具gitlab安装
  • 数字化转型浪潮下,如何选择适合企业的低代码平台
  • 利用 Amazon API Gateway 和 Amazon Lambda 处理 Cloudfront 的内容请求
  • Parasoft和TASKING联手提供卓越的汽车软件开发和自动化测试
  • java读取word文档内容
  • 使用Process Monitor排查因dll库被锁定导致C++程序启动报“0xc0000022”错误问题