EUAIActClassifier 0.0.1
See the version list below for details.
dotnet add package EUAIActClassifier --version 0.0.1
NuGet\Install-Package EUAIActClassifier -Version 0.0.1
<PackageReference Include="EUAIActClassifier" Version="0.0.1" />
<PackageVersion Include="EUAIActClassifier" Version="0.0.1" />
<PackageReference Include="EUAIActClassifier" />
paket add EUAIActClassifier --version 0.0.1
#r "nuget: EUAIActClassifier, 0.0.1"
#:package EUAIActClassifier@0.0.1
#addin nuget:?package=EUAIActClassifier&version=0.0.1
#tool nuget:?package=EUAIActClassifier&version=0.0.1
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
Minimalif 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 = 0for 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 | Versions 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. |
-
.NETStandard 2.0
- Microsoft.Extensions.AI (>= 10.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.