curl https://api.pipellm.ai/v1/images/variations \
-H "Authorization: Bearer $PIPELLM_API_KEY" \
-F model="dall-e-2" \
-F image="@logo.png" \
-F n=2 \
-F size="1024x1024"
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai/v1",
)
result = client.images.create_variation(
model="dall-e-2",
image=open("logo.png", "rb"),
n=2,
size="1024x1024",
)
print([item.url for item in result.data])
{
"created": 1726400000,
"data": [
{ "url": "https://..." },
{ "url": "https://..." }
]
}
生成图像变体
基于源图生成变体。
POST
/
v1
/
images
/
variations
curl https://api.pipellm.ai/v1/images/variations \
-H "Authorization: Bearer $PIPELLM_API_KEY" \
-F model="dall-e-2" \
-F image="@logo.png" \
-F n=2 \
-F size="1024x1024"
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai/v1",
)
result = client.images.create_variation(
model="dall-e-2",
image=open("logo.png", "rb"),
n=2,
size="1024x1024",
)
print([item.url for item in result.data])
{
"created": 1726400000,
"data": [
{ "url": "https://..." },
{ "url": "https://..." }
]
}
上游只有
dall-e-2 实现了这个接口,GPT 图像模型不支持。想用 GPT 图像模型做变体,请把源图发到 POST /v1/images/edits,并用提示词描述你想要的变化。multipart/form-data。
file
必填
源图。必须是小于 4 MB 的正方形 PNG。
string
默认值:"dall-e-2"
只有
dall-e-2 实现了变体功能。integer
默认值:"1"
变体数量,1–10。
string
默认值:"1024x1024"
256x256、512x512 或 1024x1024。string
默认值:"url"
url 或 b64_json。URL 在生成约 60 分钟后失效,请及时下载。string
稳定的终端用户标识。
curl https://api.pipellm.ai/v1/images/variations \
-H "Authorization: Bearer $PIPELLM_API_KEY" \
-F model="dall-e-2" \
-F image="@logo.png" \
-F n=2 \
-F size="1024x1024"
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai/v1",
)
result = client.images.create_variation(
model="dall-e-2",
image=open("logo.png", "rb"),
n=2,
size="1024x1024",
)
print([item.url for item in result.data])
{
"created": 1726400000,
"data": [
{ "url": "https://..." },
{ "url": "https://..." }
]
}
integer
生成时间的 Unix 时间戳。
array
每个变体一项,按
response_format 返回 url 或 b64_json。错误
错误信封与 错误处理 一致。源图非正方形或体积超限返回400;模型不支持变体时,上游错误原样返回。此页面对您有帮助吗?