Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getbifrost.ai/llms.txt

Use this file to discover all available pages before exploring further.

Guardrails are an enterprise-only feature and require the enterprise Bifrost image.
Credential and endpoint fields in guardrail provider config blocks support "env.VAR_NAME" strings (e.g. "env.AWS_SECRET_KEY"). Bifrost resolves the value from the process environment at startup. See the Environment Variable Support section for the complete per-provider field list.
Guardrails are configured under guardrails_config in config.json. The configuration has two parts:
  • guardrail_providers - the backend that performs the check. Rules link to providers by id.
  • guardrail_rules - CEL expressions that control when and where providers are invoked.

Providers

Runs entirely in-process with no external dependency. Patterns use RE2 syntax. Supports optional per-pattern flags: i (case-insensitive), m (multiline), s (dot-all).
{
  "guardrails_config": {
    "guardrail_providers": [
      {
        "id": 1,
        "provider_name": "regex",
        "policy_name": "block-secrets",
        "enabled": true,
        "timeout": 5,
        "config": {
          "patterns": [
            { "pattern": "sk-[A-Za-z0-9]{20,}", "description": "OpenAI API key" },
            { "pattern": "AKIA[0-9A-Z]{16}", "description": "AWS access key" },
            { "pattern": "gh[ps]_[A-Za-z0-9]{36}", "description": "GitHub token", "flags": "i" }
          ],
          "sampling_rate": 100
        }
      }
    ]
  }
}
The Web UI’s PII Detection template is also a regex provider configuration. See Custom Regex for the full config.json and Helm examples.

Provider Fields

FieldRequiredDescription
idYesUnique integer ID - referenced by rules via provider_config_ids
provider_nameYesBackend: "regex", "secrets", "bedrock", "azure", "patronus-ai", "grayswan"
policy_nameYesHuman-readable policy label
enabledYestrue to activate
timeoutNoExecution timeout in seconds
configNoProvider-specific configuration object

Environment Variable Support

Any field marked env.* supported accepts a bare "env.VAR_NAME" string in addition to a literal value. Bifrost resolves the variable from the process environment at startup. Fields marked plain only must be a literal value (boolean, number, array, or string).

AWS Bedrock

FieldRequiredenv.* supportedNotes
guardrail_arnYesYesARN of the Bedrock guardrail
guardrail_versionYesYes"DRAFT" or a published version number
regionYesYesAWS region (e.g. "us-east-1")
auth_typeNoYes"keys" (default) | "api_key" | "iam_role"
access_keyConditionalYesRequired when auth_type="keys"
secret_keyConditionalYesRequired when auth_type="keys"
session_tokenNoYesOptional temporary session token
bedrock_api_keyConditionalYesRequired when auth_type="api_key"
role_arnNoYesIAM role ARN to assume (optional, auth_type="iam_role")
external_idNoYesExternal ID for role assumption
session_nameNoYesSession name for role assumption
sampling_rateNoPlain only0100; percentage of requests to evaluate (default: 100)
timeoutNoPlain onlyExecution timeout in seconds

Azure Content Safety

FieldRequiredenv.* supportedNotes
endpointYesYesAzure Content Safety resource URL
auth_typeNoYes"api_key" (default) | "default_credential" | "entra_id"
api_keyConditionalYesRequired when auth_type="api_key"
client_idConditionalYesRequired when auth_type="entra_id"
client_secretConditionalYesRequired when auth_type="entra_id"
tenant_idConditionalYesRequired when auth_type="entra_id"
analyze_severity_thresholdNoYes"low" | "medium" | "high" (default: "medium")
analyze_enabledNoPlain onlyEnable text analysis (default: true)
jailbreak_shield_enabledNoPlain onlyEnable jailbreak detection (default: false)
indirect_attack_shield_enabledNoPlain onlyEnable indirect attack detection (default: false)
copyright_enabledNoPlain onlyEnable copyright detection (default: false)
text_blocklist_enabledNoPlain onlyEnable custom blocklists (default: false)
scopesNoPlain onlyOAuth scopes (string array)
blocklist_namesNoPlain onlyBlocklist names to apply (string array)
sampling_rateNoPlain only0100; percentage of requests to evaluate (default: 100)
timeoutNoPlain onlyExecution timeout in seconds

Patronus AI

FieldRequiredenv.* supportedNotes
api_keyYesYesPatronus AI API key
environmentNoYes"production" (default) | "development"
sampling_rateNoPlain only0100; percentage of requests to evaluate (default: 100)
timeoutNoPlain onlyExecution timeout in seconds

Gray Swan

