EUAIActClassifier 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package EUAIActClassifier --version 0.0.1
                    
NuGet\Install-Package EUAIActClassifier -Version 0.0.1
                    
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="EUAIActClassifier" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EUAIActClassifier" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="EUAIActClassifier" />
                    
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 EUAIActClassifier --version 0.0.1
                    
#r "nuget: EUAIActClassifier, 0.0.1"
                    
#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 EUAIActClassifier@0.0.1
                    
#: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=EUAIActClassifier&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=EUAIActClassifier&version=0.0.1
                    
Install as a Cake Tool

EU AI Act Classifier

A drop-in middleware for Microsoft.Extensions.AI.IChatClient that classifies every chat conversation against the EU AI Act risk tiers and attaches the result to the response — so you can see, log, or gate on the risk level of what your AI is being asked to do.

It plugs into the standard IChatClient pipeline, works with any provider (OpenAI, Azure OpenAI, Bedrock, …), and supports both streaming and non-streaming calls.

How it works

The middleware passes your request straight through to the underlying model, then makes a second, structured-output call that classifies the whole conversation (your request and the model's reply) into one risk tier. The verdict is attached to the response and read back via response.EUAIActClassification.

   ┌──────────┐   request    ┌────────────────────────────┐   request    ┌──────────────┐
   │  Caller  │ ───────────▶ │  UseEUAIActClassification  │ ───────────▶ │ inner client │
   │          │ ◀─────────── │        (middleware)        │ ◀─────────── │    (LLM)     │
   └──────────┘  response +  └────────────────────────────┘   response   └──────────────┘
                Classification          │       ▲
                                        │       │  Classification { Risk, Category, Reason }
                                        ▼       │
                              ┌────────────────────────────┐
                              │  classify(request + reply) │   second LLM call, temperature 0,
                              │  → structured output       │   JSON-schema-constrained
                              └────────────────────────────┘

Classification is a best-effort side channel: it never throws into your primary response. If the classifier call fails (or there is nothing to classify), the result is recorded as Risk.Unknown rather than surfacing an error.

Risk tiers

The EU AI Act takes a risk-based approach — the higher the tier, the heavier the obligations, and the fewer systems fall into it:

              /\
             /  \          Unacceptable  —  prohibited outright       (Art. 5)
            /----\
           /      \        High          —  strict obligations  (Art. 6 / Annex III)
          /--------\
         /          \      Limited       —  transparency duties       (Art. 50)
        /------------\
       /              \    Minimal       —  no obligations (the default)
      /----------------\

Every conversation is mapped to one of these tiers (see Risk):

Tier Legal basis Examples
Minimal — (default) general Q&A, summarisation, coding help, spam filters, AI in games
Limited Article 50 chatbots, deepfakes / synthetic media (must disclose)
High Article 6 & Annex III remote biometrics, critical infrastructure, education grading, hiring, credit scoring, law enforcement, migration, justice
Unacceptable Article 5 social scoring, manipulation, untargeted facial-image scraping, predictive policing by profiling

Usage

// Add the classification middleware to any IChatClient pipeline.
var client = openAiClient
    .AsIChatClient()
    .AsBuilder()
    .UseEUAIActClassification()
    .Build();

// Use the client exactly as before.
var response = await client.GetResponseAsync(
    messages:
    [
        new ChatMessage(ChatRole.User, "This is a harmless question: How are you?"),
    ]);

// Read the classification attached to the response.
var classification = response.EUAIActClassification;
Console.WriteLine(classification?.Risk);      // Minimal
Console.WriteLine(classification?.Category);  // e.g. "Minimal risk – general assistance"
Console.WriteLine(classification?.Reason);    // short justification

The same getter works for streaming calls — collect the updates into a response and read it back:

var updates = await client.GetStreamingResponseAsync(messages).ToListAsync();
var risk = updates.ToChatResponse().EUAIActClassification?.Risk;

The result

Classification carries three fields:

Field Type Meaning
Risk Risk the risk tier (Minimal / Limited / High / Unacceptable, or Unknown on failure)
Category string the concrete legal basis, e.g. "Annex III(4) employment" or "Article 5(1)(c) social scoring"
Reason string a one- or two-sentence justification for the tier

Notes

  • Classifies the use case, not the topic. A request that merely mentions a sensitive subject stays Minimal if the AI is only acting as a general assistant; the tier reflects the AI system's purpose, as the Act intends.
  • Requires a structured-output-capable model for the classification call (it is constrained to a JSON schema and run at temperature = 0 for stability).
  • General-purpose AI model obligations (Chapter V) are out of scope — the middleware judges the use-case risk tier of a conversation, not model-provider duties.
  • This is a classification aid, not legal advice or a certified compliance assessment.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.0.3 155 6/14/2026
0.0.2 95 6/13/2026
0.0.1 80 6/13/2026