Skip to main content
Dome allows you to create custom detectors to implement domain-specific detection logic. This guide covers creating, registering, and using custom detectors.

Detection Categories

Register your detector with one of these categories:
CategoryUse Case
DetectionCategory.SecurityAdversarial attacks, injections
DetectionCategory.ModerationHarmful content, toxicity
DetectionCategory.PrivacyPII, secrets, sensitive data
DetectionCategory.IntegrityData quality, format validation
DetectionCategory.GenericAnything else
The category determines which guard types can use your detector.

Detection Result Format

The detect method must return a tuple of (flagged: bool, metadata: dict)
Always include query_string and response_string in metadata for proper guardrail operation.

Using Custom Detectors

  • Define before instantiation: custom detectors must be defined before creating the Dome instance.
  • Import from separate file: for cleaner organization, define detectors in a separate module.
Import your custom detector module before creating the Dome instance. The @register_method decorator must run before the config is parsed.

Example Detectors

  • Rate Limiter: Track request frequency per user
  • Regex Pattern Detector: Block content matching patterns
  • External API Detector: Call an external service for detection
  • Semantic Similarity Detector: Block content similar to known bad examples

Work in Progress

The programmatic protection capabilities and Dome integrations are currently in private preview and subject to change.

Next Steps

Configure Guardrails

Use custom detectors in configurations

Use Guardrails

Runtime integration patterns

Observability

Monitor custom detector performance

Protection Overview

Built-in detectors reference
Last modified on April 20, 2026