Skip to main content
Use Qualifire to evaluate LLM outputs for quality, safety, and reliability. Detect prompt injections, hallucinations, PII, harmful content, and validate that your AI follows instructions.
Looking for async evaluations and observability? Check out the Qualifire Evals Integration for logging, tracing, and async evaluations.
1

Install the Qualifire SDK

Install the Qualifire Python SDK:
2

Configure Guardrails in LiteLLM

Define your guardrails under the guardrails section in your config.yaml:
litellm config.yaml
Supported values for mode:
  • pre_call - Run before LLM call, on input
  • post_call - Run after LLM call, on input & output
  • during_call - Run during LLM call, on input. Same as pre_call but runs in parallel as LLM call. Response not returned until guardrail check completes
3

Start LiteLLM Gateway

Start the LiteLLM gateway with your configuration:
4

Test Your Integration

Test your integration with a request. The guardrail will block requests that violate your policies.
When a guardrail violation is detected, you’ll receive an error response:

Using Pre-configured Evaluations

You can use evaluations pre-configured in the Qualifire Dashboard by specifying the evaluation_id:
litellm config.yaml
When evaluation_id is provided, LiteLLM will use invoke_evaluation() instead of evaluate(), running the pre-configured evaluation from your dashboard.

Available Checks

Enable individual checks directly in your guardrail configuration:

Example with Multiple Checks

Example with Custom Assertions

Parameter Reference

Default Behavior

  • If no evaluation_id is provided and no checks are explicitly enabled, prompt_injections defaults to true
  • When evaluation_id is provided, it takes precedence and individual check flags are ignored
  • on_flagged: "block" raises an HTTP 400 exception when violations are detected
  • on_flagged: "monitor" logs violations but allows the request to proceed

Complete Configuration Example

litellm config.yaml

Tool Call Support

Qualifire supports evaluating tool/function calls. When using tool_selection_quality_check, the guardrail will analyze tool calls in assistant messages:
This evaluates whether the LLM selected the appropriate tools and provided correct arguments.

Environment Variables

Additional Resources