Skip to content

Installation Guide ​

This guide will help you install elsai Guardrails and set up your development environment.

Prerequisites ​

  • Python 3.10 or higher
  • pip package manager

Installation ​

Basic Installation ​

bash
pip install --extra-index-url https://elsai-core-package.optisolbusiness.com/root/elsai-guardrails/ elsai-guardrails==0.1.5

PII/PHI Detection Setup ​

If you plan to use PII/PHI Detection and Data Masking, download the required spaCy language model after installing the package:

bash
python -m spacy download en_core_web_lg

This step is required for PII/PHI detection to work. Without this model, entity-based detection will not function correctly.

Optional Environment Variables ​

For semantic content classification (jailbreak detection, prompt injection, etc.), you can configure an embedding encoder. The encoder type is configured via the ENCODER_TYPE environment variable.

If encoder environment variables are not provided, the system will automatically use HuggingFace encoder as the default (local, no API key required).

Encoder Configuration ​

Set the encoder type:

bash
export ENCODER_TYPE="openai"  # or any supported encoder from the table below

Supported Encoder Types ​

Encoder TypeAPI Key RequiredSpeedQualityExample Environment Variables
huggingfaceNo (default)MediumGoodNo configuration needed
openaiYesFastExcellentOPENAI_API_KEY
azure_openaiYesFastExcellentAZURE_OPENAI_EMBEDDING_DEPLOYMENT
AZURE_OPENAI_EMBEDDING_ENDPOINT
AZURE_OPENAI_EMBEDDING_API_KEY
AZURE_OPENAI_EMBEDDING_API_VERSION
cohereYesFastExcellentCOHERE_API_KEY
googleYesFastExcellentGOOGLE_API_KEY
fastembedNoVery FastGoodNo configuration needed
ollamaNoMediumGoodOLLAMA_BASE_URL (optional)
mistralYesFastExcellentMISTRAL_API_KEY
voyageYesFastExcellentVOYAGE_API_KEY
jinaYesFastExcellentJINA_API_KEY
bedrockYesFastExcellentAWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION
bm25NoVery FastFairNo configuration needed
tfidfNoVery FastFairNo configuration needed
localNoMediumVariableLOCAL_MODEL (model name)

Example: Using Azure OpenAI Encoder ​

bash
export ENCODER_TYPE="azure_openai"
export AZURE_OPENAI_EMBEDDING_DEPLOYMENT="text-embedding-ada-002"
export AZURE_OPENAI_EMBEDDING_ENDPOINT="https://your-endpoint.openai.azure.com"
export AZURE_OPENAI_EMBEDDING_API_KEY="your-azure-api-key"
export AZURE_OPENAI_EMBEDDING_API_VERSION="2024-02-15-preview"

For complete encoder configuration details, see the Semantic Classification documentation.

ARMS Storage Setup (v0.1.5) ​

If you plan to use ARMS Storage, set Backend credentials (shared with ARMS):

bash
export API_BASE_URL="https://your-arms-backend"
export ELSAI_ARMS_API_KEY="your-api-key"
# Optional correlation ids:
export GUARDRAILS_ARMS_RUN_ID="your-run-id"
export GUARDRAILS_ARMS_PROJECT_ID="your-project-id"

Enable storage in your guardrails policy:

yaml
guardrails:
  storage:
    enabled: true
    project: my-app
    arms_correlation: true

Data Exfiltration Setup (v0.1.5) ​

If you plan to use Data Exfiltration Detection, enable it on output checks:

yaml
guardrails:
  output_checks: true
  data_exfiltration:
    enabled: true
    action_thresholds:
      warn: 20
      block: 80

The optional detect-secrets package improves credential detection when installed:

bash
pip install detect-secrets

Regex-based detection still runs when the plugin is not installed.

Verify Installation ​

Check that the package is installed correctly:

bash
pip show elsai-guardrails

Next Steps ​

Released under the MIT License.