典名词元DMTOKENSHome
API DocumentationThird-Party Tools Tutorial
AI Model APIImageDoubao

Image Generation

POST/api/v1/image/generation

Header Parameters

Authorization*string

Use Bearer Token authentication. Format: Authorization: Bearer sk-xxxxxx

Request Body

application/json

model*string

Model name, fixed value: doubao-seedream-4-0-250828 doubao-seedream-4-5-251128 doubao-seedream-5-0-260128

Value in"doubao-seedream-4-0-250828" | "doubao-seedream-4-5-251128" | "doubao-seedream-5-0-260128"
prompt*string

Prompts for image generation, supporting both Chinese and English. It is recommended to keep the prompt under 300 Chinese characters or 600 English words. Excessive length can dilute the information, causing the model to overlook details and focus only on the main points, resulting in missing elements in the generated image.

image?string|array<string>

Input image information, supporting URL or Base64 encoding, where doubao-seedream-5.0-lite/4.5/4.0 supports single or multiple image inputs. Requirements for passing a single image: Image formats: jpeg, png (doubao-seedream-5.0-lite/4.5/4.0 models newly support webp, bmp, tiff, gif, heic, and heif formats). Aspect ratio (width/height) range: [1/16, 16] (applicable models: doubao-seedream-5.0-lite/4.5/4.0). Width and height (px) > 14. Size: up to 30MB. Total pixels: up to 6000x6000=36000000 px (limits the product of the width and height in pixels for a single image, rather than limiting the width or height individually). doubao-seedream-5.0-lite/4.5/4.0 supports up to 14 reference images.

size?string

Specify the size information for the generated image. Doubao-Seedream-5.0-lite: Method 1 | Specify the resolution of the generated image, and describe the aspect ratio, shape, or purpose of the image in natural language in the prompt. The model will ultimately determine the size of the generated image. Optional values: 2K, 3K, 4K. Method 2 | Specify the width and height pixel values of the generated image: Default value: 2048x2048. Total pixel value range: [2560x1440=3686400, 4096x4096=16777216]. Aspect ratio range: [1/16, 16]. Note: The total pixel limit applies to the product of the image's width and height in pixels, rather than restricting the individual values of width or height. Valid example: 3750x1250. The total pixel value 3750x1250=4687500 meets the range requirement of [3686400, 16777216]; the aspect ratio 3750/1250=3 meets the range requirement of [1/16, 16], so this example value is valid. Invalid example: 1500x1500. The total pixel value 1500x1500=2250000 does not meet the minimum requirement of 3686400; the aspect ratio 1500/1500=1 meets the range requirement of [1/16, 16], but since it does not satisfy both limits simultaneously, this example value is invalid. Recommended width and height pixel values: For 2K resolution, aspect ratio/width and height pixel values: 1:1->2048x2048, 4:3->2304x1728, 3:4->1728x2304, 16:9->2848x1600, 9:16->1600x2848, 3:2->2496x1664, 2:3->1664x2496, 21:9->3136x1344. For 3K resolution, aspect ratio/width and height pixel values: 1:1->3072x3072, 4:3->3456x2592, 3:4->2592x3456, 16:9->4096x2304, 9:16->2304x4096, 2:3->2496x3744, 3:2->3744x2496, 21:9->4704x2016. For 4K resolution, aspect ratio/width and height pixel values: 1:1->4096x4096, 3:4->3520x4704, 4:3->4704x3520, 16:9->5504x3040, 9:16->3040x5504, 2:3->3328x4992, 3:2->4992x3328, 21:9->6240x2656. Doubao-Seedream 4.5: Method 1 | Specify the resolution of the generated image, and describe the aspect ratio, shape, or purpose of the image in natural language in the prompt. The model will ultimately determine the size of the generated image. Optional values: 2K, 4K. Method 2 | Specify the width and height pixel values of the generated image: Default value: 2048x2048. Total pixel value range: [2560x1440=3686400, 4096x4096=16777216]. Aspect ratio range: [1/16, 16]. Note: The total pixel limit applies to the product of the image's width and height in pixels, rather than restricting the individual values of width or height. Valid example: 3750x1250. The total pixel value 3750x1250=4687500 meets the range requirement of [3686400, 16777216]; the aspect ratio 3750/1250=3 meets the range requirement of [1/16, 16], so this example value is valid. Invalid example: 1500x1500. The total pixel value 1500x1500=2250000 does not meet the minimum requirement of 3686400; the aspect ratio 1500/1500=1 meets the range requirement of [1/16, 16], but since it does not satisfy both limits simultaneously, this example value is invalid. Recommended width and height pixel values: For 2K resolution, aspect ratio/width and height pixel values: 1:1->2048x2048, 4:3->2304x1728, 3:4->1728x2304, 16:9->2848x1600, 9:16->1600x2848, 3:2->2496x1664, 2:3->1664x2496, 21:9->3136x1344. For 4K resolution, aspect ratio/width and height pixel values: 1:1->4096x4096, 3:4->3520x4704, 4:3->4704x3520, 16:9->5504x3040, 9:16->3040x5504, 2:3->3328x4992, 3:2->4992x3328, 21:9->6240x2656. Doubao-Seedream 4.0: Method 1 | Specify the resolution of the generated image, and describe the aspect ratio, shape, or purpose of the image in natural language in the prompt. The model will ultimately determine the size of the generated image. Optional values: 1K, 2K, 4K. Method 2 | Specify the width and height pixel values of the generated image: Default value: 2048x2048. Total pixel value range: [1280x720=921600, 4096x4096=16777216]. Aspect ratio range: [1/16, 16]. Note: When using Method 2, both the total pixel value range and the aspect ratio range must be satisfied simultaneously. The total pixel limit applies to the product of the image's width and height in pixels, rather than restricting the individual values of width or height. Valid example: 1600x600. The total pixel value 1600x600=960000 meets the range requirement of [921600, 16777216]; the aspect ratio 1600/600=8/3 meets the range requirement of [1/16, 16], so this example value is valid. Invalid example: 800x800. The total pixel value 800x800=640000 does not meet the minimum requirement of 921600; the aspect ratio 800/800=1 meets the range requirement of [1/16, 16], but since it does not satisfy both limits simultaneously, this example value is invalid. Recommended width and height pixel values: For 1K resolution, aspect ratio/width and height pixel values: 1:1->1024x1024, 4:3->1152x864, 3:4->864x1152, 16:9->1280x720, 9:16->720x1280, 3:2->1248x832, 2:3->832x1248, 21:9->1512x648. For 2K resolution, aspect ratio/width and height pixel values: 1:1->2048x2048, 4:3->2304x1728, 3:4->1728x2304, 16:9->2848x1600, 9:16->1600x2848, 3:2->2496x1664, 2:3->1664x2496, 21:9->3136x1344. For 4K resolution, aspect ratio/width and height pixel values: 1:1->4096x4096, 3:4->3520x4704, 4:3->4704x3520, 16:9->5504x3040, 9:16->3040x5504, 2:3->3328x4992, 3:2->4992x3328, 21:9->6240x2656.

