Optimized Latent Consistency (SDv1.5)
fal-ai/lcm-sd15-i2i
API documentation
Generate Image
Real-time support
This API supports real-time inference. You can use the fal clients to create real-time experiences in your own applications.
import * as fal from "@fal-ai/serverless-client";
const connection = fal.realtime.connect("fal-ai/lcm-sd15-i2i", {
onResult: (result) => {
console.log(result);
},
onError: (error) => {
console.error(error);
}
});
connection.send({
prompt: "masterpiece, colorful, photo of a beach in hawaii, sun",
image_url: "https://storage.googleapis.com/falserverless/model_tests/lcm/beach.png"
});
Calling the API
The API follows common HTTP semantics and should work with the language of your preference. Below you will find the API endpoint and some code snippets to help you get started:
https://fal.run/fal-ai/lcm-sd15-i2i
import * as fal from "@fal-ai/serverless-client";
const result = await fal.subscribe("fal-ai/lcm-sd15-i2i", {
input: {
prompt: "masterpiece, colorful, photo of a beach in hawaii, sun",
image_url: "https://storage.googleapis.com/falserverless/model_tests/lcm/beach.png"
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS") {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
For requests that take longer than several seconds, checkout our queue and webhook features. Our JS and Python clients use the queue behind the scenes. Head to our client page in our documenation site to read more about our Python and Javascript clients.
Authentication guidelines
FAL_KEY
variable set in your environment. Make sure you check out our docs to find out more about our API and how to manage authentication, long-running requests and more.Input
prompt*
string
The prompt to use for generating the image. Be as descriptive as possible for best results.
Examples:
- "masterpiece, colorful, photo of a beach in hawaii, sun"
image_url*
string
The image to use as a base.
Examples:
- "https://storage.googleapis.com/falserverless/model_tests/lcm/beach.png"
strength
float
The strength of the image. Default value: 0.8
negative_prompt
string
The negative prompt to use.Use it to address details that you don't want
in the image. This could be colors, objects, scenery and even the small details
(e.g. moustache, blurry, low resolution). Default value: ""
Examples:
- "cartoon, illustration, animation. face. male, female"
- "ugly, deformed"
seed
integer
The same seed and the same prompt given to the same version of Stable Diffusion will output the same image every time.
guidance_scale
float
The CFG (Classifier Free Guidance) scale is a measure of how close you want
the model to stick to your prompt when looking for a related image to show you. Default value: 1
num_inference_steps
integer
The number of inference steps to use for generating the image. The more steps
the better the image will be but it will also take longer to generate. Default value: 4
sync_mode
boolean
If set to true, the function will wait for the image to be generated and uploaded before returning the response. This will increase the latency of the function but it allows you to get the image directly in the response without going through the CDN.
num_images
integer
The number of images to generate. The function will return a list of images
with the same prompt and negative prompt but different seeds. Default value: 1
enable_safety_checks
boolean
If set to true, the resulting image will be checked whether it includes any
potentially unsafe content. If it does, it will be replaced with a black
image. Default value: true
request_id
string
An id bound to a request, can be used with response to identify the request
itself. Default value: ""
Input sample:
{
"prompt": "masterpiece, colorful, photo of a beach in hawaii, sun",
"image_url": "https://storage.googleapis.com/falserverless/model_tests/lcm/beach.png",
"strength": 0.8,
"negative_prompt": "cartoon, illustration, animation. face. male, female",
"seed": 42,
"guidance_scale": 1,
"num_inference_steps": 4,
"num_images": 1,
"enable_safety_checks": true
}
Output
images*
list<Image>
The generated image files info.
timings*
Timings
seed*
integer
Seed of the generated Image. It will be the same value of the one passed in the input or the randomly generated that was used in case none was passed.
num_inference_steps
integer
Number of inference steps used to generate the image. It will be the same value of the one passed in the
input or the default one in case none was passed. Default value: 4
request_id
string
An id bound to a request, can be used with response to identify the request
itself. Default value: ""
nsfw_content_detected*
list<boolean>
A list of booleans indicating whether the generated image contains any potentially unsafe content. If the safety check is disabled, this field will have a false for each generated image.
Output sample:
{
"images": [
{
"url": "",
"content_type": "image/jpeg"
}
],
"num_inference_steps": 4
}
Error types
Some errors may also contain a JSON payload with additional details. In this section you can find the possible error types and their properties.
ValidationError
When input validation fails, the API will response with a 422
status and an array
of ValidationError
object in the response body. The ValidationError
object
will contain a list of errors, each with a loc
(location) attribute that indicates
the path to the invalid input, and a msg
(message) attribute that describes the error.
HTTPValidationError
detail
list<ValidationError>
Types
Image
url*
string
width*
integer
height*
integer
content_type
string
Default value: "image/jpeg"