Skip to main content
No Docker containers required, just a REST request to the HiddenLayer servers to test functionality and get familiar with the APIs.
Why start with Prompt Analyzer? Because it is independent of any attached LLM, and allows a new user to get a feel for what the HiddenLayer detections look like and how our APIs work, without the added complexity of needing to connect to an additional LLM on the backend.

Pre-Requisites

To follow this tutorial, you need:
  • HiddenLayer AI Runtime Security license
  • HiddenLayer ClientId and ClientSecret to generate an access token

Python Script

The following script shows you how to make a simple call to the HiddenLayer SaaS endpoint for the Prompt Analyzer. Copy the script, save it to your working drive, and replace any necessary variables with your values. Some notes on using this script and on the Prompt Analyzer SaaS:
  • Authentication and calling the endpoint are region-specific operations. You should set the region variable to eu if you are in the EU, or leave it blank if you are in the US.
  • You will need to either set your ClientID and ClientSecret as environment variables, or paste them into the script.
  • The script includes a block to configure a requester id, which is passed in through a header. This header is optional, but it is highly recommended to always include it and to use it effectively. This is because detections in the HiddenLayer Console are grouped together by the model name (configured in line 39 of the script) and the requester id. Properly configuring those 2 parameters ensures that all detections sent to the console via this SaaS endpoint will be grouped together in the detection summary screen.
  • When you use headers to configure the request, note that the Prompt Analyzer can be configured to block (e.g. unsafe input), but the block itself is not being performed, as the Prompt Analyzer does not handle the backend connection – it simply provides the information that something should be blocked. The actual block must be implemented in the downstream application code.
  • This script can also be run against a locally-running containerized instance of Runtime Security – simply change the URL in line 31 to the local URL for your container, e.g. http://localhost:8000.

Jupyter Notebook

This script can be used as a Jupyter Notebook, split into relevant cells.