作者:王佳、江昱、筱姜

Stable Diffusion 模型,现已成为 AI 职业从传统深度学习年代走向 AIGC 年代的标志性里程碑。越来越多的开发者借助 stable-diffusion-webui(以下简称 SDWebUI)能力进行 AI 绘画范畴创业或者事务上新,取得高流量及商业价值,可是面临多客户、高并发的复杂场景,运用原生 Stable Diffusion API 会面临以下应战:

1. 显卡资源昂贵且难以购买,GPU 卡池办理技能门槛高: 高性能的 GPU 资源不只价格昂贵,并且往往难以大规模收购。此外,GPU 卡池的有用办理和维护需要复杂的技能支撑,也带来了额定的应战。

2. 难以应对高并发: 原生的 Stable Diffusion API 选用单实例推理形式,其并发处理能力有限。在面临高并发场景时,尤其是并发恳求具有大的波动性时,资源配置难以精确猜测,然后或许导致体系过错和事务中断。

3. 多模型切换难度大: 当不同模型的恳求在高并发条件下一起发送到同一实例时,频频的模型切换成为一个明显的瓶颈。这种切换不只耗费巨大,并且影响了推理功率,使得多模型布置在实践运用中变得复杂和低效。

为了协助用户高功率、低本钱应对企业级复杂场景,函数核算团队正式推出 Stable Diffusion API Serverless 版解决计划,经过运用该计划,用户能够充分运用 Stable Diffusion Serverless 技能优势快速开发上线 AI 绘画运用,期待为广阔开发者 AI 绘画创业及变现供给思路。

根据 Stable Diffusion API Serverless 版解决计划搭建的,布置 AI 艺术字运用活动炽热进行中!生成姓氏头像赢新春好礼,欢迎点击 “阅览原文” 体会。

活动链接:developer.aliyun.com/topic/fcnew…

运用场景

Stable Diffusion API Serverless 版别供给了多种或许性,以习惯不同的运用场景和事务需求。

1. 个性化内容创造: 运用 Stable Diffusion API,内容创造者和数字艺术家能够快速生成个性化的艺术作品和图画。例如,艺术家能够依据用户的描述或关键词,即时创造出共同的艺术风格图画,完成个性化的艺术创造和用户互动。

2. 广告和商场营销: 在广告和商场营销范畴,Stable Diffusion API 能够用来生成吸引人的视觉内容,然后增强广告作用。例如,企业能够依据产品特性和目标受众的偏好,快速创立多样化的广告图画,以提高品牌形象和商场吸引力。

3. 游戏和文娱工业: 在游戏和文娱工业中,Stable Diffusion API 能够被用来增强用户体会,经过生成共同的游戏背景、角色和元从来丰厚游戏国际。例如,游戏开发者能够运用 API 来设计共同的游戏环境和角色,为玩家供给更丰厚和个性化的游戏体会。

计划优势

Stable Diffusion API Serverless 版别在多方面供给了明显的优势,特别是在简化布置、本钱功率、推理功率、资源办理、并发处理和用户体会上。以下是这些优势的详细表现:

1. 上手简略,快速布置: 借助阿里云 Serverless 运用中心,用户能够完成快速布置,大幅简化传统 Stable Diffusion API 的复杂布置流程。这使得开发者能够快速上手并专心于运用的开发和立异。

2. 计费灵敏,本钱效益明显: Serverless 版别供给按需计费形式,用户仅需为实践运用的资源付费,无需预先投资昂贵的硬件。这种灵敏的计费方法大幅降低了整体本钱,尤其合适资源需求波动的场景。

3. 优化的模型办理,提高推理功率: 经过优化多模型的办理和布置,Serverless 版别有用提高了推理功率。减少模型切换和加载的频率,确保了快速、安稳的推理性能。

4. 主动扩缩容,高效资源办理: 运用主动扩缩容机制,Serverless 版别依据实时需求灵敏调整资源运用,防止了资源浪费并保障了服务的连续性。

5. 异步处理和排队机制,优化并发处理: Serverless 版别经过引进异步处理和高效排队机制,克服了高并发场景下的应战,保证了服务的高可用性和响应速度。

总归,Stable Diffusion API Serverless 版别集成了阿里云 Serverless 技能的核心优势,供给了一种高效、本钱有用且用户友好的解决计划,为开发者在 AI 绘画和其他 AI 运用范畴的立异和商业化供给支撑。

计划架构

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

