跳转到主要内容
POST
/
v1
/
images
/
generations
Create images
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"
    }
  ]
}
使用此路由可在 CometAPI 上通过兼容 OpenAI 的请求格式,从文本创建图像。

先选择模型

  • 当你想进行基于简单 URL 的冒烟测试时,使用 dall-e-3
  • 当你想使用较新的 GPT 图像模型并且可以处理 base64 响应时,使用 gpt-image-1gpt-image-1-minigpt-image-1.5
  • 当你明确需要该提供方时,使用 qwen-image,但请将 n 保持为 1

安全的首次请求

  • dall-e-3 开始
  • size 保持为 1024x1024
  • 如果你希望获得较小的 JSON 响应和临时下载 URL,请设置 response_format: "url"
  • 在添加批量生成或风格调优之前,先只使用一个 Prompt 和一张图像

模型特定的响应行为

  • dall-e-2dall-e-3 支持 URL 响应和 base64 响应
  • gpt-image-1gpt-image-1-minigpt-image-1.5 更适合作为优先返回 base64 的路由来使用
  • qwen-image 不支持 n > 1
在 2026-03-12 的实时验证中,一个带有 response_format: "url"dall-e-3 请求返回了正常的 created 时间戳、一个 revised_prompt,以及一个临时图像 URL。
生成的图像必须遵守提供方的使用政策。请勿发送违法、暴力、色情或侵犯版权的 Prompt。

授权

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

请求体

application/json
model
string
默认值:dall-e-3
必填

The image generation model to use. Choose a current model from the Models page.

prompt
string
必填

Text description of the image you want to generate.

示例:

"A paper boat floating on calm water at sunrise."

n
integer
默认值:1

Number of images to generate. Keep this at 1 for the broadest compatibility.

size
string

Requested output size. Supported values depend on the selected model.

示例:

"1024x1024"

response_format
enum<string>

Requested output encoding for models that support it.

可用选项:
url,
b64_json

响应

200 - application/json

Image generation result.

created
integer
必填

Unix timestamp for the completed generation.

data
object[]
必填