Skip to main content

/api/sd/img2img/async

POST /api/sd/img2img/async

This interface provides a service for generating images from images.
Its usage is almost the same as img2img. The difference between this interface and img2img is that this interface will return immediately with task information.
After obtaining the task information, you can use the /api/sd/task/status interface to query the task status and get the result.

Header Parameters
  • Authorization string required
    • Bearer DAN_API_KEY.
    • Public anonymous DAN_API_KEY is:
    sk-000000000000000000000000000000000000000000000000
    Example: Bearer sk-000000000000000000000000000000000000000000000000
  • Content-Type string required

    application/json is required

    Example: application/json
  • Accept string
    Example: application/json
Request Body
  • init_image string required

    The base64-encoded string of your original image

  • denoising_strength number required

    Controls the level of denoising; smaller values yield results that are closer to the original image. Valid range is [0, 1]

  • prompt string required

    A positive prompt that describes what you want the image to be.

  • sampler_name string required

    The name of the sampling algorithm used. refer to the Introduction section for supported list values

  • model string required

    The model used to generate the image. refer to the Introduction section for supported list values

  • width integer required

    The desired width of the resulting image. Valid range is [8, 1024].

  • height integer required

    The desired height of the resulting image. Valid range is [8, 1024].

  • loras array[]
    • A list of LoRAs to be applied and their weights.
    • Format example
    [        
    ["XXXXXXXX", 0.5],
    ["XXXXXXXX", 0.6]
    ]
    • "XXXX" mean LoRA value. Such like "62efe75048d55a096a238c6e8c4e12d61b36bf59e388a90589335f750923954c".
    • Refer to the Introduction section for supported list values.
  • seed integer

    -1 for a random seed.

  • steps integer

    Number of inference steps. Valid range is [20, 60], default 20.

  • cfg_scale integer

    A classifier-free guidance scale; smaller values result in higher quality images, and larger values yield images closer to the provided prompt. Valid range is [1, 30].

  • negative_prompt string

    A negative prompt that describes what you don't want in the image.

  • control_net object[]

    Optional. An array of control net parameters. Theoretically speaking, multiple control net can be applied simultaneously, but currently only up to 1 control net is supported, if you specify more than 1 set of paramters, the rest (i.e. not the first one) will be ignored.

  • Array [
  • image string required

    The reference image file, encoded in base64

  • model string required

    The control net model. Valid options are: sd15_canny and sd15_openpose.

  • preprocess string required

    How the reference image should be preprocessed, you can specify the preprocess method name. Valid options are: canny and openopse.

  • preprocess_param1 unknown

    Optional. Some control net model (e.g. sd15_canny) requires parameters, this is the first parameter. See the table below. If you don't known what to fill in here, just leave it undefined.

    Control net modelTypeDescription
    sd15_cannynumberThe first threshold of canny algorithm. For more information, see opencv doc
    sd15_openposeIgnoredIgnored
  • preprocess_param2 unknown

    Optional. Some control net model (e.g. sd15_canny) requires parameters, this is the second parameter. See the table below. If you don't known what to fill in here, just leave it undefined.

    Control net modelTypeDescription
    sd15_cannynumberThe second threshold of canny algorithm. For more information, see opencv doc
    sd15_openposeIgnoredIgnored
  • weight number

    Before merging control net into the main SD model, all weights will be scaled by this value. Valid range is [0, 2], default value is 1.

  • resize_mode number

    If control image's dimension does not equal to target dimension, stable diffusion will resize the control image. 0 means just resize, 1 means resize and crop, 2 means resize and fill, otherwise use default value: 0.

  • guidance_start number

    The control net will be applied in [guidance_start, guidance_end] percents inference steps. Valid range is [0, 1], default: 0.

  • guidance_end number

    The control net will be applied in [guidance_start, guidance_end] percents inference steps. Valid range is [0, 1], default: 1.

  • guessmode bool

    Optional. Default: false. If true, you can just remove all prompts, and then the control net encoder will recognize the content of the input control map. For this mode, we recommend to use 50 steps and guidance scale between 3 and 5.

  • ]
  • inpaint object

    If you want to regenerate part of your image, this will be what you want.

  • mask string required

    This is a base64 encoded image of a mask which defined where you want to regenerate.

  • mask_blur number

    Before regenerating, the image and mask will be gaussian blured by this radius. Valid range is [0, 64], default 0.

  • mask_mode number

    0 means regenerate where is masked; 1 means regenerate where is not masked.

  • inpaint_area number

    0 means regenerate whole image, then paste corresponding area back. 1 means only the masked area will be regenereate, then paste corresponding area back.

Responses

Instead of returning the final result, this API returns the taskId and queueing information. You can use /api/sd/task/status to query the latest status of the task or get the final result.

Schema
  • code integer required
  • data object required
  • taskId string required
  • queuePosition integer required

    The length of the queue of pending tasks, when status != 0, queuePosition = 0

  • status integer required

    0:pending, 1:processing, 2:success, 3:fail

  • message string required
Loading...