You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Image Editing
Image generation and editing (Doubao seedream series models)
Copy page
Download PDF
Image generation and editing (Doubao seedream series models)

Operator introduction

Description

Image generation processor (doubao-seedream)

Key features:

  • Text-to-image: Generate an image by entering only the prompt
  • Image-to-image: Input reference_images (one or more reference images) + prompt to generate an image based on the reference images
  • Batch image generation: Use sequential_image_generation="auto" + sequential_image_generation_options={"max_images": N} to generate multiple images at once
  • Supported output formats:
  • response_format="url": Returns image links (links expire within 24 hours after generation)
  • response_format="b64_json": Returns base64 strings
  • Prompt optimization (supported in some versions only): optimize_prompt_options={"mode": "standard" | "fast"}

Model support:

  • doubao-seedream-4.0(version: 250828
  • doubao-seedream-4.5(version: 251128

Input and output specifications:

  • Input columns:
  • Prompt (prompts): pa.array[str]
  • Reference images (reference_images): pa.array[str | list[str]] | None
  • Output columns:
  • Generation result: pa.array[list[str] | None] (Each row outputs a list of image URLs or base64 strings, depending on response_format)

Caution and prerequisites

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.
For details, see Obtain the Base URL. The Examples below are for reference only; when making actual calls, replace the path values with those corresponding to your region.

Daft invocation

Operator parameters

Input

Input column name

Description

prompts

Text prompt. Type is str. Used for text-to-image/image-to-image (in combination with reference_images).

reference_images

Reference images (optional). Used for image-to-image. Supports None / str / list[str]:

  • None: Text-to-image
  • str: Single reference image URL
  • list[str]: Multiple reference image URLs

Output

Returns the list of images generated for each row:

  • Type: list[str] | None
  • When response_format="url", list[str] contains image URLs
  • When response_format="b64_json", list[str] contains base64 strings
  • Returns None for failed/skipped rows

Parameters

If a parameter does not have a default value, it is required

Parameter name

Type

Default value

Description

model

str

Required

Model name, for example

  • doubao-seedream-4.5 / doubao-seedream-4.0

version

int or None

None

Model version number, for example 251128

api_key

str or None

None

Authentication token (token only, without the Bearer prefix). If not provided, reads from environment variable LAS_API_KEY/API_KEY

sequential_image_generation

str

disabled

Single/batch image control:

  • disabled: Single image
  • auto: Batch images

sequential_image_generation_options

dict or None

None

Batch image parameters (only effective when auto), for example: {"max_images": 3}

watermark

bool

true

Whether to add the "AI generated" watermark

size

str

2048x2048

Output size, for example 2048x2048 or 2K (subject to server support)

response_format

str

url

Return format: url / b64_json

optimize_prompt_options

dict or None

None

Prompt optimization configuration (supported in some versions only), for example: {"mode": "standard"}

request_timeout

int

1200

Timeout for a single request (seconds)

max_concurrency

int

100

Maximum concurrency per process

Examples

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                           │
    # ╰────────────────────────────────────────┴────────────────────────────────┴────────────────────────────────╯
        
Last updated: 2026.05.24 15:54:58