Thanks @graemeniedermayer for suggestion. Example: https://github.com/Mikubill/sd-webui-controlnet/blob/main/scripts/api.py