hiddenlayer-sdk package from PyPI into a virtual environment, add optional packages, and confirm that the installation works.
Before you start, check the Prerequisites.
Create a virtual environment
A virtual environment is an isolated Python installation for one project. Use one because:- The SDK’s dependencies, such as
httpxandpydantic, do not conflict with other projects. - You can pin exact versions per project and reproduce them on other machines.
- You do not need administrator rights to install packages.
- macOS/Linux
- Windows
(.venv). Inside an active environment, python and pip refer to the environment’s interpreter on every operating system.
Activate the environment in every new terminal session before you run your code. To leave the environment, run
deactivate.Upgrade pip
Olderpip versions can fail to resolve recent packages. Upgrade pip inside the environment:
Install the SDK
Install the package:hiddenlayer-sdk, but you import it in Python as hiddenlayer.
Install optional packages
Install these only if you use the related feature.aiohttp backend for the async client
By default, the async client useshttpx. For better concurrency, you can use aiohttp as the HTTP backend. Install the aiohttp extra:
no matches found.
To use the backend, pass http_client=DefaultAioHttpClient() to AsyncHiddenLayer. See Authentication and configuration.
Cloud and Hugging Face model scanning helpers
Some model scanning helpers download models with third-party libraries. These are not SDK extras, so install them separately:
If a package is missing when you call the helper, the SDK raises an
ImportError, for example Python package boto3 is not installed.
Loading credentials from a .env file
The SDK reads environment variables but does not load.env files itself. To load them from a file during local development, install python-dotenv:
Verify the installation
Print the installed SDK version:pip:
Pin versions
Pin the SDK version so that every developer and every deployment uses the same code. Add a line to yourrequirements.txt file:
requirements.txt
requirements.txt
The SDK generally follows semantic versioning, but some backwards-incompatible changes can ship in minor releases, and beta APIs are excluded from versioning guarantees. An exact pin is the safest choice for production. See Version compatibility and upgrades.
Upgrade or uninstall
Upgrade to the latest release:Common installation errors
pip installs the package, but Python still cannot import it
pip installs the package, but Python still cannot import it
On machines with several Python installations, the The path should point inside your
pip command can belong to a different interpreter than python. Always install with python -m pip ... so that pip runs under the same interpreter as your code.To see which interpreter you are using, run:.venv folder.
