Skip to content

Microsoft.Extensions.AI Integration

Cross-SDK comparison

See the centralized MEAI documentation for feature matrices and comparisons across all tryAGI SDKs.

The TypeSafeAI SDK provides integration with Microsoft.Extensions.AI, enabling seamless interoperability with the unified .NET AI abstractions.

Installation

1
dotnet add package tryAGI.TypeSafeAI

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
using Microsoft.Extensions.AI;
using TypeSafeAI;
using TypeSafeAI.Extensions.AI;

using var judgments = TypeSafeClient.CreateFromEnvironment();
var hazards = new QuestionSet();
var unsafeContent = hazards.AddNoul("unsafe", new NoulQuestion("Is this unsafe?"));

IChatClient guarded = new ChatClientBuilder(innerChatClient)
    .UseTypeSafeGuardrail(judgments, options =>
    {
        options.InputQuestions = hazards;
        options.Decide = assessment => assessment.Get(unsafeContent).Noul >= 0.7
            ? GuardrailDecision.Block("unsafe content")
            : GuardrailDecision.Allow;
    })
    .Build();

The integration package includes:

  • input and output guardrails, with optional buffered streaming checks;
  • TypeSafeRoutingChatClient for calibrated intent or confidence routing;
  • TypeSafeAIFunctions.Create for agent-callable judgments;
  • TypeSafeEvaluator for Microsoft.Extensions.AI.Evaluation numeric, boolean, and string metrics.

Next Steps