Chuyển đến nội dung chính
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>"
}

Tổng quan

Tạo ảnh bằng các model Seedream của ByteDance thông qua endpoint chuẩn tương thích OpenAI /v1/images/generations. Hỗ trợ cả tạo text-to-imageimage-to-image. Để xem đầy đủ danh sách model, hãy xem trang Models. Để xem tài liệu chi tiết về tham số từ nhà cung cấp, hãy xem tài liệu VolcEngine.
Khi sử dụng tính năng tạo tuần tự (nhiều ảnh), hãy đặt sequential_image_generation thành auto và có thể tùy chọn cấu hình sequential_image_generation_options.max_images để giới hạn số lượng ảnh đầu ra. Tổng số ảnh tham chiếu cộng với ảnh được tạo phải ≤ 15.

Image-to-Image

Truyền một hoặc nhiều ảnh tham chiếu qua tham số image (mảng URL hoặc data URI base64) cùng với một prompt văn bản. Hỗ trợ tối đa 14 ảnh tham chiếu.

URL trả về báo AccessDenied?

url được trả về là một liên kết object storage có chữ ký, chứa & và các ký tự đặc biệt khác.
Nếu bạn sao chép JSON thô và dán trực tiếp vào trình duyệt hoặc script, việc escape của shell hoặc cắt ngắn trong terminal có thể làm mất các tham số chữ ký, dẫn đến:
\{"Code":"AccessDenied","Message":"Access Denied","EC":"0003-00000015"\}
Cách khắc phục:
  • curl: pipe qua | jq -r '.data[].url' để trích xuất URL một cách chính xác.
  • Python: dùng result.data[0].url hoặc image["url"] — chuỗi này đã đầy đủ; truyền trực tiếp vào requests.get() hoặc webbrowser.open().
  • JavaScript: tương tự — result.data[0].url.
  • Chung: đảm bảo &% trong URL không bị cắt ngắn hoặc escape hai lần.

Ủy quyền

Authorization
string
header
bắt buộc

Bearer token authentication. Use your CometAPI key.

Nội dung

application/json

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

model
string
mặc định:doubao-seedream-5-0-260128
bắt buộc

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

prompt
string
mặc định:a cat wearing a scarf sitting by the window
bắt buộc

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>
mặc định:url

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

Tùy chọn có sẵn:
url,
b64_json
size
string
mặc định: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
mặc định:true

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

guidance_scale
number
mặc định: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
mặc định:-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>
mặc định: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
Tùy chọn có sẵn:
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>
mặc định:jpeg

Output image file format. Options: png, jpeg.

Tùy chọn có sẵn:
png,
jpeg

Phản hồi

200 - application/json

Successful Response

created
integer
bắt buộc

Unix timestamp (seconds) when the image was generated.

data
object[]
bắt buộc

Array of generated image objects.

usage
object
bắt buộc

Resource usage information for this request.

model
string

The model used for generation.