This guide explains how to integrate Azure Content Safety Guardrail with TrueFoundry to enhance the safety and compliance of your LLM applications.

How to setup Azure Content Safety on Azure

1

Sign in to Azure Portal

Navigate to Azure Portal and sign in with your Azure credentials.
2

Create a New Content Safety Resource

Select Create a resource in the top left corner of the Azure Portal.
3

Select Content Safety Resource Type

Choose Azure AI Content Safety from the list of resources, then select Create.
4

Configure Content Safety Resource Details

  • Subscription: Choose your Azure subscription.
  • Resource group: Select an existing resource group or create a new one.
  • Instance details:
    • Region: Select the region (e.g., East US) where you want your resource to be hosted.
    • Name: Enter a unique name for your Content Safety resource.
    • Pricing tier: Choose the appropriate pricing tier for your needs.
5

Create the Resource

Select Create to provision your Azure Content Safety resource. The creation process may take several minutes.
6

Locate API Key and Endpoint

Once your resource is created, navigate to the Overview section in the Azure Portal. Here, you will see the Manage Keys and Resource Name displayed, it will be used later when configuring the integration in TrueFoundry.
Azure Portal showing Content Safety resource overview with Manage Keys and Resource Name highlighted

Locate API Key and Endpoint

Adding Azure Content Safety Guardrail Integration

To add Azure Content Safety Guardrail to your TrueFoundry setup, follow these steps: Fill in the Guardrails Group Form
  • Name: Enter a name for your guardrails group.
  • Collaborators: Add collaborators who will have access to this group.
  • Azure Content Safety Guardrail Config:
    • Name: Enter a name for the Azure Content Safety Guardrail configuration.
    • Resource Name: The unique name of your Azure resource (e.g., the Azure Cognitive Services or Azure AI resource) that provides the content safety capability. You can find this in the Azure portal under the resource’s overview page. This is required to authenticate and route requests to the correct Azure service instance.
    • API Version: The version of the Azure Content Safety API to use. (Default: 2024-09-01)
    • Blocklist Name (Optional): The name of the blocklist to use.
    • Severity: The severity threshold to use for blocking content. (Default: 2)
    • Categories: The categories of content to check against.
  • Azure Authentication Data:
    • API Key: The API key for the Azure Content Safety Guardrail service.
      This key is required to authenticate requests to Azure’s Content Safety Guardrail API. You can obtain it from the Azure portal by navigating to your Cognitive Services or Azure AI resource, then selecting “Keys and Endpoint” in the resource menu. Ensure you keep this key secure, as it grants access to your Azure resource.
TrueFoundry interface for configuring Azure Content Safety Guardrail with fields for name, resource name, API version, severity threshold, and categories

Fill in the Azure Content Safety Guardrail Form

How Azure Content Safety Guardrail Works

When you integrate Azure Content Safety Guardrail with TrueFoundry, the system sends the last message to the Azure Content Safety Guardrail API and receives a response that indicates whether the content violates any configured policies.

Response Structure

The Azure Content Safety Guardrail API returns a response with the following structure:

Validation Logic

TrueFoundry relies on the Azure Content Safety Guardrail response to determine content safety:
  • TrueFoundry uses a configurable severity threshold to determine if content should be blocked.
  • If any category in the Azure Content Safety Guardrail response has a severity equal to or greater than the configured threshold, the content will be blocked.
  • If all detected severities are below the threshold, the content will be passed through as is.
  • TrueFoundry AI Gateway will respond with an error or block the content if the severity threshold is met or exceeded.