Skip to content

tryAGI/Guardrails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Guardrails

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official Guardrails AI OpenAPI specification using AutoSDK
  • Same day update to support new features
  • 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

using Guardrails;

// Connect to a self-hosted Guardrails server (default: http://localhost:8000)
using var client = new GuardrailsClient(apiKey);

// Or specify a custom base URL
using var client = new GuardrailsClient(apiKey, baseUri: new Uri("https://my-guardrails-server.example.com"));

Validate LLM Output

var result = await client.Validate.ValidateAsync(
    guardName: "my-guard",
    llmOutput: "Some LLM output to validate");

Console.WriteLine($"Validation passed: {result.ValidationPassed}");

List Guards

var guards = await client.Guard.GetGuardsAsync();
foreach (var guard in guards)
{
    Console.WriteLine($"Guard: {guard.Name} ({guard.Id})");
}

MEAI Tools

using Microsoft.Extensions.AI;

// Use Guardrails as tools with any IChatClient
var tools = new[]
{
    client.AsValidateTool(),
    client.AsListGuardsTool(),
    client.AsGetGuardTool(),
};

var chatOptions = new ChatOptions { Tools = [..tools] };

Support

Priority place for bugs: https://github.com/tryAGI/Guardrails/issues
Priority place for ideas and general questions: https://github.com/tryAGI/Guardrails/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.

About

C# SDK for the Guardrails AI API -- LLM validation, hallucination detection, PII protection, and content safety

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors