WebSocket endpoints
Development
wss://dev-ws-api.diffusionmaster.com/v1/
Production
wss://ws-api.diffusionmaster.com/v1/
REST API Endpoint - Coming Soon
REST API Endpoint - Coming Soon
Development
Production
Using WebSockets
We recommend WebSocket connections as they are more efficient, faster, and less resource intensive. They are, however, a little harder to manage because of they async nature. We tried to make WebSocket connections easy to work with, as each response contains the request ID. So it's possible to easily match request β response.
New connections & authentication
WebSocket connections are point-to-point. So there's no need for each request to contain an authentication header. Instead, the first request must always be an authentication request that includes the API key. This way we can identify which subsequent requests are arriving from the same user.
{
"newConnection":{
"apiKey":"<APIKEY>"
}
}
How to get the API key
Currently, the API key for each account can be obtained by contacting our team. We are working however on a the ability to generate API keys directly in the user account. Once this is in place it will be possible to also create API keys for multiple environments (dev, prod, staging) and for different projects. Billing will be cumulated per API key costs can be correctly attributed to environments or projects.
WebSockets Session IDs
After youβve made the authentication request the API will return a connectionSessionUUID
in the following format:
{
"newConnectionSessionUUID":{
"connectionSessionUUID":"f40c2aeb-f8a7-4af7-a1ab-7594c9bf778f"
}
}
Message buffer & resuming connections
If any service, server, or network is unresponsive, for instance due to a restart, all the images or tasks that could not be delivered are kept in a buffer memory for 2 minutes. It's possible to reconnect and have these messages delivered by providing in the initial authentication connection request the connectionSessionUUID, like in this example:
{
"newConnection":{
"apiKey":"<APIKEY>",
"connectionSessionUUID":"f40c2aeb-f8a7-4af7-a1ab-7594c9bf778f"
}
}
After the connection is made it's possible to send different tasks to the API - e.g. text2img, img2img, inpainting, upscale, image2text, imageUpload, etc.