名词解释:

  • admin,供给模型办理,包含模型上传 删去等
  • webui,供给界面化的调试功用,首要是模型和参数调整、插件装置等,到达更好出图作用
  • proxy,API 的前端服务,供给非推理之外的功用,首要包含成果、进展查询等
  • control,操控推理实例最大并发实例数。经过操控 control 的并发度,操控下游多函数推理服务的实例数
  • agent sd-api,推理服务
    • 一个模型(checkpoints)创立一个函数,每个函数支撑弹多个实例,总的实例数经过 control 并发度进行操控。
    • 之所以一个模型(checkpoints)创立一个函数,是为了防止多模型并发推理运用场景下的模型间的频频切换带来的开销,提高推理功率,从而到达给用户降本的作用
    • sd_ 开头的都是动态创立函数

留意事项:

  • 运用过程中会动态创立 sdapi 函数,每个 checkpoint 对应一个函数,并且会在 ots 中 function 表中记录对应的函数概况。假如想删去动态创立的函数,请清理对应 ots 中 function 表的函数记录,防止后续调用出问题
  • 异步推理成果会默许存放到 oss 中,存放到 image/default 途径下

布置Stable Diffusion APIServerless版

准备工作

注册云产品:

  • 函数核算 FC:用于供给 CPU GPU 算力
  • 目标存储 OSS:用于保存输出图片成果;一起存储恳求中的中转图片,便面直接传递 base64 导致超出恳求的 body 限制
  • 表格存储 Tablestore:用于存储推理成果、函数信息等
  • 文件存储 NAS:用于多节点同享存储空间

布置 Stable Diffusion Serverless API

  1. 进入函数核算 FC 3.0 操控台,点击左侧“运用”进行运用中心。假如老用户曾经创立过运用,点击“创立运用”也可直达运用中心

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

  1. 点击“人工智能”分类,挑选“fc-stable-diffusion-v3”模版,点击“立即创立”

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

  1. 确定详细参数进行运用创立,您能够重点留意三个信息的填写,其他运用默许值即可。
  • 地域:挑选距离您较近的区域,假如后续有更多出图需要,能够考虑挑选海外区域,以便利 hugging face 等网站的连接
  • 命名空间:假如您现已布置多个 SD,请在这儿进行区分,新用户可运用默许值
  • 绘图类型:挑选艺术字

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

  1. 初次运用需要额定的权限,能够依据提示“前往授权”

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

  1. 点击“创立运用”,勾选了解内容,点击“同意并持续布置”,等待大约 1 分钟

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

  1. 生成 WebUI 域名(留意保护此链接不别传避免耗费您账户的费用),不要点击链接,直接切换到右侧“Serverless API”

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

  1. 点击“Serverless API”点击“初始化 Serverless API”,再次承认现已注册“FC、OSS、OTS”三款产品,勾选“已阅览”点击“下一步”

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

  1. 进行“角色名”的授权,勾选“启用 Serverless API”,OTS 实例创立方法能够默许“主动创立”,承认后等待大约 30 秒

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

  1. 创立好 Serverless API,就能够参阅下面 API 定义开端进行测验生产运用

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

StableDiffusion API Serverless 版支撑的 API 概况

API 接口首要分两类:

  • 非推理类接口,用于成果和进展查询、模型办理、运用重启等
  • 推理类接口,文生图、图生图、图片扩大等

详细能够参阅:github.com/devsapp/ser…

1. 模型相关 API

模型的注册、更新和删去都经过 admin 界面化操作即可

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

1.1获取模型列表 API

GET /modelsresponse:

[
  {
  "type": "stableDiffusion",
  "name": "model_v1",
  "ossPath": "/path/to/oss/model_v1",
  "etag": "3f786850e387550fdab836ed7e6dc881de23001b",
  "status": "loaded", // registering|loading|loaded|unloaded|deleted
  "registeredTime": "2023-01-01T12:00:00Z",
  "lastModificationTime": "2023-01-10T12:00:00Z"
  }
]

2. 推理相关 API

支撑文生图和图生图

支撑同步形式和异步形式两种,默许同步形式

  • 同步形式:header 中增加 {“Request-Type”:”sync”},不增加默许为同步形式
  • 异步形式:header 中增加 {“Request-Type”:”async”}

推理成果会同步存储到 oss 和 ots 中,能够经过 /tasks/{taskId}/result 接口获取推理成果(oss 图片地址、推理参数等)

2.1txt2img

POST /txt2img

request:其间 stable_diffusion_model, sd_vae 新加字段,其他保持跟原生 webui:txt2img 保持一致

