PrimusSaaS.AI 2.0.0

dotnet add package PrimusSaaS.AI --version 2.0.0
                    
NuGet\Install-Package PrimusSaaS.AI -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PrimusSaaS.AI" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PrimusSaaS.AI" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PrimusSaaS.AI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PrimusSaaS.AI --version 2.0.0
                    
#r "nuget: PrimusSaaS.AI, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PrimusSaaS.AI@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PrimusSaaS.AI&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PrimusSaaS.AI&version=2.0.0
                    
Install as a Cake Tool

Primus.AI SDK

AI integration SDK for .NET applications. Provides unified abstraction over Azure OpenAI and GitHub Models with tenant isolation, token budgets, prompt injection detection, and structured outputs.

Installation

dotnet add package Primus.AI

Quick Start

Basic Setup (Azure OpenAI)

using Primus.AI;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddPrimusAI(ai =>
{
    ai.UseAzureOpenAI(opts =>
    {
        opts.Endpoint = builder.Configuration["AzureOpenAI:Endpoint"];
        opts.ApiKey = builder.Configuration["AzureOpenAI:ApiKey"];
        opts.DefaultDeployment = "gpt-4o";
    });
    
    ai.ConfigureDefaults(opts =>
    {
        opts.MaxTokens = 4096;
        opts.Temperature = 0.7f;
    });
    
    // Enable safety features
    ai.EnablePromptInjectionDetection();
    ai.EnableTokenBudgets(budget =>
    {
        budget.DefaultDailyLimit = 100_000;
        budget.EnforceLimits = true;
    });
});

Using GitHub Models

builder.Services.AddPrimusAI(ai =>
{
    ai.UseGitHubModels(opts =>
    {
        opts.Token = builder.Configuration["GitHub:Token"];
        opts.DefaultModel = "gpt-4o";
    });
});

Chat Completion

public class ChatController : ControllerBase
{
    private readonly IAIClient _aiClient;
    
    public ChatController(IAIClient aiClient)
    {
        _aiClient = aiClient;
    }
    
    [HttpPost("chat")]
    public async Task<IActionResult> Chat([FromBody] ChatRequest request)
    {
        var response = await _aiClient.ChatAsync(new ChatCompletionRequest
        {
            Messages = 
            [
                ChatMessage.System("You are a helpful assistant."),
                ChatMessage.User(request.Message)
            ],
            MaxTokens = 1000
        });
        
        return Ok(new { response.Content, response.TokensUsed });
    }
}

Multi-Tenant with Token Budgets

builder.Services.AddPrimusAI(ai =>
{
    ai.UseAzureOpenAI(opts => { /* config */ });
    
    ai.ConfigureTenantIsolation(opts =>
    {
        opts.Enabled = true;
        opts.TenantIdClaimType = "tenant_id";
    });
    
    ai.EnableTokenBudgets(budget =>
    {
        budget.DefaultDailyLimit = 50_000;
        budget.DefaultMonthlyLimit = 1_000_000;
        budget.EnforceLimits = true;
        budget.TrackByTenant = true;
    });
});

// In your service:
public class TenantAwareAIService
{
    private readonly IAIClient _aiClient;
    private readonly ITenantContext _tenantContext;
    
    public async Task<string> GenerateAsync(string prompt)
    {
        // Token usage is automatically tracked per tenant
        var response = await _aiClient.ChatAsync(
            new ChatCompletionRequest { /* ... */ },
            tenantId: _tenantContext.TenantId);
            
        return response.Content;
    }
}

Prompt Injection Detection

builder.Services.AddPrimusAI(ai =>
{
    ai.UseAzureOpenAI(opts => { /* config */ });
    
    ai.EnablePromptInjectionDetection(opts =>
    {
        opts.BlockSuspiciousPrompts = true;
        opts.LogDetections = true;
        opts.CustomPatterns = 
        [
            @"ignore\s+(previous|all)\s+instructions",
            @"you\s+are\s+now\s+DAN"
        ];
    });
});

Structured Outputs (JSON Mode)

public record ProductDescription(string Title, string Summary, string[] Features);

var response = await _aiClient.ChatAsync<ProductDescription>(new ChatCompletionRequest
{
    Messages =
    [
        ChatMessage.System("Generate a product description in JSON format."),
        ChatMessage.User("Describe a wireless gaming mouse.")
    ],
    ResponseFormat = ResponseFormat.Json
});

// response.Content is a deserialized ProductDescription
Console.WriteLine(response.Content.Title);

Streaming Responses

await foreach (var chunk in _aiClient.StreamChatAsync(request))
{
    Console.Write(chunk.Content);
}

Configuration

appsettings.json

{
  "PrimusAI": {
    "Provider": "AzureOpenAI",
    "AzureOpenAI": {
      "Endpoint": "https://your-resource.openai.azure.com/",
      "ApiKey": "your-api-key",
      "DefaultDeployment": "gpt-4o"
    },
    "Defaults": {
      "MaxTokens": 4096,
      "Temperature": 0.7
    },
    "TokenBudget": {
      "DefaultDailyLimit": 100000,
      "EnforceLimits": true
    },
    "PromptInjection": {
      "Enabled": true,
      "BlockSuspiciousPrompts": true
    }
  }
}

Environment Variables

PRIMUSAI__PROVIDER=AzureOpenAI
PRIMUSAI__AZUREOPENAI__ENDPOINT=https://your-resource.openai.azure.com/
PRIMUSAI__AZUREOPENAI__APIKEY=your-api-key
PRIMUSAI__AZUREOPENAI__DEFAULTDEPLOYMENT=gpt-4o

Features

Feature Description
Provider Abstraction Unified API over Azure OpenAI and GitHub Models
Tenant Isolation Automatic context separation for multi-tenant apps
Token Budgets Track and enforce token usage per tenant
Prompt Injection Detection Detect and block malicious prompts
Structured Outputs JSON mode with automatic deserialization
Streaming Async streaming responses
Retry Policies Built-in exponential backoff

SDK-Only Design

This SDK runs entirely in your application. It does NOT:

  • Store any prompts or responses
  • Proxy requests through Primus servers
  • Collect telemetry or usage data

All API calls go directly to Azure OpenAI or GitHub Models using your credentials.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 104 1/12/2026

v2.0.0:
- Standardized Framework Release.
- Renamed all packages to PrimusSaaS.* namespace.
- Synchronized versions across the entire suite.
- Enhanced metadata and fixed consistency issues.