Streaming Response
Seedream-5.0/4.5/4.0 supports streaming output mode. When you call the Image Generation API with stream set to true, the server will push events to the client in real time via Server-Sent Events (SSE) during the generation process. This section describes the various events the server will push.
Response
SSE streaming response. The response type is text/event-stream.
image_generation.partial_succeeded
Currently only Seedream-5.0/4.5/4.0 support streaming response.
Returned when any image generation succeeds in streaming response mode.
type string
This should be image_generation.partial_succeeded.
model string
The model ID used for this request, in the format <model name>-<version>.
created integer
The Unix timestamp (seconds) of the creation time for this request.
image_index integer
The index of the image corresponding to this event in the current image generation request.
Starting from 0, it increments by 1 regardless of whether the image generation succeeds or fails, i.e., it auto-increments by 1 in both image_generation.partial_succeeded and image_generation.partial_failed events.
url string
The download URL of the image corresponding to this event. Returned when response_format is set to url in the request.
b64_json string
The Base64 encoding of the image corresponding to this event. Returned when response_format is set to b64_json in the request.
size string
The pixel dimensions of the image, in the format <width>×<height>, e.g., 2048×2048.
Response Example
image_generation.partial_failed
Currently only Seedream-5.0/4.5/4.0 support streaming response.
Returned when any image generation fails in streaming response mode.
- If the failure reason is content moderation rejection: It will continue to request the next image generation task, meaning it does not affect the generation flow of other images within the same request.
- If the failure reason is an internal service error (500): It will not continue to request the next image generation task.
type string
This should be image_generation.partial_failed.
model string
The model ID used for this request, in the format <model name>-<version>.
created integer
The Unix timestamp (seconds) of the creation time for this request.
image_index integer
The index of the image corresponding to this event in the current image generation request.
Starting from 0, it increments by 1 regardless of whether the image generation succeeds or fails, i.e., it auto-increments by 1 in both image_generation.partial_succeeded and image_generation.partial_failed events.
error object
The error reason for this event in the current image generation request.
error. code string
Error code.
error. message string
Error message.
Response Example
image_generation.completed
Currently only Seedream-5.0/4.5/4.0 support streaming response.
Returned after all images (whether successful or failed) in the request have been processed. This is the last response event of the streaming response.
type string
This should be image_generation.completed.
model string
The model ID used for this request, in the format <model name>-<version>.
created integer
The Unix timestamp (seconds) of the creation time for this request.
tools array of object
Configured model tools for this request.
tools. type string
The configured tool type.
- web_search: Web search tool.
usage object
Usage information for this request.
usage. generated_images integer
The number of successfully generated images. Images that failed to generate are not included. Billing is based on the number of successfully generated images.
usage. output_tokens integer
Number of tokens spent on the generated image. Calculation logic: sum(image_width * image_height) / 256, then rounded.
usage. total_tokens integer
Total number of tokens consumed for this request. Input tokens are not currently counted, so this matches the output_tokens value.
usage. tool_usage object
Usage information for tools used.
usage.tool_usage. web_search integer
The number of times the web search tool was called. Only returned when web search is enabled.
Response Example
error
Error information for this request, if an error occurred.
error object
The error message returned for this request error.
error. code string
Error code.
error. message string
Error message.