LocalAI supports generating images with Stable Diffusion, running on CPU using C++ and Python implementations. You install an image model, send a text prompt to the image endpoint, and get a generated image back — the same shape as the OpenAI image API, but running on your own machine.
Install an image model
There are several models in the gallery that are available to install and get up and running with the stablediffusion-ggml backend, which is based on stable-diffusion.cpp. You can for example run Flux by searching for it in the Model gallery (flux.1-dev-ggml), or start LocalAI with run:
local-ai run flux.1-dev-ggml
Every model supported by the stable-diffusion.cpp backend is supported by LocalAI with this backend. To use a custom model instead, create a model file such as stablediffusion.yaml in the models folder with backend: stablediffusion-ggml, download the required assets to the models folder, and start LocalAI.
Send a text prompt
To generate an image, send a POST request to the /v1/images/generations endpoint with the instruction as the request body. Use the image generation endpoint with the model name from the configuration file:
curl http://localhost:8080/v1/images/generations -H "Content-Type: application/json" -d '{
"prompt": "A cute baby sea otter",
"model": "flux.1-dev-ggml",
"size": "256x256"
}'
Available additional parameters are mode, step, and negative_prompt. To set a negative prompt, pass a separate negative_prompt field, or split the prompt with | — for example a cute baby sea otter|malformed. When both are present they are joined with a comma, with the negative_prompt field first, then the |-suffixed tags.
Open the generated image
The reply returns the generated image under /generated-images, with the output URL in data[0].url. Open that URL in your browser and check the picture: it should show the subject of your prompt — a baby sea otter, in the example above. If the image does not match the prompt, check that the model field names the image model you installed, and try the prompt again with a negative prompt added to steer it away from the unwanted detail.
Try it: four checks from install to first image
| Check | What you should see | If you do not see it |
|---|---|---|
| Model installed | flux.1-dev-ggml installed from the Model gallery or started with local-ai run |
Search the gallery for flux.1-dev-ggml and install it, then wait for the download |
| Request accepted | A reply from /v1/images/generations with no error |
Check the model name in the request matches the installed model |
| Image returned | An output URL in data[0].url under /generated-images |
Check the reply body for an error message from the backend |
| Picture matches | An image of a baby sea otter when you open the URL | Try the prompt again with a negative prompt, for example |malformed |
Expected result. We checked the LocalAI image generation docs page, which gives the Stable Diffusion support on CPU with C++ and Python implementations, the gallery install and local-ai run flux.1-dev-ggml command, the stablediffusion-ggml backend based on stable-diffusion.cpp, the POST /v1/images/generations endpoint with the “A cute baby sea otter” prompt and 256×256 size, the mode, step, and negative_prompt parameters with the | split and the a cute baby sea otter|malformed example, and the generated image returned under /generated-images with the output URL in data[0].url. We did not install LocalAI or generate any image on this machine.
Limits
This guide covers text-to-image generation with one model only. Image generation does not automatically upscale its results: upscaling is a separate job through POST /v1/images/upscale with its own upscale-only model. Image-to-image, depth-to-image, and text-to-video use different pipelines and configuration files, and the docs list their own model setups. The diffusers backend is an extra backend that is already available in the container image; the docs say not to use core images ending in -core for it. We did not run any of this ourselves.
![Schematic diagram with three steps: install the flux.1-dev-ggml model, send a prompt to the /v1/images/generations endpoint, then open the generated image from data[0].url.](https://newtoolradar.com/wp-content/uploads/2026/11/run-localai-image-generation-model-1024x700.png)