其间 controlnet 中图片支撑两种格局:

  • 图片的 base64 编码:补白:base64 恳求存在超越 FC 异步恳求 body 上限或许,假如超越上限请运用 oss 方法
  • oss 上图片途径,支撑 png/jpg/jpeg
{
  "stable_diffusion_model": "diffusion_v1", // sd主模型
  "sd_vae": "vae_v1", // vae模型
  "enable_hr": true,
  "denoising_strength": 0.5,
  "firstphase_width": 640,
  "firstphase_height": 480,
  "hr_scale": 2,
  "hr_upscaler": "upscale_method_v1",
  "hr_second_pass_steps": 10,
  "hr_resize_x": 1280,
  "hr_resize_y": 960,
  "hr_sampler_name": "sampler_v1",
  "hr_prompt": "High resolution prompt",
  "hr_negative_prompt": "Negative high resolution prompt",
  "prompt": "Mountain landscape during sunset",
  "styles": [
    "style1",
    "style2"
  ],
  "seed": 123456,
  "subseed": 789,
  "subseed_strength": 5,
  "seed_resize_from_h": 480,
  "seed_resize_from_w": 640,
  "sampler_name": "sampler_v2",
  "batch_size": 32,
  "n_iter": 1000,
  "steps": 100,
  "cfg_scale": 1,
  "width": 640,
  "height": 480,
  "restore_faces": true,
  "tiling": false,
  "do_not_save_samples": false,
  "do_not_save_grid": false,
  "negative_prompt": "Avoid mountains",
  "eta": 5,
  "s_min_uncond": 1,
  "s_churn": 3,
  "s_tmax": 10,
  "s_tmin": 1,
  "s_noise": 2,
  "override_settings": {
    "settingKey": "settingValue"
  },
  "override_settings_restore_afterwards": true,
  "script_args": [
    {
      "argKey": "argValue"
    }
  ],
  "sampler_index": "index_v1",
  "script_name": "script_v1",
  "send_images": true,
  "save_images": true,
  "alwayson_scripts": {
    "controlnet": {
        "args": [
            {
                "image":"base64srcimg|image/default/xxxx.png", //支撑传输base64和oss对应图片path(png/jpg/jpeg)
                "enabled":True,
                "module":"canny",
                "model":"control_v11p_sd15_scribble",
                "weight":1,
                "resize_mode":"Crop and Resize",
                "low_vram":False,
                "processor_res":512,
                "threshold_a":100,
                "threshold_b":200,
                "guidance_start":0,
                "guidance_end":1,
                "pixel_perfect":True,
                "control_mode":"Balanced",
                "input_mode":"simple",
                "batch_images":"",
                "output_dir":"",
                "loopback":False
            }
        ]
    }
  }
}

response:

{
  "status":"succeeded", // 推理使命状况
  "taskId":"1HmyrbhBJD", // 推理使命id, 后续成果获取,进展查询,撤销推理都依赖于该id
  "ossUrl" :["xxxxx"] // 同步形式下回来的oss上图片暂时地址(有必定时效性)
}

2.2img2img

POST /img2img

