Skip to main content
This guide shows how to check prompts with OpenLIT’s local guardrails and combine checks with a Pipeline. The examples run without an LLM provider or API key. Start with prompt injection detection, then add sensitive topic filtering and OpenTelemetry guardrail metrics.
1

Initialize guardrails

Evaluate a prompt with PromptInjection:
Combine checks in a pipeline:
example.py
Output
A Pipeline evaluates its guards in order and stops when a guard returns deny. For other checks, use specific guardrails; TopicRestriction requires a user-provided classifier and an allowed or denied topic list:

Prompt injection detection

Detect and block malicious prompt injection attacks and jailbreak attempts

Sensitive topic filtering

Filter sensitive content including personal data, financial information, and confidential topics

Topic restriction

Restrict LLM responses to approved topics and prevent off-topic conversations
For more guardrail options, explore our Guardrails Guide.
2

Track AI Guardrail metrics

Initialize OpenLIT with either method below, then evaluate prompts through a Pipeline. The pipeline emits per-guard metrics when metrics are enabled and configured. It adds guard.evaluation events only to an active recording span; the standalone examples below demonstrate metrics. No collect_metrics guard argument is needed.
No code changes needed - instrument via CLI:
Then in your application:
Metrics are sent to the same OpenTelemetry backend configured during instrumentation, check our supported destinations for configuration details.
You can now evaluate prompts with individual guards, compose checks in a pipeline, and send guardrail metrics to your OpenTelemetry backend. If you have any questions or need support, reach out to our community.

Integrations

60+ AI integrations with automatic instrumentation and performance tracking

Create a dashboard

Create custom visualizations with flexible widgets, queries, and real-time AI monitoring

Manage prompts

Version, deploy, and collaborate on prompts with centralized management and tracking