Skip to main content
This page lists the public classes, methods, and exceptions in the HiddenLayer Python SDK (hiddenlayer-sdk) version 3.10.0. It is built from the SDK’s api.md and its source code. Use it to look up a signature or return type. For explanations and complete examples, see Core concepts and API usage examples. For REST request and response field details, see the HiddenLayer developer portal.

How to read this page

  • Signatures show the synchronous client (HiddenLayer). The async client (AsyncHiddenLayer) has the same methods. Call them with await, and async paginated results support async for.
  • Arguments after * are keyword-only.
  • omit means “not sent”. If you do not pass the argument, the SDK leaves it out of the request.
  • Response types are importable from hiddenlayer.types (and subpackages such as hiddenlayer.types.scans).
  • Beta endpoints emit hiddenlayer.BetaWarning and can change without notice. Deprecated methods are marked with typing_extensions.deprecated and should not be used in new code.

Common request options

Every generated resource method also accepts these keyword-only arguments. They are omitted from the signatures below for readability. Values passed through these options take precedence over values set on the client or by the method. The high-level helpers (model_scanner, community_scanner, evaluation_sessions) do not accept these options. Every resource also exposes .with_raw_response and .with_streaming_response prefixes. See Raw and streaming responses.

Clients

Constructor

Base URL resolution order: base_url argument, then environment argument, then HIDDENLAYER_BASE_URL, then prod-us. The HIDDENLAYER_LOG environment variable (info or debug) controls logging.

Client methods and attributes

Module-level exports

Import these from the top-level hiddenlayer package.

Models

client.models.retrieve

GET /api/v2/models/{model_id}. Returns the model’s name, source, model_id, tenant_id, and versions.

client.models.delete

DELETE /api/v2/models/{model_id}. Deletes a model. This operation is irreversible.

client.models.cards.list

Deprecated
GET /models/v4/cards. Lists model cards with offset pagination. Deprecated in favor of GET /asset-inventory/v2/assets, which this SDK version does not expose.

Evaluations: red team

All client.evaluations.red_team methods are Beta. Most users should use the evaluation_sessions.red_team helper instead. Types are in hiddenlayer.types.evaluations.

client.evaluations.red_team.create

Beta
POST /evaluations/v1/red-team. Starts a red team workflow.

client.evaluations.red_team.retrieve_evaluation_results

Beta
GET /evaluations/v1/red-team/{workflow_id}. Returns the workflow’s results and report.

client.evaluations.red_team.retrieve_next_action

Beta
GET /evaluations/v1/red-team/{workflow_id}/next-action. Returns the next action, such as an attack prompt to send to your target.

client.evaluations.red_team.retrieve_status

Beta
GET /evaluations/v1/red-team/{workflow_id}/status. Returns the workflow status and progress.

client.evaluations.red_team.submit_target_response

Beta
POST /evaluations/v1/red-team/{workflow_id}/target-response. Submits your target model’s reply to an attack prompt.

client.evaluations.red_team.terminate

Beta
POST /evaluations/v1/jobs/{workflow_id}/termination. Stops a running workflow. This cannot be undone.

Evaluation sessions: red team

Beta (wraps the Beta evaluations.red_team endpoints) High-level session management, accessed through client.evaluation_sessions.red_team. The classes are importable as from hiddenlayer.lib import EvaluationSessionsResource, AsyncEvaluationSessionsResource. See Attack simulation for a walkthrough.

start_session

Starts a red team workflow and returns a session object. execution_strategy_type must be "single", "random", or "static_prompt_set". Any other value raises ValueError. "static_prompt_set" requires prompt_set_id.

resume_session

Reconnects to an existing workflow by ID.

terminate_session

Stops a running workflow. This cannot be undone.

Session objects

RedTeamSession (sync) and AsyncRedTeamSession (async) are returned by start_session() and resume_session().

Prompt Analyzer

client.prompt_analyzer.create

POST /api/v1/submit/prompt-analyzer. Analyzes a prompt and optional model output. The response includes verdict, categories, results, policy, frameworks, model, provider, and elapsed_ms. hl_project_id is sent as the HL-Project-Id header.

Interactions

client.interactions.analyze

POST /detection/v1/interactions. Analyzes LLM input and output with AI Runtime Security. metadata requires model and requester_id, and accepts an optional provider. input and output take {"messages": [{"role": "...", "content": "..."}]}. The response includes analysis, analyzed_data, metadata, modified_data, and an optional evaluation (action, has_detections, threat_level). See Runtime security.

Runtime

All client.runtime methods emit BetaWarning in version 3.10.0.

client.runtime.evaluate_interaction

Beta
POST /detection/v2/interaction-evaluations. Evaluates a full agentic interaction. metadata requires model, provider, and requester_id, and accepts an optional external_session_id. The response includes outcome (action, threat_level, detections, effective_interaction), evaluated_interaction, and metadata.

