Skip to content

Repository files navigation

Guardrails

Nuget packagedotnetLicense: MITDiscord

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

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

varresult=awaitclient.Validate.ValidateAsync(guardName:"my-guard",llmOutput:"Some LLM output to validate");Console.WriteLine($"Validation passed: {result.ValidationPassed}");

List Guards

varguards=awaitclient.Guard.GetGuardsAsync();foreach(varguardinguards){Console.WriteLine($"Guard: {guard.Name} ({guard.Id})");}

MEAI Tools

usingMicrosoft.Extensions.AI;// Use Guardrails as tools with any IChatClientvartools=new[]{client.AsValidateTool(),client.AsListGuardsTool(),client.AsGetGuardTool(),};varchatOptions=newChatOptions{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

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages