Faster apps using accelerated SDXL Lightning
Learn from Thierry Moreau, Co-Founder at OctoML, how to build faster apps using OctoAI’s accelerated SDXL Lightning. This allows image generation in less than 1 second! It allows for reduced steps (from 20 to 8) with no real loss in quality.
LCM has been deprecated for SDXL Lightning.
Quick recap
We will be applying this to our Aquarelle app for consistency. Last time we used OctoAI’s accelerated SDXL API to reduce the latency from 4.6 seconds to 2 seconds. This is still using 20 steps for SDXL. But, if we use SDXL Lightning we can further improve upon that speed from 2 seconds to less than 1 second? Let’s find out.
Documentation and quick setup
The full instructions for using the SDXL Lightning with your OctoAI SDXL API endpoint should provide details for testing and setup. Make sure you follow the appropriate settings shown, specifically:
Opt for 4-8 steps, 8 is optimal
Maintain a low
cfg_scale
, ideally from 1.4 to 4.0, 3.0 is optimalUse any sampler or style preset
Note: using additional LoRAs or VAEs will increase generation time
Also, you will need your OctoAI token to use with the code examples.
Editing the Aquarelle app to use SDXL Lightning
To edit the Aquarelle app to use SDXL Lightning:
Access the TypeScript file:
route.ts
This contains the function definition that calls the SDXL API using a post request
Access the
body:
there is a JSON objectThis contains all the SDXL parameters
It currently looks like:
Following the doc instructions, it should be updated to the below:
Once you have made those updates it is time to test in our web app. We made the update to Aquarelle, and using the same prompt: batman eating a hot bowl of pho
, we saw an image generation time of 0.66 seconds, so fast! Incredible that we can generate images this fast while maintaining our consistently high quality watercolor styles.
Next: Customizing SDXL with LoRAs
Thierry will review how to apply more customizations to SDXL images using LoRAs.
Share what you build
We are excited to see what you build – feel free to show us in our Discord, and see what other community members are creating.
Your choice of models on our SaaS or in your environment
Run any model or checkpoint on our efficient, reliable, and customizable API endpoints. Sign up and start building in minutes.