> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hiddenlayer.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install the HiddenLayer SDK for Python, TypeScript, or Java, add optional packages, and verify the installation.

This page shows you how to add the HiddenLayer SDK to a Python, Node.js, or Java project, install optional packages, and confirm that the installation works.

Before you start, check the [Prerequisites](https://docs.hiddenlayer.ai/docs/integrations/sdk/prerequisites.md).

## Set up a project

> [tab] Python
>
> Install the Python SDK into a virtual environment. A virtual environment is an isolated Python installation for one project. Use one because:
>
> * The SDK's dependencies, such as `httpx` and `pydantic`, 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.
>
> Create and activate a virtual environment in your project folder:
>
> > [tab] macOS/Linux
> >
> > ```bash theme={null}
> > mkdir hiddenlayer-project
> > cd hiddenlayer-project
> > python3 -m venv .venv
> > source .venv/bin/activate
> > ```
>
> > [tab] Windows
> >
> > ```powershell theme={null}
> > mkdir hiddenlayer-project
> > cd hiddenlayer-project
> > py -m venv .venv
> > .venv\Scripts\Activate.ps1
> > ```
> >
> > If PowerShell blocks the activation script with an execution policy error, allow local scripts for your user and try again:
> >
> > ```powershell theme={null}
> > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
> > ```
>
> When the environment is active, your shell prompt usually starts with `(.venv)`. Inside an active environment, `python` and `pip` refer to the environment's interpreter on every operating system.
>
> > [!NOTE]
> >
> > Activate the environment in every new terminal session before you run your code. To leave the environment, run `deactivate`.
>
> Older `pip` versions can fail to resolve recent packages. Upgrade `pip` inside the environment:
>
> ```bash theme={null}
> python -m pip install --upgrade pip
> ```

> [tab] TypeScript
>
> Create a Node.js project, or use an existing one:
>
> ```bash theme={null}
> mkdir hiddenlayer-project
> cd hiddenlayer-project
> npm init -y
> ```
>
> The examples in this guide are ES modules that use top-level `await`. Save them with the `.mts` extension, or set `"type": "module"` in your `package.json` file.

> [tab] Java
>
> Use an existing Gradle or Maven project, or create one. For example, `gradle init --type java-application` creates a Gradle project with an `app` module.
>
> The SDK is published to Maven Central, so your build must list Maven Central as a repository. Gradle projects declare it with `repositories { mavenCentral() }`, and Maven uses it by default.

## Install the SDK

> [tab] Python
>
> ```bash theme={null}
> python -m pip install hiddenlayer-sdk
> ```
>
> The PyPI package name is `hiddenlayer-sdk`, but you import it in Python as `hiddenlayer`.
>
> > [!TIP]
> >
> > Running `python -m pip` instead of `pip` guarantees that the package is installed for the same interpreter that runs your code.

> [tab] TypeScript
>
> ```bash theme={null}
> npm install @hiddenlayerai/hiddenlayer-sdk
> ```
>
> Import the client in an ES module:
>
> ```typescript theme={null}
> import { HiddenLayer } from "@hiddenlayerai/hiddenlayer-sdk";
> ```
>
> Or in a CommonJS module:
>
> ```javascript theme={null}
> const { HiddenLayer } = require("@hiddenlayerai/hiddenlayer-sdk");
> ```
>
> The package includes its own TypeScript type definitions, so you do not need a separate `@types` package.

> [tab] Java
>
> Add the dependency to your build file. The SDK is a single artifact, `com.hiddenlayer.api:hiddenlayer-java`.
>
> ```kotlin Gradle (Kotlin) theme={null}
> dependencies {
>     implementation("com.hiddenlayer.api:hiddenlayer-java:6.0.0")
> }
> ```
>
> ```groovy Gradle (Groovy) theme={null}
> dependencies {
>     implementation 'com.hiddenlayer.api:hiddenlayer-java:6.0.0'
> }
> ```
>
> ```xml Maven theme={null}
> <dependency>
>   <groupId>com.hiddenlayer.api</groupId>
>   <artifactId>hiddenlayer-java</artifactId>
>   <version>6.0.0</version>
> </dependency>
> ```
>
> The artifact brings OkHttp 5 and Jackson 2.18 with it. All the SDK's classes are in the `com.hiddenlayer.api` package and its subpackages.

## Install optional packages

Install these only if you use the related feature.

### Asynchronous HTTP backend

> [tab] Python
>
> By default, `AsyncHiddenLayer` sends requests with `httpx`. To send them with `aiohttp` instead, install the `aiohttp` extra:
>
> ```bash theme={null}
> python -m pip install "hiddenlayer-sdk[aiohttp]"
> ```
>
> Keep the quotes. Some shells, such as zsh (the default on macOS), treat square brackets as a filename pattern and fail with `no matches found`.
>
> With the extra installed, `AsyncHiddenLayer` uses `aiohttp` automatically. You do not need to change your code. If your program then prints aiohttp's `Unclosed connector` warning when it exits, close the client's connections as shown in [Authentication and configuration](https://docs.hiddenlayer.ai/docs/integrations/sdk/authentication.md#async-client).

> [tab] TypeScript
>
> Not needed. The TypeScript client is asynchronous and uses the `fetch` function built into Node.js.

> [tab] Java
>
> Not needed. `AsyncHiddenLayerClient` is part of the `hiddenlayer-java` artifact.

### Cloud and Hugging Face model scanning helpers

Some model scanning helpers download models with third-party libraries. The SDK does not install them, so install the ones for the scans you run:

> [tab] Python
>
> | Helper | Install command |
> | - | - |
> | `client.model_scanner.scan_huggingface_model` | `python -m pip install huggingface_hub` |
> | `client.model_scanner.scan_s3_model` | `python -m pip install boto3` |
> | `client.model_scanner.scan_azure_blob_model` | `python -m pip install azure-identity azure-storage-blob` |
>
> If a package is missing when you call the helper, the SDK raises an `ImportError`, for example `Python package boto3 is not installed.`

> [tab] TypeScript
>
> | Helper | Install command |
> | - | - |
> | `client.modelScanner.scanHuggingFaceModel` | `npm install @huggingface/hub` |
> | `client.modelScanner.scanS3Model` | `npm install @aws-sdk/client-s3` |
> | `client.modelScanner.scanAzureBlobModel` | `npm install @azure/storage-blob`, plus `npm install @azure/identity` to authenticate with Microsoft Entra ID |
>
> These packages are optional peer dependencies of the SDK, so npm does not install them for you. Each one is loaded only by the scan that needs it. If a package is missing when you call the helper, the scan fails with an error that names the package, for example `This scan needs @aws-sdk/client-s3: install it beside @hiddenlayerai/hiddenlayer-sdk.`

> [tab] Java
>
> The Java SDK has no download helpers for Hugging Face, AWS S3, or Azure Blob Storage. Download the model with your provider's Java SDK, then scan the local copy with `scanFile` or `scanFolder`, or scan a remote model with the community scanner. See [Scan models](https://docs.hiddenlayer.ai/docs/integrations/sdk/model_scanning.md).

### Loading credentials from a .env file

The SDKs read environment variables but do not load `.env` files themselves.

> [tab] Python
>
> To load a `.env` file during local development, install `python-dotenv`:
>
> ```bash theme={null}
> python -m pip install python-dotenv
> ```

> [tab] TypeScript
>
> No package is needed. Node.js loads a `.env` file with its `--env-file` option, for example `node --env-file=.env app.mts`. Node.js runs TypeScript files directly from version 22.18. On an earlier Node.js 22 release, run `npx tsx --env-file=.env app.mts` instead.

> [tab] Java
>
> Set the variables in your shell or in your IDE's run configuration. To read them from a file with a library instead, pass the values to the client builder explicitly.

See [Authentication and configuration](https://docs.hiddenlayer.ai/docs/integrations/sdk/authentication.md#optional-use-a-env-file) for usage.

## Verify the installation

> [tab] Python
>
> Print the installed SDK version:
>
> ```bash theme={null}
> python -c "import hiddenlayer; print(hiddenlayer.__version__)"
> ```
>
> The output is a version number, for example:
>
> ```text theme={null}
> 6.0.0
> ```
>
> You can also check package details with `pip`:
>
> ```bash theme={null}
> python -m pip show hiddenlayer-sdk
> ```

> [tab] TypeScript
>
> List the installed SDK version:
>
> ```bash theme={null}
> npm ls @hiddenlayerai/hiddenlayer-sdk
> ```
>
> The output names the package and its version, for example:
>
> ```text theme={null}
> hiddenlayer-project@1.0.0 /home/user/hiddenlayer-project
> └── @hiddenlayerai/hiddenlayer-sdk@5.0.0
> ```

> [tab] Java
>
> List the resolved dependency with your build tool:
>
> ```bash Gradle theme={null}
> gradle dependencies --configuration runtimeClasspath
> ```
>
> ```bash Maven theme={null}
> mvn dependency:tree -Dincludes=com.hiddenlayer.api
> ```
>
> The output includes the SDK and its version, for example:
>
> ```text theme={null}
> \--- com.hiddenlayer.api:hiddenlayer-java:6.0.0
>      +--- com.squareup.okhttp3:okhttp:5.2.1
> ```
>
> In a multi-module Gradle project, run the task for the module that uses the SDK, for example `gradle :app:dependencies --configuration runtimeClasspath`.

Installation does not contact HiddenLayer or check your credentials. To confirm that you can reach the API, complete the [Quickstart](https://docs.hiddenlayer.ai/docs/integrations/sdk/quickstart.md).

## Pin versions

Pin the SDK version so that every developer and every deployment uses the same code.

> [tab] Python
>
> Add a line to your `requirements.txt` file:
>
> ```text requirements.txt theme={null}
> hiddenlayer-sdk==6.0.0
> ```
>
> Or allow compatible minor and patch updates within the same major version:
>
> ```text requirements.txt theme={null}
> hiddenlayer-sdk>=5.0,<6
> ```
>
> Install from the file:
>
> ```bash theme={null}
> python -m pip install -r requirements.txt
> ```

> [tab] TypeScript
>
> `npm install` records a caret range, such as `^5.0.0`, in `package.json`, which allows minor and patch updates within major version 5. To pin an exact version, install with `--save-exact`:
>
> ```bash theme={null}
> npm install --save-exact @hiddenlayerai/hiddenlayer-sdk@5.0.0
> ```
>
> Commit your lock file (`package-lock.json`) so that every install resolves the same versions, and use `npm ci` in CI/CD pipelines.

> [tab] Java
>
> Gradle and Maven use the exact version you declare, such as `6.0.0`. Change the version in your build file when you upgrade.

> [!NOTE]
>
> The SDKs follow semantic versioning, but beta APIs are excluded from the versioning guarantees. An exact pin is the safest choice for production. See [Version compatibility and upgrades](https://docs.hiddenlayer.ai/docs/integrations/sdk/versioning.md).

## Upgrade or uninstall

> [tab] Python
>
> Upgrade to the latest release:
>
> ```bash theme={null}
> python -m pip install --upgrade hiddenlayer-sdk
> ```
>
> Uninstall the SDK:
>
> ```bash theme={null}
> python -m pip uninstall hiddenlayer-sdk
> ```

> [tab] TypeScript
>
> Upgrade to the latest release:
>
> ```bash theme={null}
> npm install @hiddenlayerai/hiddenlayer-sdk@latest
> ```
>
> Uninstall the SDK:
>
> ```bash theme={null}
> npm uninstall @hiddenlayerai/hiddenlayer-sdk
> ```

> [tab] Java
>
> To upgrade, change the version in your build file and rebuild. To uninstall, remove the dependency from your build file.

Before upgrading, review the changelog in the SDK's GitHub repository ([Python](https://github.com/hiddenlayerai/hiddenlayer-sdk-python/blob/main/CHANGELOG.md), [TypeScript](https://github.com/hiddenlayerai/hiddenlayer-sdk-typescript/blob/main/CHANGELOG.md), [Java](https://github.com/hiddenlayerai/hiddenlayer-sdk-java/blob/main/CHANGELOG.md)). When you move to a new major version, follow the upgrade notes in [Version compatibility and upgrades](https://docs.hiddenlayer.ai/docs/integrations/sdk/versioning.md#upgrade-notes).

## Common installation errors

> [tab] Python
>
> > [accordion] ModuleNotFoundError: No module named 'hiddenlayer'
> >
> > Python cannot find the SDK in the interpreter that runs your code. Usually this means the virtual environment is not active, or the SDK was installed into a different environment.
> >
> > To fix it:
> >
> > 1. Activate the project's virtual environment (see [Set up a project](#set-up-a-project)).
> > 2. Run `python -m pip show hiddenlayer-sdk`. If nothing is shown, install the SDK again with `python -m pip install hiddenlayer-sdk`.
> > 3. In an IDE such as VS Code or PyCharm, select the `.venv` interpreter for the project.
> >
> > Also confirm that you import `hiddenlayer`, not `hiddenlayer_sdk`.
>
> > [accordion] pip installs the package, but Python still cannot import it
> >
> > On machines with several Python installations, the `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:
> >
> > ```bash theme={null}
> > python -c "import sys; print(sys.executable)"
> > ```
> >
> > The path should point inside your `.venv` folder.
>
> > [accordion] pip installs version 3.10.0 instead of 6.x
> >
> > Your environment runs Python 3.9. Versions 4 and later require Python 3.10 or later, so `pip` installs 3.10.0, the last release that supports Python 3.9. The examples in this guide do not work with 3.10.0. Create the virtual environment with Python 3.10 or later and install again.
>
> > [accordion] zsh: no matches found: hiddenlayer-sdk\[aiohttp]
> >
> > zsh interprets the square brackets as a filename pattern. Put the package specifier in quotes:
> >
> > ```bash theme={null}
> > python -m pip install "hiddenlayer-sdk[aiohttp]"
> > ```
>
> > [accordion] ERROR: Could not find a version that satisfies the requirement hiddenlayer-sdk
> >
> > `pip` cannot reach PyPI, or your package mirror does not carry the SDK. Upgrade `pip` and confirm that your network or package mirror allows access to PyPI.

> [tab] TypeScript
>
> > [accordion] npm warn EBADENGINE Unsupported engine
> >
> > Your Node.js version is older than 22. npm installs the package but warns that the SDK requires `node >= 22.0.0`, and the SDK may fail at run time. Upgrade Node.js to version 22 or later, then reinstall your dependencies.
>
> > [accordion] Error \[ERR\_MODULE\_NOT\_FOUND]: Cannot find package '@hiddenlayerai/hiddenlayer-sdk'
> >
> > The package is not installed in the project that runs your code. Run `npm ls @hiddenlayerai/hiddenlayer-sdk` in the project folder. If the package is missing, install it with `npm install @hiddenlayerai/hiddenlayer-sdk`.
>
> > [accordion] TypeError: HiddenLayer is not a constructor
> >
> > In CommonJS, `require` returns the package's exports object, not the client class. Destructure the class:
> >
> > ```javascript theme={null}
> > const { HiddenLayer } = require("@hiddenlayerai/hiddenlayer-sdk");
> > ```
>
> > [accordion] This scan needs @aws-sdk/client-s3 (or another package)
> >
> > The cloud and Hugging Face scans load optional peer dependencies that npm does not install with the SDK. Install the package that the error names. See [Cloud and Hugging Face model scanning helpers](#cloud-and-hugging-face-model-scanning-helpers).

> [tab] Java
>
> > [accordion] Duplicate classes, or NoSuchMethodError, after upgrading from 2.x
> >
> > Since version 3.0.0, the SDK is a single artifact. The `hiddenlayer-java-core` and `hiddenlayer-java-client-okhttp` artifacts from version 2.x are no longer published, and their classes are now in `hiddenlayer-java`. Remove any dependency on those two artifacts and keep only `com.hiddenlayer.api:hiddenlayer-java:6.0.0`.
>
> > [accordion] NoSuchMethodError or NoClassDefFoundError in okhttp3 or com.fasterxml.jackson
> >
> > Another dependency forces an older OkHttp or Jackson version than the SDK needs. The SDK requires OkHttp 5 and Jackson 2.18. Run `gradle dependencies` or `mvn dependency:tree` to find the conflicting version, then align your project on the versions the SDK uses.
>
> > [accordion] Could not find com.hiddenlayer.api:hiddenlayer-java:6.0.0
> >
> > Your build cannot reach Maven Central, or Maven Central is not listed as a repository. Add `mavenCentral()` to the `repositories` block in Gradle. If your organization uses a repository manager, confirm that it proxies Maven Central.
>
> > [accordion] package com.hiddenlayer.api.client does not exist
> >
> > Your code still uses the version 2.x packages. Since 3.0.0, the clients are `com.hiddenlayer.api.HiddenLayerClient` and `com.hiddenlayer.api.AsyncHiddenLayerClient`, built with `HiddenLayerClientBuilder` and `AsyncHiddenLayerClientBuilder`. See the [breaking-changes guide](https://github.com/hiddenlayerai/hiddenlayer-sdk-java/blob/main/docs/BREAKING_CHANGES_v3.0.0.md).

For other problems, see [Troubleshooting](https://docs.hiddenlayer.ai/docs/integrations/sdk/troubleshooting.md).

## Next step

> [card] [Authentication and configuration](https://docs.hiddenlayer.ai/docs/integrations/sdk/authentication.md)
>
> Provide your client ID and client secret, and choose your region.
