跳转到主要内容
POST
/
v1
/
images
/
generations
curl --request POST \
  --url https://api.cometapi.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-image-2",
  "prompt": "A paper boat floating on calm water at sunrise."
}
'
{
  "created": 1776841943,
  "background": "opaque",
  "output_format": "jpeg",
  "quality": "low",
  "size": "1024x1024",
  "usage": {
    "input_tokens": 16,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 16
    },
    "output_tokens": 208,
    "total_tokens": 224
  },
  "data": [
    {
      "b64_json": "<base64-image-data>"
    }
  ]
}

Documentation Index

Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt

Use this file to discover all available pages before exploring further.

使用此路由可通过 CometAPI 以兼容 OpenAI 的请求格式从文本创建图像。

官方参考

先选择模型

  • 当你想用 response_format 发起一个简单的首次请求时,使用 dall-e-3
  • 当你需要仅适用于 GPT 的控制项(如 output_formatqualitybackground)时,使用 GPT 图像模型
  • 当你明确需要该提供商时,使用 qwen-image,但请将 n 保持为 1

安全的首次请求

  • dall-e-3 开始
  • size 保持为 1024x1024
  • 如果你希望获得较小的 JSON 响应以及一个临时下载 URL,请设置 response_format: "url"
  • 如果你需要 GPT 图像模型参数,请使用 API 参考中已验证的 GPT 请求示例
  • 仅当你需要特定编码图像类型(如 jpeg)时,再添加 output_format
  • 在添加 backgroundoutput_compression 或流式输出之前,请先查看 OpenAI 图像生成指南
  • 在添加批量生成或风格调优之前,先使用一个 Prompt 和一张输出图像

特定模型的请求行为

  • response_format 适用于 dall-e-2dall-e-3
  • GPT 图像模型使用仅适用于 GPT 的控制项,例如 output_formatqualitybackgroundoutput_compression
  • 请遵循 OpenAI 图像生成指南以了解最新的特定模型选项
  • qwen-image 不支持 n > 1
生成的图像必须遵守提供商的使用政策。请勿发送违法、暴力、色情或侵犯版权的 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.

quality
string

Quality setting for models that support it. See the OpenAI image generation guide for the latest model-specific values.

size
string

Requested output size. Supported values depend on the selected model. See the OpenAI image generation guide for the latest model-specific ranges.

示例:

"1024x1024"

response_format
enum<string>

The response container for dall-e-2 and dall-e-3. This parameter is not supported for GPT image models, which return base64-encoded image data.

可用选项:
url,
b64_json
output_format
string

The encoded image type for GPT image model results, such as png, jpeg, or webp. See the OpenAI image generation guide for current GPT image output controls.

示例:

"jpeg"

响应

200 - application/json

Image generation result.

created
integer
必填

Unix timestamp for the completed generation.

usage
object
必填
data
object[]
必填
background
string

Background mode returned by models that expose it.

output_format
string

Encoded image type returned by GPT image models.

quality
string

Quality level returned by models that expose it.

size
string

Output size returned by models that expose it.