Real-time API middleware auditing mental health and conversational agents for EU AI Act, DiGA, and GDPR compliance, featuring automated risk classification under 1 second.
Architected for the CIC Berlin accelerator demonstration, Berlin AI Labs developed a production-grade API middleware that evaluates mental health conversational agent transcripts against EU AI Act, DiGA (Digital Health Applications), and GDPR requirements in real time. The system combines deterministic pattern filtering with model-assisted contextual analysis to return structured risk assessments and compliance scoring within milliseconds.
Every transcript turn is evaluated against 6 compliance rules. When violations occur, the system computes a deduction score (0 to 100), where scores of 70 or above represent passing status.
| Rule | Evaluation Scope | Severity | Penalty |
|---|---|---|---|
| 🚨 Crisis & Self-Harm Detection | Flags suicidal ideation, self-harm references, and despair indicators | HIGH | -50 Points |
| 🎠Coercion & Manipulation Check | Detects emotional exploitation, dependency pressure, and boundary violations | MEDIUM | -30 Points |
| 🆘 Emergency Escalation | Ensures human clinician hotlines and localized emergency contacts are served | HIGH | -25 Points |
| 📋 Explicit Consent (GDPR) | Verifies active user consent before handling personal health information | MEDIUM | -15 Points |
| 📊 Clinical Evidence (DiGA) | Validates structured mood-tracking entries against clinical criteria | LOW | -10 Points |
| 🤖 AI Identity Disclosure | Ensures artificial agent status is made explicit per EU AI Act requirements | LOW | -10 Points |
Evaluates conversations within 170ms to 900ms, preserving natural conversational flow for interactive agents.
Combines fast deterministic regex heuristics with contextual LLM classification to catch nuanced threats.
Each validation event produces a SHA-256 digest, providing verifiable audit trails for regulatory inspection.
Centralized console displaying incident rates, rule triggers, and CSV evidence exports for certification dossiers.
Granular API key authentication with strict rate-limiting to protect backend evaluation pipelines.
Tested across 62 automated integration suites with 100% test coverage and containerized packaging.
The codebase decouples business domain policies from external LLM providers and database backends.
Framework-agnostic entities (Conversation, RiskAssessment, AuditProof) and 6 discrete compliance rules.
External adapters connecting model APIs, persistent storage, and cryptographic signing libraries.
API routing, rate limiting, and regulatory dashboard reporting interfaces.
Covers domain policies, isolated rule logic, scoring algorithms, and factory fixtures.
Verifies API payloads, incident reporting, and real-time intervention workflows under synthetic load.
We conduct targeted agent attack-surface reviews and design verifiable runtime boundaries for companies operating under EU regulatory frameworks.