LocalAI has a diffusers backend which allows image generation using the diffusers library — the go-to library for state-of-the-art pretrained diffusion models for generating images, audio, and even 3D structures of molecules. This is a different backend from stablediffusion-ggml (the backend behind the flux.1-dev-ggml gallery model): it runs Hugging Face diffusion pipelines in Python instead of the C++ stable-diffusion.cpp engine, and it uses different models and a different model file. This guide generates one image with it; it does not upscale an existing image.
Create the diffusers model file
The models will be downloaded the first time you use the backend from Hugging Face automatically. Create a model configuration file in the models directory, for instance to use Linaqruf/animagine-xl with CPU:
name: animagine-xl
parameters:
model: Linaqruf/animagine-xl
backend: diffusers
f16: false
diffusers:
cuda: false # Enable for GPU usage (CUDA)
scheduler_type: euler_a
The diffusers backend is an extra backend: in the container it is already available and there is nothing to do for the setup. Do not use core images (ending with -core). The configuration parameters include f16 (default false), step (default 30), cuda (default false), enable_parameters (default negative_prompt,num_inference_steps,clip_skip), scheduler_type (default k_dpp_sde), cfg_scale (default 8), clip_skip (no default), and pipeline_type (default AutoPipelineForText2Image).
Send a prompt to the generations endpoint
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": "<positive prompt>|<negative prompt>",
"model": "animagine-xl",
"step": 51,
"size": "1024x1024"
}'
To set a negative prompt you can either 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 (negative_prompt first, then the |-suffixed tags), so a global negative prompt can live in negative_prompt while per-image negatives are appended after |. The available additional parameters are mode, step, and negative_prompt.
Open the generated image
The reply follows the image-generation response format, with the output URL in data[0].url under /generated-images. Open that URL to see the image the prompt asked for, at the size you requested — 1024x1024 in the example above. If you leave step out, the model runs its default of 30 steps; the example asks for 51.
Try it: four checks from model file to finished image
| Check | What you should see | If you do not see it |
|---|---|---|
| Model file saved | animagine-xl.yaml in the models directory with backend: diffusers and model Linaqruf/animagine-xl |
Check the file is in the models directory and the backend is spelled diffusers, not stablediffusion-ggml |
| Backend available | LocalAI runs from a full image, not a -core image, so the diffusers backend is already available |
Check the image name does not end in -core — the diffusers backend is an extra backend that core images do not carry |
| Request sent | A reply from /v1/images/generations with model: animagine-xl, step: 51, and size: 1024x1024 |
Check the model name matches the name in the configuration file and LocalAI is running on localhost:8080 |
| Image opens | data[0].url under /generated-images opens a 1024×1024 image |
Check the URL is under /generated-images and the request used the diffusers model name, not an stablediffusion-ggml model |
Expected result. We checked the LocalAI image generation docs page, which gives Diffusers as the go-to library for state-of-the-art pretrained diffusion models for generating images, audio, and even 3D structures of molecules, the LocalAI diffusers backend allowing image generation using the diffusers library, the models downloading the first time you use the backend from Hugging Face automatically, the animagine-xl model file with model Linaqruf/animagine-xl, backend diffusers, f16 false, diffusers cuda false, and scheduler_type euler_a, the diffusers backend as an extra backend already available in the container with no setup and the warning not to use core images ending with -core, the configuration parameters f16 default false, step default 30, cuda default false, enable_parameters default negative_prompt,num_inference_steps,clip_skip, scheduler_type default k_dpp_sde, cfg_scale default 8, clip_skip with no default, and pipeline_type default AutoPipelineForText2Image, the text-to-image curl with prompt <positive prompt>|<negative prompt>, model animagine-xl, step 51, and size 1024×1024, the negative prompt by separate negative_prompt field or by splitting the prompt with | with the a cute baby sea otter|malformed example and the comma join rule, the additional parameters mode, step, and negative_prompt, and the response format with the output URL in data[0].url under /generated-images. We did not install LocalAI, download any model, or generate any image on this machine.
Limits
This guide covers image generation with the diffusers backend only. It is not the stablediffusion-ggml backend: that backend runs the C++ engine and its gallery models (such as flux.1-dev-ggml) do not belong in a diffusers model file, and its ESRGAN upscaling is a separate job from generating an image. The Diffusers backend also has its own separate x4 upscaler gallery model (stable-diffusion-x4-upscaler) for upscaling through POST /v1/images/upscale — that is not what this guide does. Models download from Hugging Face the first time the backend is used, so the first request waits on a download. We did not run any of this ourselves.
![Schematic diagram with three steps: set up the animagine-xl model file with the diffusers backend and the Linaqruf animagine-xl model, send a prompt to the /v1/images/generations endpoint with step 51 and size 1024x1024, then open the image from data[0].url under generated-images at 1024 by 1024 pixels.](https://newtoolradar.com/wp-content/uploads/2026/11/run-localai-text-to-image-diffusers-backend-1024x700.png)