POST /detection/v2/interaction-evaluations). It needs no model files or other setup, so it is a quick way to confirm that your installation, credentials, and network access work. Select your language in any tab, and every example on the page switches to it.
Before you begin
You need:- A supported runtime: Python 3.10 or later, Node.js 22 or later, or Java 8 or later with Gradle.
- A HiddenLayer client ID and client secret with AI Runtime Security permissions: Interactions (Read, Write). See Create a Client Credential.
- Access to Agentic Runtime Security for your tenant. See Get started with Agentic Runtime Security.
- Your region:
prod-us(default) orprod-eu.
Make your first request
1
Create a project and install the SDK
- Python
- TypeScript
- Java
A virtual environment keeps the SDK and its dependencies isolated from other Python projects.
- macOS/Linux
- Windows
2
Set your credentials
The client reads your client ID and client secret from environment variables, so you never have to put them in code.Replace the placeholders with your values. If your client credential is in the EU region, change the region in the code in the next step from
- macOS/Linux
- Windows
prod-us to prod-eu (Environment.PROD_US to Environment.PROD_EU in Java). For a self-hosted deployment, pass your base URL in place of the region: a region set in code overrides HIDDENLAYER_BASE_URL. See Choose a region or base URL.These variables last only for the current terminal session. If you open a new terminal, set them again, or use a
.env file as described in Authentication and configuration.3
Create the quickstart program
- Python
- TypeScript
- Java
Create a file named The
quickstart.py in your project folder with this content:quickstart.py
try block catches the most common errors and prints a hint for each. ApiError is listed after UnauthorizedError and ForbiddenError because it is their parent class, so it catches any other HTTP error status. httpx.TransportError covers timeouts and connection failures.4
Run the program
- Python
- TypeScript
- Java
Expected result
The program prints the policy outcome, followed by one line per detection. With the default policy, the output looks like this example. The action, threat level, and detections depend on your project’s policy, so your values may differ.DETECT means the policy reported the detections without changing the interaction. If your project’s policy blocks or redacts prompt injection, the action is BLOCK or REDACT instead.
The default detection rules evaluate the most recent message in the interaction. To screen a prompt, send it as the last message, as this example does. If you add the model’s reply after the prompt, rules that check user input do not fire for it.
What the fields mean:
Python and TypeScript use these field names directly. Java reads them through getters, such as
getOutcome().getThreatLevel().
The response also includes outcome.effective_interaction (the interaction to forward, with any redactions applied), evaluated_interaction (the messages with per-message signals and findings), and metadata (such as evaluation_id and the project whose policy applied). For a description of the response, see Evaluation Endpoints.
What just happened
- The client read its configuration. The client read
HIDDENLAYER_CLIENT_IDandHIDDENLAYER_CLIENT_SECRETfrom the environment and set the base URL tohttps://api.us.hiddenlayer.aiforprod-us. - The client obtained an access token. Before sending the request, the SDK exchanged your client ID and client secret for an OAuth2 access token at
https://api.us.hiddenlayer.ai/oauth2/token. It caches this token and gets a new one before it expires, so you do not manage tokens yourself. - The client sent the request. It sent the metadata and the interaction to
POST /detection/v2/interaction-evaluations, with the token in theAuthorizationheader. If the request had failed with a temporary error, such as HTTP 429 or 5xx, the SDK would have retried up to two times. - The SDK parsed the response. The JSON response was converted into a typed
InteractionEvaluationResponse: a Pydantic model in Python, an interface in TypeScript, and a class in Java.
Optional: async version
Optional: async version
- Python
- TypeScript
- Java
If your application uses To close the client’s connections before your program exits, for example to avoid aiohttp’s
asyncio, use AsyncHiddenLayer. It takes the same arguments and reads the same environment variables. Await each call.quickstart_async.py
Unclosed connector warning, use async with AsyncHiddenLayer() as client: or call await client.aclose(). See Async client.If it fails
The SDK is not found
The SDK is not found
The SDK is not installed where your program runs.
- Python (
ModuleNotFoundError: No module named 'hiddenlayer'): the virtual environment is not active, or the SDK is installed in a different environment. Activate.venvand runpython -m pip install hiddenlayer-sdk. - TypeScript (
ERR_MODULE_NOT_FOUND: Cannot find package '@hiddenlayerai/hiddenlayer-sdk'): runnpm install @hiddenlayerai/hiddenlayer-sdkin the folder that containsquickstart.mts. - Java (
package com.hiddenlayer.api does not exist): check thatbuild.gradle.ktslistsmavenCentral()and thehiddenlayer-javadependency.
Authentication failed (401)
Authentication failed (401)
The client could not get a valid token. Check that the client ID and client secret are correct, and that the region in your code matches the region where the client credential was created. See Troubleshooting.
Permission denied (403)
Permission denied (403)
Your client credential is valid but lacks permission for AI Runtime Security, or Agentic Runtime Security is not enabled for your tenant. Create a client credential with Interactions (Read, Write) permissions. See Create a Client Credential. If the permissions are correct, contact your HiddenLayer account representative or Support to request access.
TypeScript: Unknown file extension '.mts'
TypeScript: Unknown file extension '.mts'
Your Node.js release cannot run TypeScript files directly. Upgrade to Node.js 22.18 or later, or run
npx tsx quickstart.mts.Next steps
Scan models
Scan model files for malicious code and vulnerabilities.
Runtime security
Protect LLM applications and agents with the evaluation endpoints.
Attack simulation
Run red team sessions against your AI application.
Core concepts
Understand clients, resources, and response types.

