Stable Diffusion tutorial: How to use Lexica, the Stable Diffusion AI art image search engine

Tuesday, November 08, 2022 by ezzcodeezzlife
Stable Diffusion tutorial: How to use Lexica, the Stable Diffusion AI art image search engine
Tutorial accompaniment image

Welcome to this Stable Diffusion tutorial! With the help of the new open source Stable Diffusion AI model everyone can generate awesomely looking images or as everyone calls it now - AI generated art.

This tutorial will show you how to use Lexica, a new Stable Diffusion image search engine, that has millions of images generated by Stable Diffusion indexed. You can use it to just browse through images to get some inspiration or you can use their API to integrate it into your next project. The big advantage of working with Stable Diffusion based tools like Lexica is that you don't need to generate the images yourself - you can just use the ones that are already indexed. This saves lots of compute power and time.

The site was created by Sharif Shameem, who hopes it β€œmakes Stable Diffusion prompting a bit less of a dark art and more of a science.”

How to use Lexica

You can find the site at It's very simple and easy to use. You can search for images by entering a prompt in the search bar. The prompt can be anything you want, it can be a word, a sentence or even a paragraph.

As mentioned before, you can even generate images on the site as well. Just enter a prompt and click on the generate button. You can also change the parameters of the model like width, height and seed. Furthermore you can add things you want to exclude in your generation.

How to use Stable Diffusion based Lexica with the API

Furthermore, the Lexica team has added a new API feature to get programmatic access to the images. To use Lexica's search API, create a GET request with a query parameter q as your search term. For example, to search for the term "apples", you would make a request to:


You can even do reverse image search. Just send the image you want and Lexica will return the most similar images. This opens up a lot of possibilities for your next project or hackathon with stable diffusion. For a reverse image search, you can pass in the URL of an image as the query:


The search response will look like this:

The API will return a JSON object containing an array of 50 image search results.

    "images": [
            // The ID of the image
            "id": "0482ee68-0368-4eca-8846-5930db866b33",
            // URL for the image's gallery
            "gallery": "",
            // Link to this image
            "src": "",
            // Link to an compressed & optimized version of this image
            "srcSmall": "",
            // The prompt used to generate this image
            "prompt": "cute chubby blue fruits icons for mobile game ui ",
            // Image dimensions
            "width": 512,
            "height": 512,
            // Seed
            "seed": "1413536227",
            // Whether this image is a grid of multiple images
            "grid": false,
            // The model used to generate this image
            "model": "stable-diffusion",
            // Guidance scale
            "guidance": 7,
            // The ID for this image's prompt
            "promptid": "d9868972-dad8-477d-8e5a-4a0ae1e9b72b"
            // Whether this image is classified as NSFW
            "nsfw": false,

If you want to learn more about how to write good prompts, check out our stable diffusion prompt guide on the tutorial page, like this one. And maybe you want to create a Stable Diffusion based tool of your own? Then, join our Stable Diffusion AI Hackathon!

Thank you! If you enjoyed this tutorial you can find more and continue reading on our tutorial page - Fabian Stehle, Data Science Intern at New Native

Discover tutorials with similar technologies

Upcoming AI Hackathons and Events