You need to enable JavaScript to run this app.
导航
Stable Diffusion API 调用指南
最近更新时间:2024.05.14 23:51:40首次发布时间:2024.05.14 23:51:40
API Host

Host:maas-api.ml-platform-cn-beijing.volces.com
Region: cn-beijing

Model Inference

目前请求体传入上限需要控制在4M以内

Images

QuickGen/FlexGen

request

字段类型描述
promptstring正向提示词,生成的图与输入内容正相关
negative_promptstring负向提示词,生成的图与输入内容负相关
init_imagebytes传入会启用img2img并增加latency,生成的图与传入图片会有正相关性

control_image_list

List of bytes

config内使用controlnet后才会起效,图片会通过controlnet控制生成内容。
传入内容是一个bytes列表,目前只有list的第一个元素会启用

seedint随机数种子
strengthfloatdenoise强度,输入范围须在(0, 1.0]
heightint生图的height,会向下取整到8的倍数,例如500->496。输入范围须在(0, 1024]
widthint生图的width,会向下取整到8的倍数,例如500->496。输入范围须在(0, 1024]
num_inference_stepsint去噪步长

sampler_name

string

可选为:

["euler", "euler_ancestral", "heun", "heunpp2","lms", "dpm_fast", "dpm_adaptive", "dpmpp_2s_ancestral", "dpmpp_sde", "dpmpp_sde_gpu",
                  "dpmpp_2m", "dpmpp_2m_sde", "dpmpp_2m_sde_gpu", "dpmpp_3m_sde", "dpmpp_3m_sde_gpu", "ddpm", "lcm"]

scheduler

string

可选为:

["normal", "karras", "exponential", "simple", "ddim_uniform"]
cfg_scalefloatThe classifier free guidance(cfg) scale,控制与提示词的相关性,数值越大与提示词相关性越强,过大会导致失真。

response

字段类型描述

data

list

目前开放出的内容为

"data": [
            {
                "url": "",         #f"data:image/jpeg;base64,{encoded_string}"
                "image_bytes": ""  #bytes 未启用
            },
         ]

其中url的返回值是data:image/jpeg;base64,{encoded_string},encoded_string为一个编码为base64的PNG格式图片

Code sample

go
https://github.com/volcengine/volc-sdk-golang/tree/main/example/maas/v2/images

Python
https://github.com/volcengine/volc-sdk-python/blob/main/volcengine/example/maas/v2/image

java
https://github.com/volcengine/volc-sdk-java/tree/main/example/src/main/java/com/volcengine/example/maas/v2/images

Curl

// Request
// quick-gen: https://maas-api.ml-platform-cn-beijing.volces.com/api/v2/endpoint/${YOUR_ENDPOINT_ID}/images/quick-gen
// flex-gen: https://maas-api.ml-platform-cn-beijing.volces.com/api/v2/endpoint/${YOUR_ENDPOINT_ID}/images/flex-gen
curl --request POST \
  --url https://maas-api.ml-platform-cn-beijing.volces.com/api/v2/endpoint/${YOUR_ENDPOINT_ID}/images/flex-gen  \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
    "prompt": "(sfw:1.0),",
    "parameters": {
        "seed": 38,
        "strength": 0.88,
        "num_inference_steps": 10,
        "cfg_scale": 1.0
    },
    "control_image_list":["/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCAAWABQDAREAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAUJ/8QAGRAAAQUAAAAAAAAAAAAAAAAAAAEEFFOi/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAL/xAAVEQEBAAAAAAAAAAAAAAAAAAAAEf/aAAwDAQACEQMRAD8A1TAAAAAABPkObsoVE0kObsoIUkObsoIV/9k="]
}'

// Response
{
    "data": [
                {
                    "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCAAWABQDAREAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAUJ/8QAGRAAAQUAAAAAAAAAAAAAAAAAAAEEFFOi/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAL/xAAVEQEBAAAAAAAAAAAAAAAAAAAAEf/aAAwDAQACEQMRAD8A1TAAAAAABPkObsoVE0kObsoIUkObsoIV/9k=",
                },
             ]
}