跳转到主要内容
OpenOpen8 提供两个兼容 OpenAI Images API 的图像端点。你可以根据提示词生成新图像,或提供源图像和提示词来编辑图像。两个端点都会将请求路由到你配置的上游图像渠道——例如 DALL·E 3、Stable Diffusion 或其他服务商。使用 Authorization 头中的 Bearer token 认证。

POST /v1/images/generations

根据文本提示词生成一张或多张图像。

请求体

model
string
必填
图像生成模型,例如 dall-e-3dall-e-2。可用值取决于你配置的渠道。
prompt
string
必填
图像的文本描述。DALL·E 3 最大 4,000 字符;DALL·E 2 最大 1,000 字符。
n
integer
生成图像数量。默认 1。DALL·E 3 仅支持 n=1
size
string
生成图像的尺寸。可选值因模型而异:
  • DALL·E 2:256x256512x5121024x1024
  • DALL·E 3:1024x10241024x17921792x1024
默认 1024x1024
quality
string
图像质量。设为 hd 获得更高细节但成本更高(仅 DALL·E 3)。默认 standard
response_format
string
返回的图像数据格式。url(临时托管 URL)或 b64_json(base64 编码的图像数据)。默认 url
style
string
生成图像的风格。vivid(超写实)或 natural(更自然)。仅 DALL·E 3。
background
string
图像背景样式(上游服务商支持时)。
output_format
string
输出文件格式(上游服务商支持时),如 pngwebp
output_compression
integer
输出图像压缩级别(上游服务商支持时)。范围 0100
watermark
boolean
是否包含水印(上游服务商支持时)。

响应

created
integer
请求处理时的 Unix 时间戳。
data
object[]
生成的图像对象数组。

示例

curl https://openopen8.ai/v1/images/generations \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "A photorealistic image of a red panda sitting on a mossy log in a misty forest",
    "n": 1,
    "size": "1024x1024",
    "response_format": "url"
  }'

POST /v1/images/edits

使用文本提示词编辑已有图像。上传源图像(multipart 表单),可选包含蒙版,并提供描述所需修改的提示词。

请求体

此端点使用 multipart/form-data 编码。
model
string
必填
图像编辑模型,例如 dall-e-2。并非所有图像模型都支持编辑。
image
file
必填
要编辑的源图像。必须为有效 PNG 文件,小于 4 MB,且为正方形。
prompt
string
必填
描述你想要应用的编辑。
mask
file
可选蒙版图像。蒙版的透明区域表示应用编辑的位置。必须与 image 尺寸相同。
n
integer
生成的编辑图像数量。默认 1
size
string
输出图像尺寸。可选:256x256512x5121024x1024。默认 1024x1024
response_format
string
urlb64_json。默认 url

响应

结构同 /v1/images/generations

示例

curl
curl https://openopen8.ai/v1/images/edits \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F model="dall-e-2" \
  -F image="@source.png" \
  -F mask="@mask.png" \
  -F prompt="Replace the background with a snowy mountain scene" \
  -F n=1 \
  -F size="1024x1024"