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。
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://..." }
]
}
错误
错误信封与 错误处理 一致。源图非正方形或体积超限返回400;模型不支持变体时,上游错误原样返回。此页面对您有帮助吗?