Noundry.AIG.Client v1.1.0 — Now Available as NuGet

Chain Prompting
for C# .NET

The unified AI gateway for .NET developers. One NuGet package connects OpenAI, Anthropic Claude, Google Gemini, Groq, Ollama, and any OpenAI-compatible endpoint — with built-in multi-provider fallback, real-time streaming, chain prompting, and zero markup on costs.

Like the Vercel AI SDK, but built for C# and the .NET ecosystem from the ground up. Includes TOON serialization for ~40% token savings.

Program.cs
// Install: dotnet add package Noundry.AIG.Client

var prompt = new PromptBuilder()
    .WithModel("anthropic/claude-sonnet-4")
    .WithTemperature(0.7f)
    .AddSystemMessage("You are a helpful AI assistant.")
    .AddUserMessage("Explain quantum computing in simple terms.")
    .Build();

var response = await aigClient.SendAsync(prompt);
Console.WriteLine(response.GetTextContent());
Supported AI Providers OpenAI Anthropic Claude Google Gemini Groq Ollama Nebius
C# AI Library Features

Everything your .NET AI app needs. Nothing it doesn't.

A feature-complete AI gateway for .NET — chain prompting, multi-provider fallback, TOON serialization, and more. Similar to Vercel's AI SDK, but built for C# and .NET from the ground up.

Unified Multi-Provider AI API

One consistent C# interface for OpenAI, Anthropic Claude, Google Gemini, Groq, Ollama, and any OpenAI-compatible endpoint. Write once, run against any AI provider — the LLM abstraction layer for .NET.

Multi-Provider Fallback & Auto-Failover

Set a fallback order of AI providers. If OpenAI GPT-4 is down, Anthropic Claude takes over automatically. Multi-provider prompting with zero downtime for your users.

Real-time SSE Streaming

SSE-based real-time AI streaming from every provider via IAsyncEnumerable. Deliver token-by-token responses the idiomatic C# .NET way.

Chain Prompting & AI Orchestration

Chain prompt multiple AI calls where each output feeds the next. Generate → Refine → Translate. Mix models across steps — use Claude for creative, GPT-4 for translation, Gemini for analysis.

BYOK — Bring Your Own Key

Bring Your Own Key (BYOK) gateway. Your API keys are passed directly to OpenAI, Anthropic, Google, etc. No proxy markup — you pay only each provider's standard rate. Zero hidden fees.

Built-in AI Analytics & Cost Tracking

Track tokens, latency, AI provider usage, and success rates out of the box. Monitor LLM costs per provider. SQLite-backed via Noundry Tuxedo ORM.

TOON Serialization — Token Optimization

Convert DataTables, DataSets, and collections to TOON (Token-Oriented Object Notation) format — ~40% fewer tokens than JSON while keeping full data fidelity. Dramatically reduce LLM costs.

Fluent C# Builder API

Intuitive PromptBuilder and ChainPromptBuilder with full IntelliSense support in Visual Studio and Rider. Configure every AI parameter with idiomatic C# chained methods.

Production-Ready for .NET

Thread-safe with HttpClientFactory, SemaphoreSlim, configurable retries, exponential backoff, and connection pooling. Ready for ASP.NET Core, Blazor, and console apps.

Quick Start Guide

Start chain prompting in C# in 3 steps

From dotnet add package to your first multi-provider AI response in under a minute.

1

Install the Noundry.AIG NuGet package

Terminal
$ dotnet add package Noundry.AIG.Client
2

Configure your AI providers (OpenAI, Anthropic, Gemini)

Setup.cs
using Noundry.AIG.Client;
using Noundry.AIG.Providers;

var httpClientFactory = new SimpleHttpClientFactory();
var providerFactory  = new ProviderFactory(httpClientFactory);

