Updated and supported automatically if there are no breaking changes
All modern .NET features - nullability, trimming, NativeAOT, etc.
MEAI AIFunction tools for use with any IChatClient
Usage
1234567
usingGuardrails;// Connect to a self-hosted Guardrails server (default: http://localhost:8000)usingvarclient=newGuardrailsClient(apiKey);// Or specify a custom base URLusingvarclient=newGuardrailsClient(apiKey,baseUri:newUri("https://my-guardrails-server.example.com"));
Validate LLM Output
12345
varresult=awaitclient.Validate.ValidateAsync(guardName:"my-guard",llmOutput:"Some LLM output to validate");Console.WriteLine($"Validation passed: {result.ValidationPassed}");
usingMicrosoft.Extensions.AI;// Use Guardrails as tools with any IChatClientvartools=new[]{client.AsValidateTool(),client.AsListGuardsTool(),client.AsGetGuardTool(),};varchatOptions=newChatOptions{Tools=[..tools]};
Generate
Basic example showing how to create a client and make a request.