跳轉到主要內容
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[]
必填