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

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

Published
Sep 12, 2026
1mo ago
Total Downloads
1.2K
1,151

Install

dotnet add package CommunityToolkit.Aspire.Hosting.StableDiffusionCpp --version 13.5.1-beta.751
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.5.1-beta.748 and v13.5.1-beta.751.

Adoption Assessment

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

This version is marked prerelease. Validate its API and upgrade path before production use.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.