seed?integer

Random seed, used to control the randomness of model-generated content. The value range is [-1, 2147483647]. (This parameter is only supported by doubao-seedream-3.0-t2i/seededit-3.0-i2i)

sequential_image_generation?string

Controls whether to disable the multi-image generation feature (this parameter is only supported by doubao-seedream-5.0-lite/4.5/4.0). auto: Automatic judgment mode, where the model autonomously determines whether to return a multi-image set and the number of images it contains based on the user-provided prompt. disable: Disables the multi-image generation feature, and the model will only generate a single image.

sequential_image_generation_options?object

Configuration for the multi-image generation feature. Takes effect only when sequential_image_generation is set to auto. (This parameter is supported only by doubao-seedream-5.0-lite/4.5/4.0)

max_images?integer

Specify the maximum number of images that can be generated for this request. Value range: [1, 15].

tools?array<object>

Configure the tools to be called by the model. (This parameter is only supported by doubao-seedream-5.0-lite.)

[]?object
type?string

Specify the type of tool to use. (web_search: Web search feature.)

stream?boolean

Controls whether to enable streaming output mode. (This parameter is only supported by doubao-seedream-5.0-lite/4.5/4.0) false: Non-streaming output mode, waits for all images to be fully generated before returning all information at once. true: Streaming output mode, immediately returns the result of each image. Streaming output mode is effective in both single-image and multi-image generation scenarios.

output_format?string

Specify the file format of the generated image (only supported by doubao-seedream-5.0-lite). Valid values: png, jpeg.

response_format?string

Specify the return format for the generated image. Two return methods are supported: url: returns an image download URL, which is valid for 24 hours after generation, so please download it promptly. b64_json: returns the image data in JSON format as a Base64-encoded string.

watermark?boolean

Whether to add a watermark to the generated image. false: Do not add a watermark. true: Add an "AI-generated" watermark in the bottom right corner of the image.

optimize_prompt_options?object

Configuration of the prompt optimization feature. (This parameter is only supported by doubao-seedream-5.0-lite/4.5/4.0)

mode?string

Set the mode used for the prompt optimization feature. standard: Standard mode, which generates higher-quality content but takes longer. fast: Fast mode, which generates content faster but with average quality; currently not supported by doubao-seedream-5.0-lite/4.5.

Response Body

application/json

Success

TypeScript Definitions

Use the response body type in TypeScript.

code*integer

Status Code

data*object

Data Object

urls*array<string>

Result Set

[]?string
usage*object

Usage Information

images*integer

Number of Images

seconds*integer

Video Seconds

input_tokens*integer

Input Token Count

total_tokens*integer

Total Token Count

output_tokens*integer

Output Token Count

expired*string

Validity Period

task_id*string

Task ID

task_status*string

Task Status

message*string

Status Information

request_id*string

Request ID

curl -X POST "https://api.ygw.ai/api/v1/image/generation" \  -H "Authorization: string" \  -H "Content-Type: application/json" \  -d '{    "model": "doubao-seedream-4-0-250828",    "prompt": "string"  }'
{
  "code": 0,
  "data": {
    "urls": [
      "string"
    ],
    "usage": {
      "images": 0,
      "seconds": 0,
      "input_tokens": 0,
      "total_tokens": 0,
      "output_tokens": 0
    },
    "expired": "string",
    "task_id": "string",
    "task_status": "string"
  },
  "message": "string",
  "request_id": "string"
}