Skip to main content
The HiddenLayer Python SDK is the official Python library for the HiddenLayer REST API. It lets you call HiddenLayer services from scripts, CI/CD pipelines, and applications without writing raw HTTP requests or handling authentication tokens yourself.
  • If you are familiar with SDKs and want to get started right away, see the Quickstart Guide.
  • For a more thorough walk-through (including Installation and Common Workflows), read the rest of this Overview page, then continue with the Prerequisities and read the rest of the Python SDK guide. You can skip the Quickstart section.
The SDK provides:
  • A synchronous client and an asynchronous client. Use HiddenLayer in regular Python code. Use AsyncHiddenLayer with asyncio. Both clients accept the same configuration options and expose the same methods.
  • Typed requests and responses. Request parameters are defined as TypedDict types (typed Python dictionaries), so editors can autocomplete and check them. Responses are Pydantic models (Python objects with validated, typed fields), so you access results as attributes such as response.evaluation.action.
  • Built-in authentication, retries, and timeouts. The client exchanges your client ID and client secret for an access token, refreshes it when it expires, and retries failed requests that are safe to retry.
  • Helpers for common workflows. Higher-level helpers handle multi-step tasks, such as uploading and scanning a model folder or driving a red team session.

Services covered

You can use the SDK with the following HiddenLayer services:
Active developmentThis project is under active development. Some endpoints are marked Beta. Beta APIs have no compatibility guarantees and may change at any time, and they are not considered when the SDK determines its semantic version. When you call a beta endpoint, the SDK emits a hiddenlayer.BetaWarning. For details, see the Beta API FAQ on the Developer Portal.

A first look

Every API call follows the same pattern: create a client, then call a method on a resource attribute.
To run this code, follow the Quickstart. It walks you through installation, credentials, and error handling.

How this guide is organized

Get started

Quickstart

Make your first API call in a few minutes.

Prerequisites

What you need before you install the SDK.

Installation

Create a virtual environment and install the package.

Authentication and configuration

Provide credentials, choose a region, and configure the client.

Core concepts

Clients, resources, request types, and response models.

Workflows

Scan models

Scan local, Hugging Face, S3, and Azure models with AI Supply Chain Security.

Runtime security

Analyze LLM interactions and use the agentic evaluation endpoints.

Attack simulation

Run red team sessions against your AI application.

API usage examples

Low-level resources, pagination, raw responses, and more.

Reference

Error handling

Exception types, retries, and timeouts.

Troubleshooting

Fixes for common problems.

Security and production guidance

Handle credentials and data safely in production.

Version compatibility and upgrades

Versioning policy, pinning, and upgrading.

Python API reference

Clients, resources, methods, and types.

Additional resources

  • hiddenlayer-sdk on PyPI: release history and package metadata.
  • GitHub repository: source code, README, changelog, and the examples directory (including demo.py for model scanning and red_team/ notebooks for AI Attack Simulation).
  • api.md: the generated list of every resource, method, and type in the SDK.
  • HiddenLayer Developer Portal: REST API reference for the endpoints the SDK calls.