Skip to main content
net10.0net8.0net9.0

An Aspire hosting integration for the stable-diffusion.cpp image generation server.

Published
Oct 1, 2026
21d ago
Total Downloads
1.2K
1,151

Install

dotnet add package CommunityToolkit.Aspire.Hosting.StableDiffusionCpp --version 13.6.0
ProductVersions
.NET
net10.0net8.0net9.0

README

CommunityToolkit.Aspire.Hosting.StableDiffusionCpp

An Aspire hosting integration for the official stable-diffusion.cpp server images.

Getting started

Install the package in an Aspire AppHost:

dotnet add package CommunityToolkit.Aspire.Hosting.StableDiffusionCpp

Add the server and a model hosted on Hugging Face:

var stableDiffusion = builder.AddStableDiffusionCpp(
        "stable-diffusion",
        StableDiffusionCppImageVariant.Cuda)
    .WithGPUSupport()
    .WithVaeTiling();

stableDiffusion.AddHuggingFaceModel(
    "stabilityai/stable-diffusion-xl-base-1.0",
    "sd_xl_base_1.0.safetensors");

The model is downloaded before the container starts. Interrupted downloads resume from the partial file, and subsequent starts reuse the cached file under .stable-diffusion-cpp/{resource-name}/models.

The integration uses official ghcr.io/leejet/stable-diffusion.cpp images. Available variants are Cuda, CudaSpark, Vulkan, Sycl, and Musa.

Gated or private Hugging Face models

Provide a secret parameter containing a Hugging Face access token:

var token = builder.AddParameter("hugging-face-token", secret: true);

var stableDiffusion = builder
    .AddStableDiffusionCpp("stable-diffusion")
    .WithHuggingFaceToken(token);

stableDiffusion.AddHuggingFaceModel(
    "organization/model",
    "model.safetensors");

LoRA and upscalers

Place compatible LoRA files under:

.stable-diffusion-cpp/{resource-name}/models/loras

Place high-resolution upscaler models under:

.stable-diffusion-cpp/{resource-name}/models/upscalers

The Web UI and API are exposed through the resource's http endpoint.

Changes from Previous Version

No structural changes between v13.6.0-beta.914 and v13.6.0.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.