request:其间 stable_diffusion_model,sd_vae 新加字段,其他保持跟原生 webui:img2img 保持一致其间 controlnet 和 init_images 中图片支撑两种格局:

  • 图片的 base64 编码:补白:base64 恳求存在超越 FC 异步恳求 body 上限或许,假如超越上限请运用 oss 方法
  • oss 上图片途径,支撑 png/jpg/jpeg
{
  "stable_diffusion_model": "diffusion_v2",  // sd主模型
  "sd_vae": "vae_v2",  // vae模型
  "init_images": [  //支撑base64、oss图片地址两种格局
    "Base64SrcImg|ossPath",
    "Base64SrcImg|ossPath"
  ],
  "resize_mode": 1,
  "denoising_strength": 0.8,
  "image_cfg_scale": 2,
  "mask": "mask_path",
  "mask_blur": 3,
  "mask_blur_x": 2,
  "mask_blur_y": 2,
  "inpainting_fill": 4,
  "inpaint_full_res": true,
  "inpaint_full_res_padding": 2,
  "inpainting_mask_invert": 0,
  "initial_noise_multiplier": 5,
  "prompt": "Forest landscape",
  "styles": [
    "styleA",
    "styleB"
  ],
  "seed": 654321,
  "subseed": 987,
  "subseed_strength": 6,
  "seed_resize_from_h": 480,
  "seed_resize_from_w": 640,
  "sampler_name": "sampler_v3",
  "batch_size": 64,
  "n_iter": 500,
  "steps": 50,
  "cfg_scale": 2,
  "width": 1280,
  "height": 960,
  "restore_faces": false,
  "tiling": true,
  "do_not_save_samples": false,
  "do_not_save_grid": true,
  "negative_prompt": "Avoid forests",
  "eta": 6,
  "s_min_uncond": 2,
  "s_churn": 4,
  "s_tmax": 11,
  "s_tmin": 2,
  "s_noise": 3,
  "override_settings": {
    "settingKeyV2": "settingValueV2"
  },
  "override_settings_restore_afterwards": false,
  "script_args": [
    "arg1",
    "arg2"
  ],
  "sampler_index": "index_v2",
  "include_init_images": false,
  "script_name": "script_v2",
  "send_images": false,
  "save_images": true,
  "alwayson_scripts": {
    "controlnet": {
        "args": [
            {
                "image":"base64srcimg|ossPath", //支撑base64、oss图片地址两种格局
                "enabled":True,
                "module":"canny",
                "model":"control_v11p_sd15_scribble",
                "weight":1,
                "resize_mode":"Crop and Resize",
                "low_vram":False,
                "processor_res":512,
                "threshold_a":100,
                "threshold_b":200,
                "guidance_start":0,
                "guidance_end":1,
                "pixel_perfect":True,
                "control_mode":"Balanced",
                "input_mode":"simple",
                "batch_images":"",
                "output_dir":"",
                "loopback":False
            }
        ]
    }
  }
}

response:

{
  "status":"succeeded", // 推理使命状况
  "taskId":"1HmyrbhBJD", // 推理使命id, 后续成果获取,进展查询,撤销推理都依赖于该id
  "ossUrl" :["xxxxx"] // 同步形式下回来的oss上图片暂时地址(有必定时效性)
}

3. 图片处理 API

3.1图片扩大

图片扩大,支撑单张图片处理,暂不支撑批量处理。respone 回来 taskId,调用获取成果接口获取图片地址即可

其间 image 支撑两种格局:

  • 图片的 base64
  • oss 上图片途径,支撑 png/jpg/jpeg

POST /extra_images

request:

{
    "resize_mode": 0,
    "show_extras_results": True,
    "gfpgan_visibility": 0,
    "codeformer_visibility": 0,
    "codeformer_weight": 0,
    "upscaling_resize": 4,
    "upscaling_crop": True,
    "upscaler_1": "Lanczos",
    "upscaler_2": "None",
    "extras_upscaler_2_visibility": 0,
    "upscale_first": False,
    "image":self.file_to_base64(),
    "image" : "base64|ossPath" //支撑传输base64和oss对应图片path(png/jpg/jpeg)
}

response:

{
    "status":"succeeded",
    "taskId":"TovRrc0Jnr",
    "ossUrl" :["xxxxx"] // 同步形式下回来的oss上图片暂时地址(有必定时效性)
}

4. 成果相关 API

4.1获取成果

经过 taskid 获取推理成果

GET /tasks/{taskId}/result

response:

