Image generation processor (doubao-seedream)
promptreference_images (one or more reference images) + prompt to generate an image based on the reference imagessequential_image_generation="auto" + sequential_image_generation_options={"max_images": N} to generate multiple images at onceresponse_format="url": Returns image links (links expire within 24 hours after generation)response_format="b64_json": Returns base64 stringsoptimize_prompt_options={"mode": "standard" | "fast"}doubao-seedream-4.0(version: 250828)doubao-seedream-4.5(version: 251128)prompts): pa.array[str]reference_images): pa.array[str | list[str]] | Nonepa.array[list[str] | None] (Each row outputs a list of image URLs or base64 strings, depending on response_format)Details | Caution and prerequisites |
|---|---|
Costs | Before calling an operator, you need to understand the model invocation costs associated with using the operator. For details, see Large model invocation billing. |
Authentication (API Key) | Before calling an operator, you need to generate an API Key for operator invocation. It is recommended to configure the API Key as an environment variable to ensure safer operator calls. For details, see Obtain and configure API Key. |
BaseURL | Before calling an operator, you need to determine the BaseURL for operator invocation based on the region where your current LAS service is deployed. This is used to configure the path parameter values for operator calls. |
Input column name | Description |
|---|---|
prompts | Text prompt. Type is |
reference_images | Reference images (optional). Used for image-to-image. Supports
|
Returns the list of images generated for each row:
list[str] | Noneresponse_format="url", list[str] contains image URLsresponse_format="b64_json", list[str] contains base64 stringsNone for failed/skipped rowsIf a parameter does not have a default value, it is required
Parameter name | Type | Default value | Description |
|---|---|---|---|
model | str | Required | Model name, for example
|
version | int or None | None | Model version number, for example |
api_key | str or None | None | Authentication token (token only, without the |
sequential_image_generation | str | disabled | Single/batch image control:
|
sequential_image_generation_options | dict or None | None | Batch image parameters (only effective when |
watermark | bool | true | Whether to add the "AI generated" watermark |
size | str | 2048x2048 | Output size, for example |
response_format | str | url | Return format: |
optimize_prompt_options | dict or None | None | Prompt optimization configuration (supported in some versions only), for example: |
request_timeout | int | 1200 | Timeout for a single request (seconds) |
max_concurrency | int | 100 | Maximum concurrency per process |
The following code demonstrates how to use Daft + las_udf to perform batch inference with DoubaoImageGenerate, covering both text-to-image and image-to-image scenarios.
import daft from daft import col from daft.las.functions.ark_llm.doubao_image_generate import DoubaoImageGenerate from daft.las.functions.udf import las_udf import os if os.getenv("DAFT_RUNNER", "native") == "ray": import logging import ray def configure_logging(): logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S.%s".format(), ) logging.getLogger("tracing.span").setLevel(logging.WARNING) logging.getLogger("daft_io.stats").setLevel(logging.WARNING) logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING) ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging}) daft.set_runner_ray() daft.set_execution_config(min_cpu_per_task=0) if __name__ == "__main__": # Environment variables must be configured before running: # - LAS_BASE_URL, create and obtain from the LAS service page # - LAS_INFERENCE_TYPE=image_generate # - LAS_IMAGE_GENERATE_ENDPOINT=/api/v1/online/image/generate (optional, usually default) # - LAS_API_KEY or API_KEY, create and obtain from the LAS service page tos_dir_url = os.getenv("TOS_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com") samples = { "prompt": [ "生成一张长城的照片,真实摄影风格", # Text-to-image "保持构图不变,把图片风格改成水彩画风格", # Image-to-image (with reference_images) None, # Example of an abnormal row: this row outputs None and does not affect other rows ], "reference_images": [ None, f"https://{tos_dir_url}/public/shared_image_dataset/seedream_test_image.png", None, ], } df = daft.from_pydict(samples) df = df.with_column( "images", las_udf( DoubaoImageGenerate, construct_args={ "model": "doubao-seedream-4.5", "version": 251128, "response_format": "url", "watermark": False, "sequential_image_generation": "disabled", "size": "2048x2048", }, batch_size=3, concurrency=3, num_gpus=0, )(col("prompt"), col("reference_images")), ) df.show() # Examples (the results of each large model inference may vary) # ╭────────────────────────────────────────┬────────────────────────────────┬────────────────────────────────╮ # │ prompt ┆ reference_images ┆ images │ # │ --- ┆ --- ┆ --- │ # │ String ┆ String ┆ List[String] │ # ╞════════════════════════════════════════╪════════════════════════════════╪════════════════════════════════╡ # │ Generate a photo of the Great Wall in a realistic photography style ┆ None ┆ [https://ark-content-generati… │ # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ # │ Keep the composition unchanged and change the image style to watercolor ┆ https://ark-project.tos-cn-be… ┆ [https://ark-content-generati… │ # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ # │ None ┆ None ┆ None │ # ╰────────────────────────────────────────┴────────────────────────────────┴────────────────────────────────╯