Image generation Beta
Learn how to generate or manipulate images with our DALL·E models
了解如何使用我们的 DALL·E 模型生成或处理图像
Introduction
The Images API provides three methods for interacting with images:
图片 API 提供了三种与图片交互的方法:
- Creating images from scratch based on a text prompt
根据文本提示从头开始创建图像 - Creating edits of an existing image based on a new text prompt
根据新文本提示创建现有图像的编辑 - Creating variations of an existing image
创建现有图像的变体
This guide covers the basics of using these three API endpoints with useful code samples. To see them in action, check out our DALL·E preview app.
本指南涵盖了使用这三个 API 端点的基础知识以及有用的代码示例。要查看它们的实际效果,请查看我们的 DALL·E 预览应用程序。
The Images API is in beta. During this time the API and models will evolve based on your feedback. To ensure all users can prototype comfortably, the default rate limit is 50 images per minute. If you would like to increase your rate limit, please review this help center article. We will increase the default rate limit as we learn more about usage and capacity requirements.
图片 API 处于测试阶段。在此期间,API 和模型将根据您的反馈进行改进。为确保所有用户都能轻松制作原型,默认速率限制为每分钟 50 张图像。如果您想提高速率限制,请查看这篇帮助中心文章。随着我们对使用和容量要求的更多了解,我们将提高默认速率限制。
Usage
Generations
The image generations endpoint allows you to create an original image given a text prompt. Generated images can have a size of 256x256, 512x512, or 1024x1024 pixels. Smaller sizes are faster to generate. You can request 1-10 images at a time using the n parameter.
图像生成端点允许您在给定文本提示的情况下创建原始图像。生成的图像的大小可以为 256x256、512x512 或 1024x1024 像素。较小的尺寸生成速度更快。您可以使用 n 参数一次请求 1-10 张图像。
Generate an image 生成图像
python
response = openai.Image.create(
prompt="a white siamese cat",
n=1,
size="1024x1024"
)
image_url = response['data'][0]['url']
The more detailed the description, the more likely you are to get the result that you or your end user want. You can explore the examples in the DALL·E preview app for more prompting inspiration. Here’s a quick example:
描述越详细,您就越有可能获得您或您的最终用户想要的结果。您可以探索 DALL·E 预览应用程序中的示例以获得更多提示灵感。这是一个简单的例子:
| PROMPT | GENERATION |
|---|---|
| a white siamese cat 一只白色的暹罗猫 | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-waP75L2u-1681139040854)(…/…/…/…/…/…/workspace/vscode-project/ringyin-blog/source/images/image_generation_simple.webp)] |
| a close up, studio photographic portrait of a white siamese cat that looks curious, backlit ears 一只白色暹罗猫的特写工作室摄影肖像,它看起来好奇,背光的耳朵 | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qwZCiITS-1681139040855)(…/…/…/…/…/…/workspace/vscode-project/ringyin-blog/source/images/image_generation_detailed.webp)] |
Each image can be returned as either a URL or Base64 data, using the response_format parameter. URLs will expire after an hour.
使用 response_format 参数,每个图像都可以作为 URL 或 Base64 数据返回。 URL 将在一小时后过期。
Edits
The image edits endpoint allows you to edit and extend an image by uploading a mask. The transpare

本文介绍了DALL·E的图像API,包括从文本提示创建图像、编辑现有图像和生成图像变体的功能。用户可以基于详细的描述请求生成多张不同尺寸的图像。API目前处于测试阶段,提供每分钟50张图像的默认速率限制,并支持通过反馈进行改进。代码示例展示了如何使用Python和Node.js进行操作,同时强调了内容审核和错误处理的重要性。
最低0.47元/天 解锁文章
770

被折叠的 条评论
为什么被折叠?



