Skip to main content

/api/sd/txt2img

POST /api/sd/txt2img

This interface provides a service for generating images from text.

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
  • 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.

  • ]
  • upscale object

    Optional, add it if you want to upscale the result.

  • denoising_strength number

    Controls the level of denoising; smaller values yield results that are closer to the original generated image, but may be blurry; larger values may lead the output looks different from the original generated image and may looks strange. Valid range is [0, 1], but I recomment you make it between 0.4 and 0.6.

  • scale number

    The upscale rate. Valid range is (1.0, 2.0].

  • upscaler string

    The upscaler algorithm name, Currently only Latent is supported.

Responses

The generated image is returned here.

Schema
  • code integer required
  • data object required
  • images string[] required

    string of base 64 encoded png file. When status = 2, a list of images is returned

  • 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...