HiddenLayer SDK

raw JSON →
3.6.0 verified Mon Apr 27 auth: no python

The official Python library for the HiddenLayer API, providing access to AI security and model scanning services. Current version 3.6.0, released April 2026, with frequent updates aligned to API changes.

pip install hiddenlayer-sdk
error ModuleNotFoundError: No module named 'hiddenlayer_sdk'
cause The package is installed as 'hiddenlayer-sdk', but the import module is 'hiddenlayer' (not 'hiddenlayer_sdk').
fix
Use 'from hiddenlayer import HiddenLayer' instead of 'from hiddenlayer_sdk import HiddenLayer'.
error ImportError: cannot import name 'HiddenLayer' from 'hiddenlayer' (unknown location)
cause The package may not be installed, or you are running in an environment where it's not available.
fix
Run 'pip install hiddenlayer-sdk' to install the package.
error AttributeError: 'NoneType' object has no attribute 'get'
cause Environment variables HIDDENLAYER_API_KEY or HIDDENLAYER_BASE_URL are not set, causing client to fail.
fix
Set the environment variables before creating the client: HIDDENLAYER_API_KEY and HIDDENLAYER_BASE_URL.
breaking In v3.0.0, the import path changed from 'hiddenlayer_sdk' to 'hiddenlayer'. All existing code using 'from hiddenlayer_sdk import ...' will break.
fix Change imports to 'from hiddenlayer import ...'.
deprecated The 'HiddenLayerApiKey' environment variable is deprecated. Use 'HIDDENLAYER_API_KEY' instead.
fix Set 'HIDDENLAYER_API_KEY' environment variable.
gotcha The SDK requires Python >= 3.9. If using Python 3.8 or older, installation will fail.
fix Upgrade Python to 3.9 or later.
gotcha When using async client, ensure you use the correct async context manager. Forgetting to await client.close() may cause resource leaks.
fix Always use 'async with HiddenLayerAsync(...) as client:' or explicitly await client.close().

Initialize the client using environment variables for credentials, then make a sample API call.

import os
from hiddenlayer import HiddenLayer

client = HiddenLayer(
    api_key=os.environ.get('HIDDENLAYER_API_KEY', ''),
    base_url=os.environ.get('HIDDENLAYER_BASE_URL', 'https://api.hiddenlayer.ai'),
)

# Example: list models
models = client.models.list()
print(models)