client.runtime.evaluate_request

Beta
POST /detection/v2/request-evaluations. Evaluates a provider-native request payload before you send it to the model. Read the hl-runtime-action response header with with_raw_response to detect a block.

client.runtime.evaluate_response

Beta
POST /detection/v2/response-evaluations. Evaluates a provider-native model response before you return it to the user.

Sensors

Deprecated. The SDK docstring states each sensors endpoint “will be removed after April 13, 2026”. Do not use these methods in new code.

Scans: results

Types are in hiddenlayer.types.scans.

client.scans.results.list_files

GET /scan/v3/results/{scan_id}/files. Returns per-file results with cursor pagination. Iterate the result to fetch all pages automatically, or use .items, .has_next_page(), .get_next_page(), and .next_page_info(). has_detections=True returns only files with detections.

client.scans.results.retrieve_summary

GET /scan/v3/results/{scan_id}/summary. Returns status, inventory, summary counts, compliance, and intelligence for a scan, without per-file results.

client.scans.results.sarif

GET /scan/v3/results/{scan_id}/sarif. Returns the scan results as a SARIF JSON string.

Scans: jobs

client.scans.jobs.retrieve

GET /scan/v3/results/{scan_id}. Returns the full scan report, including file_results. has_detections=True filters file_results to files with detections (and their parents).

client.scans.jobs.list

GET /scan/v3/results. Lists scans. Not auto-paginated: the response has items, limit, offset, and total. Page by changing offset.

client.scans.jobs.request

POST /scan/v3/jobs. Requests a scan of a model at a remote location. inventory requires model_name, model_version, and requesting_entity. client.community_scanner.community_scan() wraps this method.

Scans: upload

These methods implement the multipart upload used by client.model_scanner. Most users should call the model scanner instead.

client.scans.upload.start

POST /scan/v3/upload. Starts an upload session for a scan.

client.scans.upload.complete_all

PATCH /scan/v3/upload/{scan_id}. Marks all files as uploaded so scanning can begin.

client.scans.upload.file.add

POST /scan/v3/upload/{scan_id}/file. Registers a file in the upload session. Types are in hiddenlayer.types.scans.upload.

client.scans.upload.file.complete

PATCH /scan/v3/upload/{scan_id}/file/{file_id}. Marks one file as fully uploaded.

Model scanner

High-level helper accessed through client.model_scanner (ModelScanner or AsyncModelScanner). Every method returns a ScanReport (from hiddenlayer.types.scans import ScanReport). See Model scanning.
request_source accepts "Hybrid Upload", "API Upload", "Integration", or "UI Upload". With wait_for_results=True, the helper polls until the scan status is done, failed, or canceled, with no overall time limit. A failed scan is returned, not raised, so check report.status.

Community scanner

High-level helper accessed through client.community_scanner (CommunityScanner or AsyncCommunityScanner). HiddenLayer fetches the model from the remote location, so nothing is downloaded to your machine.
community_scan raises ValueError("scan_id must have a value") if the API does not return a scan ID.

CommunityScanSource

For HUGGING_FACE, model_path is the repository ID, for example "drhyrum/bert-tiny-torch-vuln".

Exceptions

All exceptions are importable from hiddenlayer, for example from hiddenlayer import NotFoundError. See Error handling for patterns.
APIStatusError and its subclasses expose status_code, response (the httpx.Response), body, and message. For APIConnectionError, the underlying httpx exception is available as e.__cause__.

Red team exceptions

These exceptions do not inherit from hiddenlayer.HiddenLayerError.
The session helpers map 404 and 400 errors by catching httpx.HTTPStatusError, but the SDK client raises hiddenlayer.APIStatusError subclasses. In practice you may receive hiddenlayer.NotFoundError or hiddenlayer.BadRequestError instead of WorkflowNotFoundError or InvalidSessionError. This needs confirmation. Catch both RedTeamSessionError and hiddenlayer.APIStatusError. Also, when poll_max_wait is exceeded, the helper raises a plain Exception (“Polling timed out after …”), not PollTimeoutError.

Differences from api.md

The SDK’s api.md differs from the source code in a few places. This page follows the source code (version 3.10.0):
  • api.md lists the prod-us base URL as https://api.hiddenlayer.ai and the base URL environment variable as HIDDEN_LAYER_BASE_URL. The source uses https://api.us.hiddenlayer.ai and HIDDENLAYER_BASE_URL.
  • api.md omits model_scanner.scan_azure_blob_model and model_scanner.scan_huggingface_model.
  • api.md omits CommunityScanSource.GOOGLE_SIGNED.
  • The SDK README’s error table omits ConflictError (409).
  • The 3.9.0 changelog mentions removing the Beta label from runtime v2 endpoints and exposing a v2 AI Asset Inventory API. In 3.10.0, the runtime v2 endpoints still emit BetaWarning, and no asset inventory resource exists on the client. Both need confirmation.