TrustifAI evaluates LLM and RAG responses through four trust signals — evidence coverage, epistemic consistency, semantic drift, and source diversity — and combines them into a single weighted Trust Score. This guide walks you through installing the SDK, configuring your environment, scoring a RAG response, and visualizing the reasoning behind the score.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TrustifAI/trustifai/llms.txt
Use this file to discover all available pages before exploring further.
Install TrustifAI
TrustifAI requires Python 3.10 or later. Install it from PyPI:For full installation options including tracing and test extras, see the Installation guide.
Set up your environment
TrustifAI uses LiteLLM to call LLMs and embedding models, so you configure it by setting the appropriate API key for your provider. Create a Then point your
.env file in your project root:.env
config_file.yaml at the model you want to use:config_file.yaml
Score a RAG response
Use The result dictionary contains the aggregated
MetricContext to bundle your query, answer, and retrieved documents, then call get_trust_score():score (0.0–1.0), a human-readable label (RELIABLE, ACCEPTABLE (WITH CAUTION), or UNRELIABLE), and a details dictionary with individual metric scores.Generate with real-time confidence scoring
For online evaluation — where you want confidence alongside generation — use the
generate() method. It calls your configured LLM with logprobs enabled and returns a confidence score derived from token log probabilities:Confidence scoring relies on token log probabilities. Not all models expose
logprobs, and poorly calibrated models may produce unreliable confidence estimates. Check your provider’s documentation before relying on this signal in production.Visualize the reasoning graph
TrustifAI builds a directed acyclic graph (DAG) that shows how each metric score flows into the final trust decision. Pass your The PyVis output is a physics-based interactive graph where nodes are color-coded by trust level: green for high trust, orange for partial, and red for low trust.
result to build_reasoning_graph(), then call visualize():Next steps
Installation
Full installation options including trace and test extras, git clone setup, and all supported provider keys.
Configuration
Tune metric thresholds, adjust score weights, and configure LiteLLM providers.
Core concepts
Understand how each trust signal is computed and combined into the final score.
Custom metrics
Extend TrustifAI with your own evaluation logic using the
BaseMetric interface.