StabilityAI 0.0.0-dev.32

This is a prerelease version of StabilityAI.
dotnet add package StabilityAI --version 0.0.0-dev.32
                    
NuGet\Install-Package StabilityAI -Version 0.0.0-dev.32
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StabilityAI" Version="0.0.0-dev.32" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StabilityAI" Version="0.0.0-dev.32" />
                    
Directory.Packages.props
<PackageReference Include="StabilityAI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StabilityAI --version 0.0.0-dev.32
                    
#r "nuget: StabilityAI, 0.0.0-dev.32"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package StabilityAI@0.0.0-dev.32
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StabilityAI&version=0.0.0-dev.32&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=StabilityAI&version=0.0.0-dev.32&prerelease
                    
Install as a Cake Tool

StabilityAI

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official Stability AI OpenAPI specification using AutoSDK
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0

Usage

using StabilityAI;

using var client = new StabilityAIClient(apiKey);

List Engines

using var client = new StabilityAIClient(apiKey);

// Discover available engines before generating images
var engines = await client.V1Engines.ListEnginesAsync();

foreach (var engine in engines)
{
    Console.WriteLine($"{engine.Id}: {engine.Name} ({engine.Type})");
    Console.WriteLine($"  {engine.Description}");
}

Text to Image

using var client = new StabilityAIClient(apiKey);

var images = await client.V1Generation.TextToImageAsync(
    engineId: "stable-diffusion-v1-6",
    request: new TextToImageRequestBody(
        value1: new TextToImageRequestBodyVariant1
        {
            TextPrompts =
            [
                new TextPrompt
                {
                    Text = "A beautiful sunset over mountains, digital art",
                    Weight = 1.0f,
                },
            ],
            Height = 512,
            Width = 512,
        },
        value2: new GenerationRequestOptionalParams
        {
            Samples = 1,
        }));

foreach (var image in images)
{
    Console.WriteLine($"Seed: {image.Seed}, Finish reason: {image.FinishReason}");

    // image.Base64 contains the generated image data
    var bytes = Convert.FromBase64String(image.Base64!);
    await File.WriteAllBytesAsync($"output_{image.Seed}.png", bytes);
}

Image to Image

using var client = new StabilityAIClient(apiKey);

// Load the source image
var initImageBytes = await File.ReadAllBytesAsync("input.png");

var images = await client.V1Generation.ImageToImageAsync(
    engineId: "stable-diffusion-v1-6",
    request: new ImageToImageRequestBody
    {
        TextPrompts =
        [
            new TextPrompt
            {
                Text = "A fantasy castle on a cliff, dramatic lighting",
                Weight = 1.0f,
            },
        ],
        InitImage = initImageBytes,
        InitImagename = "input.png",
        ImageStrength = 0.35f, // Lower = closer to original, higher = more creative
    });

foreach (var image in images)
{
    Console.WriteLine($"Seed: {image.Seed}, Finish reason: {image.FinishReason}");

    var bytes = Convert.FromBase64String(image.Base64!);
    await File.WriteAllBytesAsync($"output_{image.Seed}.png", bytes);
}

Upscale Image

using var client = new StabilityAIClient(apiKey);

// Load the image to upscale
var imageBytes = await File.ReadAllBytesAsync("low-res.png");

var images = await client.V1Generation.UpscaleImageAsync(
    engineId: "esrgan-v1-x2plus",
    request: new UpscaleImageRequestBody
    {
        Image = imageBytes,
        Imagename = "low-res.png",
        Width = 2048, // Only specify width OR height, not both
    });

foreach (var image in images)
{
    Console.WriteLine($"Seed: {image.Seed}, Finish reason: {image.FinishReason}");

    var bytes = Convert.FromBase64String(image.Base64!);
    await File.WriteAllBytesAsync("upscaled.png", bytes);
}

Masking

using var client = new StabilityAIClient(apiKey);

// Load the source image and mask image (must be same dimensions)
var initImageBytes = await File.ReadAllBytesAsync("input.png");
var maskImageBytes = await File.ReadAllBytesAsync("mask.png");

var images = await client.V1Generation.MaskingAsync(
    engineId: "stable-diffusion-v1-6",
    request: new MaskingRequestBody
    {
        TextPrompts =
        [
            new TextPrompt
            {
                Text = "A bright blue sky with fluffy clouds",
                Weight = 1.0f,
            },
        ],
        InitImage = initImageBytes,
        InitImagename = "input.png",
        MaskImage = maskImageBytes,
        MaskImagename = "mask.png",
    });

foreach (var image in images)
{
    Console.WriteLine($"Seed: {image.Seed}, Finish reason: {image.FinishReason}");

    var bytes = Convert.FromBase64String(image.Base64!);
    await File.WriteAllBytesAsync($"masked_{image.Seed}.png", bytes);
}

Support

Priority place for bugs: https://github.com/tryAGI/StabilityAI/issues
Priority place for ideas and general questions: https://github.com/tryAGI/StabilityAI/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.0-dev.32 0 3/20/2026
0.0.0-dev.30 0 3/19/2026
0.0.0-dev.29 0 3/19/2026
0.0.0-dev.28 0 3/19/2026
0.0.0-dev.27 0 3/19/2026
0.0.0-dev.26 0 3/19/2026
0.0.0-dev.25 0 3/19/2026
0.0.0-dev.24 0 3/19/2026
0.0.0-dev.23 0 3/19/2026
0.0.0-dev.22 3 3/19/2026
0.0.0-dev.21 25 3/19/2026
0.0.0-dev.20 19 3/19/2026
0.0.0-dev.18 19 3/19/2026
0.0.0-dev.17 24 3/19/2026
0.0.0-dev.16 25 3/19/2026
0.0.0-dev.15 26 3/19/2026
0.0.0-dev.13 26 3/19/2026
0.0.0-dev.12 29 3/19/2026
0.0.0-dev.11 23 3/19/2026
0.0.0-dev.10 28 3/19/2026
Loading failed