{
    "images":[
        "images/admin/Xldf9m80im_1.png" // images 推理成果, oss图片path
    ],
    "ossUrl" :["xxxxx"], oss上图片暂时地址(有必定时效性)
    "info":{                  // info 推理过程中产生信息
        "all_negative_prompts":[
            ""
        ],
        "all_prompts":[
            "cute beautiful blonde, very detailed, 21 years old, inoccent face, natural wave hair, blue eyes, high-res, masterpiece, best quality,intricate details, highly detailed,sharp focus, detailed skin,realistic skin texture,texture, detailed eyes u003clora:shuimobysimV3:1u003e"
        ],
        "all_seeds":[
            3896184641
        ],
        "all_subseeds":[
            6579621
        ],
        "alwayson_scripts":"",
        "batch_size":1,
        "cfg_scale":7,
        "clip_skip":1,
        "denoising_strength":0,
        "do_not_save_grid":false,
        "do_not_save_samples":false,
        "enable_hr":false,
        "eta":null,
        "extra_generation_params":{
        },
        "face_restoration_model":null,
        "firstphase_height":0,
        "firstphase_width":0,
        "height":512,
        "hr_negative_prompt":"",
        "hr_prompt":"",
        "hr_resize_x":0,
        "hr_resize_y":0,
        "hr_sampler_name":null,
        "hr_scale":2,
        "hr_second_pass_steps":0,
        "hr_upscaler":null,
        "index_of_first_image":0,
        "infotexts":[
            "cute beautiful blonde, very detailed, 21 years old, inoccent face, natural wave hair, blue eyes, high-res, masterpiece, best quality,intricate details, highly detailed,sharp focus, detailed skin,realistic skin texture,texture, detailed eyes u003clora:shuimobysimV3:1u003enSteps: 50, Sampler: Euler, CFG scale: 7.0, Seed: 3896184641, Size: 512x512, Model hash: 18ed2b6c48, Model: xxmix9realistic_v40, Denoising strength: 0, Version: v1.5.1"
        ],
        "is_using_inpainting_conditioning":false,
        "job_timestamp":"20230828073155",
        "n_iter":1,
        "negative_prompt":"",
        "override_settings":{
        },
        "override_settings_restore_afterwards":true,
        "prompt":"cute beautiful blonde, very detailed, 21 years old, inoccent face, natural wave hair, blue eyes, high-res, masterpiece, best quality,intricate details, highly detailed,sharp focus, detailed skin,realistic skin texture,texture, detailed eyes u003clora:shuimobysimV3:1u003e",
        "restore_faces":false,
        "s_churn":0,
        "s_min_uncond":0,
        "s_noise":1,
        "s_tmax":null,
        "s_tmin":0,
        "sampler_index":"Euler",
        "sampler_name":"Euler",
        "save_images":false,
        "script_args":[
        ],
        "script_name":null,
        "sd_model_hash":"18ed2b6c48",
        "seed":3896184641,
        "seed_resize_from_h":-1,
        "seed_resize_from_w":-1,
        "send_images":true,
        "steps":50,
        "styles":[
        ],
        "subseed":6579621,
        "subseed_strength":0,
        "tiling":false,
        "width":512
    },
    "parameters":{           // parameters实践推理过程中的参数
        "all_negative_prompts":[
            ""
        ],
        "all_prompts":[
            "cute beautiful blonde, very detailed, 21 years old, inoccent face, natural wave hair, blue eyes, high-res, masterpiece, best quality,intricate details, highly detailed,sharp focus, detailed skin,realistic skin texture,texture, detailed eyes u003clora:shuimobysimV3:1u003e"
        ],
        "all_seeds":[
            3896184641
        ],
        "all_subseeds":[
            6579621
        ],
        "alwayson_scripts":"",
        "batch_size":1,
        "cfg_scale":7,
        "clip_skip":1,
        "denoising_strength":0,
        "do_not_save_grid":false,
        "do_not_save_samples":false,
        "enable_hr":false,
        "eta":null,
        "extra_generation_params":{
        },
        "face_restoration_model":null,
        "firstphase_height":0,
        "firstphase_width":0,
        "height":512,
        "hr_negative_prompt":"",
        "hr_prompt":"",
        "hr_resize_x":0,
        "hr_resize_y":0,
        "hr_sampler_name":null,
        "hr_scale":2,
        "hr_second_pass_steps":0,
        "hr_upscaler":null,
        "index_of_first_image":0,
        "infotexts":[
            "cute beautiful blonde, very detailed, 21 years old, inoccent face, natural wave hair, blue eyes, high-res, masterpiece, best quality,intricate details, highly detailed,sharp focus, detailed skin,realistic skin texture,texture, detailed eyes u003clora:shuimobysimV3:1u003enSteps: 50, Sampler: Euler, CFG scale: 7.0, Seed: 3896184641, Size: 512x512, Model hash: 18ed2b6c48, Model: xxmix9realistic_v40, Denoising strength: 0, Version: v1.5.1"
        ],
        "is_using_inpainting_conditioning":false,
        "job_timestamp":"20230828073155",
        "n_iter":1,
        "negative_prompt":"",
        "override_settings":{
        },
        "override_settings_restore_afterwards":true,
        "prompt":"cute beautiful blonde, very detailed, 21 years old, inoccent face, natural wave hair, blue eyes, high-res, masterpiece, best quality,intricate details, highly detailed,sharp focus, detailed skin,realistic skin texture,texture, detailed eyes u003clora:shuimobysimV3:1u003e",
        "restore_faces":false,
        "s_churn":0,
        "s_min_uncond":0,
        "s_noise":1,
        "s_tmax":null,
        "s_tmin":0,
        "sampler_index":"Euler",
        "sampler_name":"Euler",
        "save_images":false,
        "script_args":[
        ],
        "script_name":null,
        "sd_model_hash":"18ed2b6c48",
        "seed":3896184641,
        "seed_resize_from_h":-1,
        "seed_resize_from_w":-1,
        "send_images":true,
        "steps":50,
        "styles":[
        ],
        "subseed":6579621,
        "subseed_strength":0,
        "tiling":false,
        "width":512
    },
    "taskId":"Xldf9m80im"
}

