Installation and setup
ImportError: Python package boto3 / huggingface_hub / azure-identity / azure-storage-blob is not installed
ImportError: Python package boto3 / huggingface_hub / azure-identity / azure-storage-blob is not installed
The installed version is older than expected, or a method is missing
The installed version is older than expected, or a method is missing
-
Print the version your code actually uses:
-
Upgrade with the same interpreter:
python -m pip install --upgrade hiddenlayer-sdk. -
Check for pins such as
hiddenlayer-sdk==...inrequirements.txtorpyproject.toml.
Configuration errors
ValueError: Unknown environment: ...
ValueError: Unknown environment: ...
environment argument has a value the SDK does not recognize.Fix: Use one of the supported values:base_url instead of environment.Authentication and permission errors
401 AuthenticationError
401 AuthenticationError
- Missing environment variables. The client constructs successfully without credentials. The error only appears when it sends a request without an
Authorizationheader. - Expired or deleted API key. API keys have an expiration set when they are created. Expired keys are removed from the Console.
- Credentials for the wrong region. An API key created in the US Console does not work against the EU API, and the reverse. The SDK requests its access token from the base URL you configured, so the credentials must belong to that region.
- Token request failed. If the SDK cannot exchange the client ID and client secret for an access token, it sends the request without a token, and the API returns 401.
- Bearer token expired. If you use
HIDDENLAYER_TOKEN, the SDK does not refresh the token for you. - Typos or extra whitespace in the client ID or client secret.
- Run the environment variable check to confirm that the variables are set in the process that runs your code.
- In the Console, confirm that the API key exists and has not expired. If needed, create a new API key.
- Confirm that the client’s environment (
prod-usorprod-eu) matches the region where you created the key. - If you use a bearer token, get a new one, or switch to a client ID and client secret so the SDK refreshes tokens automatically.
- Configure only one authentication method. If both are set, the client ID and client secret take precedence.
403 PermissionDeniedError
403 PermissionDeniedError
404 NotFoundError
404 NotFoundError
- The ID is wrong. Check for typos, and check that you passed the right kind of ID, for example a scan ID rather than a model ID.
- The resource exists in a different region. Resources created in
prod-usare not visible fromprod-eu. - The resource is not available yet. For example, scan results can take a moment to appear after you start a scan. With
wait_for_results=False, the scanning helpers make up to 5 attempts when they receive a 404 before raisingNotFoundError.
wait_for_results=True.Connection and rate limit errors
APIConnectionError: Connection error.
APIConnectionError: Connection error.
- No network access, or a DNS failure
- A corporate proxy or firewall is blocking outbound HTTPS traffic
- A typo in
base_urlorHIDDENLAYER_BASE_URL - A local AI Runtime Security container is not running or is listening on a different port
-
Print the underlying error, which explains the specific failure:
- Check that the printed base URL is correct.
- If you are behind a proxy, configure it on a custom HTTP client. See Security and production guidance.
-
If you use a local container, confirm that it is running and that
base_urluses the correct host and port.
APITimeoutError: Request timed out.
APITimeoutError: Request timed out.
429 RateLimitError
429 RateLimitError
retry-after header, and raises RateLimitError only after all retries fail.Fix:- Reduce request concurrency or volume.
- Increase
max_retriesso the SDK waits longer before giving up. - Avoid adding your own retry loop on top of the SDK’s retries, which can make rate limiting worse.
Model scanning issues
RuntimeError: Couldn't download model ...
RuntimeError: Couldn't download model ...
scan_s3_model or scan_azure_blob_model could not download the model before scanning it. Common reasons are a wrong bucket, key, container, or blob name, missing cloud credentials, or no write access to the local download directory.Fix:- Print
e.__cause__to see the original error fromboto3or the Azure SDK. - Confirm that the object exists and that your AWS or Azure credentials can read it.
scan_s3_modeluses the standard AWS credential chain by default.scan_azure_blob_modelusesDefaultAzureCredentialby default. - Confirm that the process can write to
/tmp.
A scan seems to hang
A scan seems to hang
wait_for_results=True (the default), the scanning helpers poll until the scan reaches done, failed, or canceled. There is no overall time limit, so a slow or stuck scan blocks your program. The timeout client setting applies only to individual HTTP requests.Fix:- For large models or CI pipelines, call the helper with
wait_for_results=False. Then check the scan later withclient.model_scanner.scan_result(scan_id=...). - To enforce your own limit, run the scan in a worker thread or process and stop waiting after a deadline.
The scan status is failed
The scan status is failed
ScanReport with status == "failed" instead of raising an exception.Fix: Inspect the report to find which files failed and why:Windows: errors writing to /tmp
Windows: errors writing to /tmp
scan_s3_model and scan_azure_blob_model always download to /tmp, and scan_huggingface_model uses /tmp by default. This path may not exist on Windows.Fix: For Hugging Face models, pass a Windows path with local_dir=. For S3 and Azure, download the file yourself and call client.model_scanner.scan_file(), or run the scan from WSL or a Linux container./tmp paths on Windows has not been verified and needs confirmation.Warnings in your output
BetaWarning: [BETA] ... This endpoint is not GA or Production ready
BetaWarning: [BETA] ... This endpoint is not GA or Production ready
client.runtime.evaluate_interaction or a red team method. The warning is informational. Your request still succeeded.Fix: Review what beta status means in Version compatibility and upgrades. If you accept the risk, hide the warning:DeprecationWarning when calling client.models.cards.list
DeprecationWarning when calling client.models.cards.list
client.models.cards.list() is deprecated in favor of the GET /asset-inventory/v2/assets API endpoint. Python can show a DeprecationWarning when you call it.Fix: The method still exists in version 3.10.0, but avoid building new code on it. The replacement asset inventory endpoint is not exposed as a method in this SDK version.Debug checklist
If your problem is not listed above, work through these steps. They collect the information support needs.Check the SDK version
Check environment variables
This script reports whether each variable the SDK reads is set, without printing secret values:HIDDENLAYER_CLIENT_ID and HIDDENLAYER_CLIENT_SECRET, or HIDDENLAYER_TOKEN. If you set HIDDENLAYER_BASE_URL, do not also pass environment= to the client.
Turn on debug logging
SetHIDDENLAYER_LOG to debug to log each request, retry, and response. Use info for less detail.
- macOS/Linux
- Windows
Inspect raw response headers
Response headers can explain what happened, for example whether a request was blocked or rate limited. Usewith_raw_response to access them:
Contact support
If you still need help, contact HiddenLayer through the Support Portal. Include:- The SDK version and Python version
- The environment (
prod-usorprod-eu) or base URL - The full exception type and message
- Relevant IDs, such as a scan ID or workflow ID
- Debug logs with secrets and sensitive data removed