FieldRequiredenv.* supportedNotes
api_keyYesYesGray Swan API key
base_urlNoYesCustom API base URL (uses Gray Swan default if unset)
reasoning_modeNoYes"standard" | "fast" | "off" (default: "standard")
violation_thresholdNoPlain only0.01.0; higher = more permissive (default: 0.5)
policy_idNoPlain onlySingle policy ID string
policy_idsNoPlain onlyMultiple policy IDs (string array)
rulesNoPlain onlyInline rule map ({ "rule_name": "description" })
sampling_rateNoPlain only0100; percentage of requests to evaluate (default: 100)
timeoutNoPlain onlyExecution timeout in seconds

Regex

FieldRequiredenv.* supportedNotes
patternsYesPlain onlyArray of { pattern, description?, flags? } objects
sampling_rateNoPlain only0100; percentage of requests to evaluate (default: 100)

Secrets

FieldRequiredenv.* supportedNotes
ignored_secret_keywordsNoPlain onlyString array of substrings used to suppress known false-positive secret matches

Rules

Rules are CEL expressions that fire when their condition matches. Available CEL variables:
VariableTypeDescription
modelstringModel name from the request
providerstringProvider name (e.g. "openai")
headersmap<string,string>HTTP request headers
paramsmap<string,string>Query parameters
customerstringCustomer ID
teamstringTeam ID
userstringUser ID
{
  "guardrails_config": {
    "guardrail_rules": [
      {
        "id": 101,
        "name": "block-secrets-input",
        "description": "Block prompts containing credentials",
        "enabled": true,
        "cel_expression": "true",
        "apply_to": "input",
        "sampling_rate": 100,
        "timeout": 10,
        "provider_config_ids": [1]
      },
      {
        "id": 102,
        "name": "content-safety-gpt4o-output",
        "enabled": true,
        "cel_expression": "model == 'gpt-4o'",
        "apply_to": "output",
        "sampling_rate": 100,
        "timeout": 15,
        "provider_config_ids": [3]
      },
      {
        "id": 103,
        "name": "grayswan-openai-partial",
        "enabled": true,
        "cel_expression": "provider == 'openai'",
        "apply_to": "input",
        "sampling_rate": 50,
        "timeout": 20,
        "provider_config_ids": [5]
      }
    ]
  }
}

Rule Fields

FieldRequiredDescription
idYesUnique integer ID
nameYesHuman-readable name
descriptionNoOptional description
enabledYestrue to activate
cel_expressionYesCEL boolean expression. "true" matches every request
apply_toYes"input", "output", or "both"
sampling_rateNo0100; percentage of requests to evaluate (default: 100)
timeoutNoRule timeout in seconds
provider_config_idsNoid values of providers to invoke when this rule matches. Multiple providers run in parallel

Full Example

{
  "$schema": "https://www.getbifrost.ai/schema",
  "encryption_key": "env.BIFROST_ENCRYPTION_KEY",

  "providers": {
    "openai": {
      "keys": [{ "name": "primary", "value": "env.OPENAI_API_KEY", "models": ["*"], "weight": 1.0 }]
    }
  },

  "guardrails_config": {
    "guardrail_providers": [
      {
        "id": 1,
        "provider_name": "regex",
        "policy_name": "block-secrets",
        "enabled": true,
        "timeout": 5,
        "config": {
          "patterns": [
            { "pattern": "sk-[A-Za-z0-9]{20,}", "description": "OpenAI API key" },
            { "pattern": "AKIA[0-9A-Z]{16}", "description": "AWS access key" }
          ]
        }
      },
      {
        "id": 2,
        "provider_name": "azure",
        "policy_name": "content-safety",
        "enabled": true,
        "timeout": 10,
        "config": {
          "endpoint": "env.AZURE_CONTENT_SAFETY_ENDPOINT",
          "api_key": "env.AZURE_CONTENT_SAFETY_KEY",
          "analyze_enabled": true,
          "analyze_severity_threshold": "medium",
          "jailbreak_shield_enabled": true,
          "indirect_attack_shield_enabled": false
        }
      }
    ],
    "guardrail_rules": [
      {
        "id": 101,
        "name": "block-secrets-input",
        "description": "Block prompts leaking credentials",
        "enabled": true,
        "cel_expression": "true",
        "apply_to": "input",
        "sampling_rate": 100,
        "timeout": 10,
        "provider_config_ids": [1]
      },
      {
        "id": 102,
        "name": "content-safety-both",
        "description": "Azure content safety on all traffic",
        "enabled": true,
        "cel_expression": "true",
        "apply_to": "both",
        "sampling_rate": 100,
        "timeout": 15,
        "provider_config_ids": [2]
      }
    ]
  }
}