Skip to main content
Interactions performs a detailed security analysis of the input and output of LLM interactions. The detections returned depend on the rules configured for the relevant Project — for example, prompt injection, personally identifiable information (PII), code, denial of service, guardrails, model refusals, and prompt language. The rest of this page shows how to call it via the Python SDK.
The HiddenLayer SaaS endpoint lets you exercise the API and detections without needing to deploy a container or wire up a backend LLM. The same script also works against a locally-running Runtime Security container — just point base_url at your container.
This content demonstrates using the HiddenLayer SDK and Python. There are other options.

Pre-Requisites

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

SDK Python

The following script shows you how to make a simple call to the HiddenLayer endpoint for Interactions. Copy the script, save it to your working drive, and replace any necessary variables with your values.
  1. Install the HiddenLayer SDK Python using PyPI. If you cannot use PyPI, you can download the SDK from the HiddenLayer SDK Python GitHub page.
  2. Create a Python file.

Notes

Some notes on using this script:
  • Authentication and calling the endpoint are region-specific operations. Set environment="prod-eu" if you are in the EU, or leave it as the default (prod-us) if you are in the US.
  • If there are multiple Python versions on your system, make sure you are using the version the HiddenLayer SDK is installed to.
  • This script can also be run against a locally-running containerized instance of Runtime Security — set base_url to your container’s URL, e.g. http://localhost:8000.

Response

The following is an example Interactions response.