4.2查询进展

推理进展查询

GET /tasks/{taskId}/progress,同 webui 中的 progress

response:

{
    "currentImage":"",
    "etaRelative":0.10594336,
    "progress":0.99,
    "state":{
        "interrupted":false,
        "job":"scripts_txt2img",
        "job_count":1,
        "job_no":0,
        "job_timestamp":"20230828073155",
        "sampling_step":49,
        "sampling_steps":50,
        "skipped":false
    },
    "taskId":"Xldf9m80im"
}

4.3撤销推理

撤销对应使命POST /tasks/{taskId}/cancellation

5. 动态资源相关 API

5.1获取动态创立 sd 函数

获取动态创立的 sdapi 函数

GET /list/sdapi/fucntions

response:

{
    "functions":[
        {
            "functionName":"sd_739f6de96fdbb66704296cd11ab3f96c182fde7f2cbbb127185b184a43414dea",
            "model":"chilloutmix_NiPrunedFp16Fix.safetensors"
        }
    ],
    "status":"success"
}

5.2更新动态创立 sd 资源

批量更新动态创立 sd 函数资源,比如镜像、环境变量、cpu、显存等。其间 models 不指定代表更新一切动态创立 sd 函数资源

POST /batch_update_sd_resource

request:

{
    "models": ["chilloutmix_NiPrunedFp16Fix.safetensors"],
    "cpu": 4,
    "memorySize": 16384, // MB
    "image": "xxx",
    "extraArgs": "--api --nowebui --no-hashing",
    "instanceType": "fc.gpu.ampere.1",
    "gpuMemorySize": 16384, // MB
    "timeout": 60, //s
    "env": {},
    "vpcConfig":{
        "securityGroupId":"xxx",
        "vSwitchIds":[
            "xxx"
        ],
        "vpcId":"xxx"
    },
    "nasConfig": {
      "groupId" : 123,
      "mountPoints": [
        {
        "enableTLS": true|false,
        "mountDir": "xxx",
        "serverAddr": "dddd"
        }
      ],
      "userId": 123
    },
    "mountPoints":[
      {
        "bucketName": "xxx",
        "bucketPath": "xxx",
        "endpoint": "xxx",
        "mountDir": "ddd",
        "readOnly": true|false
      }
    ]
}

response:

{
  "status": "success|fail",
  "failFuncList": ["xxx"], // 失败的函数列表
  "errMsg": ["xxxx"] //过错信息
}

5.3批量删去动态创立函数接口

批量删去动态创立的函数,入参函数列表

POST /del/sd/functions

request:

{
    "functions":["xxxxx"]
}
responese
// status_code=200
{
    "status":"success"
}
// status_code=500
{
    "fails":[
        {
            "err":"xxxx",
            "functionName":"xxxx"
        }
    ],
    "status":"fail"
}

6. 其他接口

  • 原生 webui-api 接口,除了上面支撑的功用接口,剩余的 api 接口
  • 插件自定义的 api 接口

其间支撑同步、异步形式 使命形式:

  • 同步/异步,header 中设置 Request-Type,其间值 sync 为同步形式,async 为异步形式,不设置该值默许为同步形式,异步获取成果需要从上面的获取成果接口(tasks/{taskId}/result)获取最终的成果
  • 使命形式,header 中设置 Task-Flag,会将成果保存到 ots 进行耐久化,相同支撑同步 异步

最佳实践

为了便利我们直观体会一下该解决计划成效,根据函数核算团队开发者的根据 Stable Diffusion Serverless API 解决计划搭建的 AI 文字生成运用,作为一个实验 demo 开放体会,期待为广阔开发者 AI 绘画创业及变现供给一些有利思考。直接参与体会活动,送好礼!

活动链接:developer.aliyun.com/topic/fcnew…

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

布置成功的 AI 绘画运用:

AI 绘画渠道难开发,难变现?试试 Stable Diffusion API Serverless 版解决计划

眯着眼睛看看是什么字?

开源代码
github :github.com/devsapp/ser…

能够自己根据开源代码加工开发