跳轉到主要內容
POST
/
v1
/
images
/
generations
curl -s https://api.cometapi.com/v1/images/generations \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-5-0-260128",
    "prompt": "a cat wearing a scarf sitting by the window watching rain, illustration style",
    "size": "2K",
    "response_format": "url",
    "watermark": false
  }' | jq -r '.data[].url'
{
  "created": 123,
  "data": [
    {
      "url": "<string>",
      "b64_json": "<string>",
      "size": "<string>"
    }
  ],
  "usage": {
    "generated_images": 123,
    "output_tokens": 123,
    "total_tokens": 123
  },
  "model": "<string>"
}

概覽

透過標準 OpenAI 相容的 /v1/images/generations 端點,使用 ByteDance 的 Seedream 模型生成圖像。支援 文字轉圖像圖像轉圖像 生成。 完整模型清單請參閱模型頁面。如需供應商提供的詳細參數文件,請參閱 VolcEngine 文件
使用依序(多圖)生成時,請將 sequential_image_generation 設為 auto,並可選擇設定 sequential_image_generation_options.max_images 來限制輸出圖像數量。參考圖像與生成圖像的總數必須 ≤ 15

圖像轉圖像

透過 image 參數(URL 或 base64 data URI 陣列)傳入一張或多張參考圖像,並搭配文字提示。最多支援 14 張參考圖像。

回傳的 URL 出現 AccessDenied?

回傳的 url 是已簽名的物件儲存連結,包含 & 與其他特殊字元
如果你複製原始 JSON 並直接貼到瀏覽器或腳本中,shell 轉義或終端截斷可能會移除簽名參數,導致出現:
\{"Code":"AccessDenied","Message":"Access Denied","EC":"0003-00000015"\}
如何修正:
  • curl:透過 | jq -r '.data[].url' 管線擷取 URL,避免內容被破壞。
  • Python:使用 result.data[0].urlimage["url"] —— 該字串已完整,可直接傳給 requests.get()webbrowser.open()
  • JavaScript:同樣的做法 —— result.data[0].url
  • 一般情況:請確認 URL 中的 &% 沒有被截斷或重複轉義。

授權

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

主體

application/json

Parameters for Seedream image generation (text-to-image and image-to-image).

model
string
預設值:doubao-seedream-5-0-260128
必填

Model to use. See the Models page for current Seedream model IDs.

prompt
string
預設值:a cat wearing a scarf sitting by the window
必填

Text prompt describing the image to generate. Supports both Chinese and English. Recommended max 300 Chinese characters or 1000 English characters.

response_format
enum<string>
預設值:url

Output format. url returns a temporary image link (valid for 24 hours); b64_json returns base64-encoded image data.

可用選項:
url,
b64_json
size
string
預設值:2048x2048

Output resolution. Presets 2K, 4K, or exact pixels like 2048x2048, 2304x1728, 2848x1600, 1600x2848, etc. Default: 2048x2048.

image
string[]

Reference image(s) for image-to-image generation. Each item is a public URL or base64 data URI (data:image/png;base64,...). Supports up to 14 reference images. Supported formats: jpeg, png, webp, bmp, tiff, gif.

watermark
boolean
預設值:true

When true, adds an 'AI Generated' watermark to the bottom-right corner of the output image.

guidance_scale
number
預設值:2.5

Controls how closely the output follows the prompt. Higher values increase adherence but may reduce naturalness. Range: 1.0–10.0. Not supported by Seedream 5.0 (ignored).

seed
integer
預設值:-1

Random seed for reproducible outputs. Range: -1 to 2147483647. Use -1 (default) for random generation. Legacy parameter — ignored by newer models.

sequential_image_generation
enum<string>
預設值:disabled

Controls sequential (multi-image) generation mode.

  • auto: model decides whether to generate a sequence based on the prompt
  • disabled: always generate a single image
可用選項:
auto,
disabled
sequential_image_generation_options
object

Configuration for sequential (multi-image) generation. Only effective when sequential_image_generation is auto.

output_format
enum<string>
預設值:jpeg

Output image file format. Options: png, jpeg.

可用選項:
png,
jpeg

回應

200 - application/json

Successful Response

created
integer
必填

Unix timestamp (seconds) when the image was generated.

data
object[]
必填

Array of generated image objects.

usage
object
必填

Resource usage information for this request.

model
string

The model used for generation.