- AI Supply Chain Security (model scanning)
- AI Runtime Security — Interactions (LLM input/output analysis)
- AI Runtime Security — Agentic evaluation endpoints
- AI Attack Simulation (red team evaluations)
Active DevelopmentThis project is under active development. The full API surface is documented in the SDK’s api.md.
Some endpoints are marked Beta; see the Beta API Guidelines on the Developer Portal.
Before You Begin
The following are required for using the HiddenLayer Python SDK:- Python 3.9+ (this should include pip)
- HiddenLayer API key and secret; see Create API Key
Install SDK
Install thehiddenlayer-sdk package with pip.
-
For the optional async
aiohttpHTTP backend: -
To scan models from Hugging Face, AWS S3, or Azure Blob Storage, install the platform packages separately as needed:
Usage Overview
The main client exposed by the SDK ishiddenlayer.HiddenLayer, which provides access to all HiddenLayer services exposed via API. An async equivalent (AsyncHiddenLayer) is also available with the same interface.
Authentication
To authenticate to HiddenLayer, generate a client ID and secret from the platform UI. See Create API Key. The SDK supports two authentication methods:- OAuth2 client credentials — set
HIDDENLAYER_CLIENT_IDandHIDDENLAYER_CLIENT_SECRET, or passclient_id/client_secretdirectly. - Bearer token — set
HIDDENLAYER_TOKEN, or passbearer_tokendirectly.
base_url when constructing the client, or set the HIDDENLAYER_BASE_URL environment variable.
Async Usage
An async client is available with the same interface as the synchronous client. ImportAsyncHiddenLayer and await each API call:
hiddenlayer-sdk[aiohttp] and pass http_client=DefaultAioHttpClient().
See the SDK README for details.
Data Models
The HiddenLayer Python SDK uses Pydantic to represent data for APIs, which makes the code more readable and type-safe and easier to work with. Request parameters use TypedDicts. Responses are Pydantic models underhiddenlayer.types, with helpers such as model.to_json() and model.to_dict().
Specific data models are organized under hiddenlayer.types. Each resource exposes its own request and response types — see the SDK’s api.md for the full inventory.
Example Usage
The HiddenLayer Python SDK comes with a number of examples demonstrating how to use the library for various common use-cases. These examples and more are located in theexamples directory of the GitHub repository (including demo.py for model scanning and red_team/ for Attack Simulation).
Initiate Client
Scanning Models
Scanning a model on disk
client.model_scanner.scan_folder(...).
Scanning a Hugging Face model
Requirespip install huggingface_hub.
Scanning from cloud storage
Runtime Security
Analyzing LLM Interactions
Useclient.interactions.analyze to send LLM input and output to the Interactions endpoint.
For a full walkthrough and an example response, see Getting Started with Interactions.
base_url="http://localhost:8000" (or your container’s URL) when constructing the client.
Agentic evaluation endpoints
Useclient.runtime.evaluate_request, client.runtime.evaluate_response, and client.runtime.evaluate_interaction for Agentic Runtime Security use cases. For a full walkthrough, see Get Started with Agentic Runtime Security.
AI Attack Simulation
Useclient.evaluation_sessions.red_team (high-level session helpers) or client.evaluations.red_team (low-level API) to drive red team evaluations. For a full walkthrough, see Configuring an Attack Simulation against an Application.

