512x512
For the fastest inference speed use 512x512 input dimensions for image_url
.
In this example, we'll be using our most popular optimized ultra fast latent consistency model (opens in a new tab).
All our Model Endpoint's support HTTP/REST. Additionally our real-time models support WebSockets. You can use the HTTP/REST endpoint for any real time model but if you are sending back to back requests using websockets gives the best results.
Before we proceed, you need to create your API key.
import * as fal from "@fal-ai/serverless-client";
fal.config({
credentials: "FAL_KEY",
});
const connection = fal.realtime.connect("fal-ai/fast-lcm-diffusion", {
onResult: (result) => {
console.log(result);
},
onError: (error) => {
console.error(error);
},
});
connection.send({
prompt:
"an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
sync_mode: true,
image_url:
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
});
You can read more about the real time clients in our real time client docs section.
For the fastest inference speed use 512x512 input dimensions for image_url
.
To get the best performance from this model:
You can also use 768x768 or 1024x1024 as your image dimensions, the inference will be faster for this configuration compared to random dimensions but wont be as fast as 512x512.
Video Tutorial: Latent Consistency - Build a Real-Time AI Image App with WebSockets, Next.js, and fal.ai by Nader Dabit