var options = new AigClientOptions
{
    UseLocalProviders = true,
    EnableRetries     = true,
    MaxRetries        = 3,
    ProviderConfigs   = new Dictionary<string, ProviderConfig>
    {
        ["openai"]    = new { ApiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") },
        ["anthropic"] = new { ApiKey = Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY"),
                              ApiVersionHeaderValue = "2023-06-01" },
        ["google"]    = new { ApiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY") }
    }
};

var aigClient = new AigClient(providerFactory, options);
3

Send your first AI prompt from C#

Program.cs
var prompt = new PromptBuilder()
    .WithModel("anthropic/claude-sonnet-4")
    .WithTemperature(0.7f)
    .AddSystemMessage("You are a helpful AI assistant.")
    .AddUserMessage("Explain quantum computing in simple terms.")
    .Build();

var response = await aigClient.SendAsync(prompt);

if (response.IsSuccess())
{
    Console.WriteLine(response.GetTextContent());
    Console.WriteLine($"Tokens: {response.GetTotalTokens()}");
}

That's it. Switch the model string from "anthropic/claude-sonnet-4" to "openai/gpt-4", "google/gemini-pro", or "groq/llama3" — zero code changes needed. One API for every AI provider.

C# AI Use Cases

Built for every .NET AI workflow

From simple completions to complex multi-step chain prompts — explore what you can build with the Noundry AI Gateway in C#.

Real-time AI Streaming in C#

Deliver token-by-token responses using native IAsyncEnumerable<T>. Works identically across OpenAI, Anthropic, Gemini, and all supported providers. Idiomatic C# streaming with await foreach.

StreamExample.cs
var prompt = new PromptBuilder()
    .WithModel("anthropic/claude-sonnet-4")
    .WithStreaming(true)
    .AddUserMessage("Write a poem about nature.")
    .Build();

await foreach (var chunk in aigClient.SendStreamAsync(prompt))
{
    if (chunk.IsSuccess())
    {
        Console.Write(chunk.GetTextContent());
    }
}

Multi-Provider AI Fallback in .NET

Specify a priority order of AI providers (OpenAI → Anthropic → Gemini). The gateway tries each provider in sequence until one succeeds — automatic resilience and zero downtime for your users.

FallbackExample.cs
var prompt = new PromptBuilder()
    .WithModels("openai/gpt-4", "anthropic/claude-sonnet-4", "google/gemini-pro")
    .AddUserMessage("Generate a creative story idea.")
    .Build();

var multiResponse = await aigClient.SendMultiAsync(prompt);

if (multiResponse.HasSuccess)
{
    Console.WriteLine($"Provider: {multiResponse.FirstSuccess.Provider}");
    Console.WriteLine(multiResponse.FirstSuccess.GetTextContent());
}

// Inspect all provider responses
foreach (var resp in multiResponse.Responses)
{
    var status = resp.IsSuccess() ? "OK" : $"Failed: {resp.Error?.Message}";
    Console.WriteLine($"{resp.Model}: {status}");
}

Chain Prompting — Multi-Step AI Workflows

Orchestrate multi-step AI workflows with ChainPromptBuilder. Each step's output becomes the next step's input. Mix different AI models across steps — use Claude for creativity, GPT-4 for code, Gemini for analysis.

ChainExample.cs
var chain = new ChainPromptBuilder()
    .WithDefaultModel("anthropic/claude-sonnet-4")

    // Step 1: Generate an idea
    .AddStep("Generate Idea", _ =>
        new PromptBuilder()
            .AddUserMessage("Give me a random creative writing topic."))

    // Step 2: Write about it
    .AddStep("Write Content", previousOutput =>
        new PromptBuilder()
            .AddUserMessage($"Write a short paragraph about: {previousOutput}"))

    // Step 3: Translate (using a different model!)
    .AddStep("Translate", previousOutput =>
        new PromptBuilder()
            .WithModel("openai/gpt-4")
            .AddUserMessage($"Translate to Spanish:\n{previousOutput}"));

var result = await chain.ExecuteAsync(aigClient);

if (result.Success)
    Console.WriteLine(result.FinalOutput);

Multi-Turn AI Conversations in C#

Build C# chatbots with full conversation context. Add system, user, and assistant messages using the fluent PromptBuilder API to maintain multi-turn conversation history across any AI provider.

ChatBot.cs
var prompt = new PromptBuilder()
    .WithModel("anthropic/claude-sonnet-4")
    .WithTemperature(0.8f)
    .WithMaxTokens(2000)
    .AddSystemMessage("You are a creative storyteller.")
    .AddUserMessage("Start a story about a robot.")
    .AddAssistantMessage("In a world of circuits and steel, "
        + "there lived a robot named Canvas-7...")
    .AddUserMessage("What happens next?")
    .Build();

var response = await aigClient.SendAsync(prompt);
Console.WriteLine(response.GetTextContent());

Custom OpenAI-Compatible Endpoints in C#

Connect to Nebius, Together AI, Groq, Ollama, LM Studio, or any OpenAI-compatible API with a single config change. Run local LLMs or use any hosted provider through the same unified C# interface.

CustomEndpoint.cs
// Connect to Nebius, Groq, Ollama — any OpenAI-compatible API
var config = new ProviderConfig
{
    ApiKey      = "your-nebius-key",
    ApiEndpoint = "https://api.tokenfactory.nebius.com/v1/chat/completions"
};

var prompt = new PromptBuilder()
    .WithModel("openai/openai/gpt-oss-120b")
    .AddUserMessage("Hello from Nebius!")
    .Build();

// Pass custom config directly
await foreach (var chunk in aigClient.SendStreamAsync(prompt, config))
{
    Console.Write(chunk.GetTextContent());
}

Nebius

tokenfactory.nebius.com

Together AI

api.together.xyz

Groq

api.groq.com

Ollama

localhost:11434

LM Studio

localhost:1234

Any OpenAI-compatible

your-endpoint.com

ASP.NET Core & Blazor AI Integration

Register IAigClient in your .NET dependency injection container and inject it into ASP.NET Core controllers, minimal API endpoints, or Blazor components. Production-ready AI for any .NET web app.

AiController.cs
// Register in Program.cs
builder.Services.AddHttpClient();
builder.Services.AddSingleton<IProviderFactory, ProviderFactory>();
builder.Services.AddSingleton<IAigClient, AigClient>();

// Inject and use in any controller
[ApiController]
[Route("api/[controller]")]
public class AiController : ControllerBase
{
    private readonly IAigClient _aigClient;

    public AiController(IAigClient aigClient) => _aigClient = aigClient;

    [HttpPost("chat")]
    public async Task<IActionResult> Chat([FromBody] ChatRequest req)
    {
        var prompt = new PromptBuilder()
            .WithModel(req.Model ?? "anthropic/claude-sonnet-4")
            .AddUserMessage(req.Message)
            .Build();

        var response = await _aigClient.SendAsync(prompt);
        return Ok(new { content = response.GetTextContent() });
    }
}
BYOK AI Gateway

Bring Your Own Key.
Zero markup.
Your keys, your cost.

The Noundry AI Gateway is live at api.noundry.ai. It's a BYOK (Bring Your Own Key) relay — pass your provider API key via the X-API-KEY header and the gateway routes to the right AI provider based on the model string. No markup. No hidden fees. Works with OpenAI, Anthropic, Google, and any OpenAI-compatible endpoint.

Automatic routing — openai/gpt-4 goes to OpenAI, anthropic/claude-sonnet-4 goes to Anthropic

Direct pass-through — your provider key is sent directly; we never store it

Built-in analytics — track token usage, latency, and costs per provider

Self-hostable — deploy the gateway yourself with the open-source Noundry.AIG.Api package

cURL
$ curl -X POST "https://api.noundry.ai/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_GATEWAY_KEY" \
  -H "X-API-KEY: Bearer YOUR_OPENAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4",
    "messages": [
      {
        "role": "user",
        "content": "Hello from the gateway!"
      }
    ]
  }'

Authorization

Your gateway API key

X-API-KEY

Your provider API key (passed through)

TOON — Token-Oriented Object Notation

Save ~40% on LLM tokens
with TOON serialization

TOON (Token-Oriented Object Notation) converts your C# DataTables, DataSets, and collections into a compact, LLM-optimized serialization format — dramatically reducing token usage and AI costs while maintaining full data fidelity. A smarter alternative to sending raw JSON to AI models.

Traditional JSON ~85 tokens
data.json
[
  {
    "product": "Widget",
    "qty": 10,
    "price": 9.99
  },
  {
    "product": "Gadget",
    "qty": 5,
    "price": 14.50
  }
]
TOON Format ~30 tokens — 65% smaller
data.toon
sales[2]{product,qty,price}:
  Widget,10,9.99
  Gadget,5,14.5
ToonExample.cs
using Noundry.AIG.Core.Extensions;

// Convert any DataTable to TOON
var table = new DataTable("sales");
table.Columns.Add("product", typeof(string));
table.Columns.Add("qty", typeof(int));
table.Columns.Add("price", typeof(decimal));
table.Rows.Add("Widget", 10, 9.99m);
table.Rows.Add("Gadget", 5, 14.50m);

var toonData = table.ToToon();

// Feed TOON data directly into your prompts
var request = new PromptBuilder()
    .WithModel("anthropic/claude-sonnet-4")
    .AddSystemMessage("Analyze the sales data in TOON format.")
    .AddUserMessage($"Data:\n\n{toonData}\n\nProvide insights.")
    .Build();

var response = await aigClient.SendAsync(request);
.NET Architecture

Clean, extensible C# design

Built on proven .NET design patterns — Factory, Builder, Strategy, Repository. Extend with new AI providers in minutes.

Noundry.AIG.Api

ASP.NET Core Web API · ChatController · Analytics · Middleware

Noundry.AIG.Client

AigClient · PromptBuilder · ChainPromptBuilder · TOON Extensions

Noundry.AIG.Providers

OpenAiProvider · AnthropicProvider · GoogleProvider · Custom Endpoints

Noundry.AIG.Core

AiRequest · AiResponse · ProviderConfig · Interfaces · Extensions

Factory

ProviderFactory

Builder

PromptBuilder

Strategy

IAiProvider

Repository

IAnalyticsRepository

Start chain prompting in C# today

One NuGet package. Every major AI provider. Chain prompting, TOON serialization, multi-provider fallback — production-ready from day one.

$ dotnet add package Noundry.AIG.Client

Why developers choose `Chain Prompting`

The open-source .NET AI toolkit trusted by C# developers for multi-provider LLM integration, prompt chaining, and token-optimized data serialization.

What is Chain Prompting?

Chain prompting (also called prompt chaining) is an AI orchestration technique where multiple LLM calls are linked in sequence — each step's output becomes the next step's input. This enables complex AI workflows like: generate an idea → expand into a draft → translate to another language. The ChainPromptBuilder in Noundry.AIG makes this trivial in C#, with support for mixing AI models across steps (e.g., use Claude for creativity, GPT-4 for code generation, Gemini for analysis).

What is TOON Serialization?

TOON (Token-Oriented Object Notation) is a compact data serialization format purpose-built for sending structured data to large language models. Unlike JSON, which uses verbose key-value pairs for every row, TOON defines column headers once and uses a tabular row format — achieving approximately 40% fewer tokens with identical data fidelity. In C#, simply call dataTable.ToToon() to convert any DataTable, DataSet, or collection.

Multi-Provider AI for .NET

Noundry.AIG is the Vercel AI SDK equivalent for .NET. It provides a unified C# interface for OpenAI GPT-4, Anthropic Claude, Google Gemini, Groq, Ollama, Nebius, Together AI, LM Studio, and any OpenAI-compatible endpoint. Switch providers by changing one model string — zero code changes. Built-in multi-provider fallback ensures your app stays online even when individual AI providers experience outages.

Built for ASP.NET Core, Blazor & Console Apps

Noundry.AIG integrates seamlessly with the .NET dependency injection container. Register IAigClient as a singleton and inject it into ASP.NET Core controllers, minimal API endpoints, Blazor components, or background services. Thread-safe by design with HttpClientFactory, SemaphoreSlim concurrency control, configurable retries with exponential backoff, and connection pooling. Production-ready from dotnet add package.

Get in Touch

Contact Us

Have questions about chain prompting, TOON, or integrating Noundry.AIG into your project? Drop us a line.

Message sent!

Thanks for reaching out. We'll get back to you soon.