If you are using Windows,
you can modify webui-user.bat and add "set COMMANDLINE_ARGS=--api",
send a post request url:{webui_uri}/sdapi/v1/txt2img,
the body content can refer to this URL https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/3734,
the response can be taken from the key "images",
there will be a picture, hope it can help you