Stable Diffusion Webhooks
Webhooks are the primary way in which results from inferencing are returned to your application.
Registering webhooks
Registering a webhook is quite simple. When sending an inferencing request, simply pass a developer-defined secret token, such as a JavaScript Web Token (JWT), along with a publicly accessible URL that supports HTTP POST
with a JSON body. Diffute will callback with a JSON manifest containing matching identifiers based upon the name
used for each prompt in the request.
The developer-defined secret token will be sent as a bearer token in an Authentication header in the HTTP POST
callback so that you can verify that the authenticity of the HTTP POST
request.
Consuming webhooks
Example webhook payload
{
"name": "Houston",
"images":
{
"Ansel_Adams": ["https://url_to_media1", "https://url_to_media2", "https://url_to_media3"],
"Henri_Rousseau": ["https://url_to_media4", "https://url_to_media5", "https://url_to_media6"],
"Rachel_Ruysch": ["https://url_to_media7", "https://url_to_media8", "https://url_to_media9"]
},
"job_id": 1234567890
}
The payload above will be delivered to the URL https://example.com/customer/12345
through a Diffute webhook if the request is as follows. Notice images
contains keys with the name
of the individual prompts pointing to a list of URLs with a length of num_images
.
Example of an inference request
curl --request PUT \
--url https://api.diffute.com/v1/project/<organization_id>/<project_id>/media/inference \
--header 'Content-Type: application/json' \
--header 'x-api-key: long-api-key/default' \
--data '{
"prompts": [
{
"name": "Ansel_Adams",
"prompt": "A series of black and white photographs capturing the beauty and grandeur of Yosemite National Park",
"num_images": 3,
"height": 1024,
"width": 768,
"style": "photography in the style of Ansel Adams"
},
{
"name": "Henri_Rousseau",
"prompt": "A painting of a lush jungle scene with a variety of exotic plants and animals",
"num_images": 3,
"height": 1024,
"width": 768,
"style": "painting in the style of Henri Rousseau"
},
{
"name": "Rachel_Ruysch",
"prompt": "Still life painting featuring a variety of flowers and plants found in a garden",
"num_images": 3,
"height": 1024,
"width": 768,
"style": "painting in the style of Rachel Ruysch"
}
],
"webhook" : "https://example.com/customer/12345",
"secret" : "4f986e48-0129-480e-996a-728ea57c020c",
"pretrained_model_name" : "stabilityai/stable-diffusion-xl-base-1.0",
"name" : "Houston"
}'