通过 CometAPI 调用 OpenAI 的 POST /v1/images/generations,从文本 Prompt 创建图像、控制风格、选择尺寸,并返回 base64 或 URL。
curl --request POST \
--url https://api.cometapi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "dall-e-3",
"prompt": "A paper boat floating on calm water at sunrise."
}
'{
"created": 1773311889,
"data": [
{
"revised_prompt": "A paper boat floating on calm water at sunrise, with soft golden light reflecting off the water's surface.",
"url": "https://filesystem.site/cdn/20260312/1d6826050921c07a13ff173310c640.webp"
}
]
}dall-e-3gpt-image-1、gpt-image-1-mini 或 gpt-image-1.5qwen-image,但请将 n 保持为 1dall-e-3 开始size 保持为 1024x1024response_format: "url"dall-e-2 和 dall-e-3 支持 URL 响应和 base64 响应gpt-image-1、gpt-image-1-mini 和 gpt-image-1.5 更适合作为优先返回 base64 的路由来使用qwen-image 不支持 n > 1response_format: "url" 的 dall-e-3 请求返回了正常的 created 时间戳、一个 revised_prompt,以及一个临时图像 URL。Bearer token authentication. Use your CometAPI key.
The image generation model to use. Choose a current model from the Models page.
Text description of the image you want to generate.
"A paper boat floating on calm water at sunrise."
Number of images to generate. Keep this at 1 for the broadest compatibility.
Requested output size. Supported values depend on the selected model.
"1024x1024"
Requested output encoding for models that support it.
url, b64_json curl --request POST \
--url https://api.cometapi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "dall-e-3",
"prompt": "A paper boat floating on calm water at sunrise."
}
'{
"created": 1773311889,
"data": [
{
"revised_prompt": "A paper boat floating on calm water at sunrise, with soft golden light reflecting off the water's surface.",
"url": "https://filesystem.site/cdn/20260312/1d6826050921c07a13ff173310c640.webp"
}
]
}