n4nAI

Topic

C# / .NET LLM API Integration

13 posts on c# / .net llm api integration — part of api integration on the n4n AI blog.

API integrationHow-to

Unit testing LLM API integrations in C# with Moq

Learn how to unit test LLM API integrations in C# using Moq to isolate HTTP calls, mock responses, and verify behavior without hitting live endpoints.

2 min read
API integrationComparison

System.Text.Json vs Newtonsoft.Json for LLM responses

A pragmatic head-to-head comparison of System.Text.Json vs Newtonsoft.Json for parsing, streaming, and serializing LLM responses in C# .NET apps.

4 min read
API integrationHow-to

Streaming LLM responses in .NET with IAsyncEnumerable

Step-by-step guide to dotnet iasyncenumerable streaming llm integration in C#, with runnable code and verification for production-grade apps.

3 min read
API integrationComparison

Semantic Kernel vs raw HTTP for .NET LLM integration

Compare Semantic Kernel vs raw HTTP dotnet for production LLM apps: capabilities, cost, latency, ergonomics, ecosystem, limits, and which to choose.

5 min read
API integrationHow-to

Polly retry policies for OpenAI API calls in .NET

Implement resilient LLM calls in C# using Polly retry policies for OpenAI API failures, with step-by-step code for transient error handling.

3 min read
API integrationHow-to

NuGet setup for an OpenAI-compatible C# client

Install and configure a NuGet OpenAI-compatible C# client for .NET apps: package setup, base URL, auth, and a test chat call to verify.

4 min read
API integrationGuide

IHttpClientFactory best practices for LLM API clients

Practical patterns for using IHttpClientFactory in .NET to build resilient LLM API clients, covering pooling, streaming, retries, and metering.

3 min read
API integrationHow-to

Handling 429 rate limits in .NET LLM clients

Practical steps to handle dotnet 429 rate limit llm errors in C# clients with retry, backoff, and fallback to keep LLM calls resilient.

3 min read
API integrationHow-to

Dependency injection for LLM clients in .NET 8

Learn to implement a dotnet 8 dependency injection llm client using OpenAI-compatible endpoints, resilient provider fallbacks, and testable service layers.

3 min read
API integrationComparison

Azure OpenAI SDK vs OpenAI-compatible REST in .NET

Head-to-head comparison of Azure OpenAI SDK vs OpenAI-compatible REST in .NET: capabilities, cost, latency, ergonomics, ecosystem, limits, and verdict.

4 min read
API integrationGuide

Async/await patterns for concurrent LLM calls in C#

Hands-on guide to c# async await concurrent llm calls: use Task.WhenAll, SemaphoreSlim, and proper cancellation to build resilient .NET LLM integrations.

4 min read
API integrationTutorial

Calling the OpenAI API from C# with HttpClient

Learn how to call the OpenAI API from C# using HttpClient with a hands-on tutorial covering auth, requests, streaming, and error handling.

2 min read
API integrationTutorial

Building a minimal API wrapper for n4n in ASP.NET Core

Hands-on tutorial: build an ASP.NET Core minimal API wrapper for the n4n LLM gateway using its OpenAI-compatible endpoint with C#.

3 min read