跳轉到主要內容
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.