A lightweight library for generating AI image prompts
$ dotnet add package ImagePromptGeneratorA lightweight, fluent C# library for building AI image generation prompts.
This library provides a small set of strongly-typed helper classes and helpers for composing style anchors, negative keywords, and full image generation prompts suitable for use with image generation models or pipelines.
StyleAnchor, StylePrompt, NegativeKeyword, NegativePrompt, and ImageGenerationPrompt.bad hands, watermark, realistic).--no suitable for many model CLI interfaces.Install or add this project to your solution. The source is minimal and can be referenced directly.
Build and pack the NuGet package (optional):
dotnet pack -o ./nupkgs ImagePromptGenerator.cs
dotnet nuget push ./nupkgs/ImagePromptGenerator.[version].nupkg --api-key $API_KEY --source https://api.nuget.org/v3/index.json
The library uses fluent operators to combine styles and negative keywords.
// Create a style prompt by combining predefined anchors
var style = StyleAnchor.Sticker.Cute
+ StyleAnchor.Sticker.Emoji
+ StyleAnchor.Art2D.CelShaded
+ StyleAnchor.Art2D.VibrantFlatColors;
// Build negative keywords to avoid certain styles and elements
var negative = NegativeKeyword.StyleClash.Photorealistic
+ NegativeKeyword.Elements.Text
+ NegativeKeyword.Elements.Watermark;
// Construct the final prompt
var prompt = new ImageGenerationPrompt(style, "smiling cat with party hat", negative);
// Customize background or subject if needed
prompt.Background = "isolated on a transparent background";
// Convert to string (uses default postfix "--no" for negative prompt)
Console.WriteLine(prompt.ToString());
Output example:
(cute sticker illustration, custom emoji, cel-shaded, vibrant flat colors), smiling cat with party hat, isolated on a transparent background --no (photorealistic, text, watermark)
The library includes factory methods that return ready-to-use presets:
ImageGenerationPrompt.PresetSticker() — optimized for sticker/emoji icons.ImageGenerationPrompt.Preset3DIcon() — for glossy 3D icon renders.ImageGenerationPrompt.PresetPhotorealistic() — for photorealistic images.ImageGenerationPrompt.PresetPixelArt() — for pixel-art / 8-bit style images.Use them as starting points and then adjust Subject or Background:
var sticker = ImageGenerationPrompt.PresetSticker();
sticker.Subject = "red panda mascot holding a balloon";
Console.WriteLine(sticker);
StyleAnchor — Defines a single style description; implicitly convertible from string and combines into StylePrompt with +.StylePrompt — A collection of StyleAnchor providing ToString() formatting and convenient operators to combine with anchors, strings, or other prompts.NegativeKeyword — Single negative keyword; implicitly convertible from string and combines into NegativePrompt with +.NegativePrompt — A collection of NegativeKeyword and ToString() implementation to produce a negative list.ImageGenerationPrompt — The final model of the prompt containing Style, Negative, Subject, and Background. It provides a ToString() that uses --no (default) as a negative postfix, and an overloaded ToString(string) to override the postfix.Style anchors and negative keywords support + operator for fluent composition. Examples:
var combined = StyleAnchor.Photography.Cinematic + StyleAnchor.Photography.GoldenHour;
var bad = NegativeKeyword.Quality.Blurry + NegativeKeyword.Elements.Text;
These can be passed directly into ImageGenerationPrompt.
ImageGenerationPrompt.Background defaults to: isolated on a plain white background.DefaultNegativePromptPostfix defaults to --no — a widely used negative postfix in model CLI style interfaces.Contributions, improvements, new anchors or keywords, and bug reports are welcome. Please fork this repository and open a PR.
This project uses the MIT license (see PackageLicenseExpression in project metadata).
If you'd like, I can also add usage examples for specific models (e.g., how to pass these prompts to a Python client or an HTTP API for image generation) — tell me which backend or model you target and I'll add examples.