> ## 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.

# API reference

> Cross-language reference for the HiddenLayer SDKs for Python, TypeScript, and Java: client options, exports, resource methods with HTTP endpoints and return types, high-level helpers, and exceptions.

This page maps the HiddenLayer SDKs side by side: Python (`hiddenlayer-sdk` 6.0.0), TypeScript (`@hiddenlayerai/hiddenlayer-sdk` 5.0.0), and Java (`com.hiddenlayer.api:hiddenlayer-java` 6.0.0). It covers the client, the module-level exports, the resources the workflow guides use, the high-level helpers, and the exceptions.

Use it to find a method's name in your language, the endpoint it calls, and what it returns. For explanations and complete examples, see [Core concepts](https://docs.hiddenlayer.ai/docs/integrations/sdk/core_concepts.md) and [API usage examples](https://docs.hiddenlayer.ai/docs/integrations/sdk/api_examples.md). For REST request and response field details, see the [HiddenLayer Developer Portal](https://dev.hiddenlayer.ai/).

## How to read this page

* **Language tabs.** Choose Python, TypeScript, or Java in any tab, and every tab on the page switches to it.
* **Resource sections.** Each one starts with a table of operations, the endpoint each calls, and what it returns, followed by the method calls in your language, in the same order.
* **Method names.** Python uses `snake_case` (`retrieve_summary`), TypeScript and Java use `camelCase` (`retrieveSummary`). Java reaches resources through accessor methods: `client.scans().results()`.
* **Arguments.** Python takes path parameters positionally and everything else as keyword arguments. TypeScript takes one request object whose fields keep the API's names, with path parameters and headers as fields (`{ scan_id }`, `"HL-Project-Id"`). Java takes path parameters as leading `String` arguments and the body and query fields in a request object built with a builder.
* **Types.** Request and response types are named after the API specification's schemas and have the same name in every language. Import them from `hiddenlayer` in Python, read them from the `HiddenLayerApi` namespace in TypeScript (a type that belongs to one resource is nested under it, such as `HiddenLayerApi.scans.StartUploadResponse`), and import them from `com.hiddenlayer.api.types` (or a resource's `requests` or `types` package) in Java.
* **Async clients.** Python's `AsyncHiddenLayer` and Java's `AsyncHiddenLayerClient` have the same methods as the synchronous clients. Python methods are coroutines; Java methods return a `CompletableFuture`. Every TypeScript method returns a promise.
* **Pages.** "Page of `T`" means a paginated return: `SyncPager` (Python; `AsyncPager` on the async client), `Page` (TypeScript), or `SyncPagingIterable` (Java). See [Pagination](https://docs.hiddenlayer.ai/docs/integrations/sdk/core_concepts.md#pagination).
* **Beta** endpoints can change without notice and emit a warning on first use. **Deprecated** endpoints should not be used in new code.

## Full method reference

The SDKs cover every public operation in the HiddenLayer API, many more than this page lists. Each SDK's repository has a reference with every method, its parameters, and an example:

| Language | Method reference | Upgrade guide |
| - | - | - |
| Python | [reference.md](https://github.com/hiddenlayerai/hiddenlayer-sdk-python/blob/main/reference.md) | [Breaking changes in 4.0.0](https://github.com/hiddenlayerai/hiddenlayer-sdk-python/blob/main/docs/BREAKING_CHANGES_v4.0.0.md) |
| TypeScript | [reference.md](https://github.com/hiddenlayerai/hiddenlayer-sdk-typescript/blob/main/reference.md) | [Breaking changes in 4.0.0](https://github.com/hiddenlayerai/hiddenlayer-sdk-typescript/blob/main/docs/BREAKING_CHANGES_v4.0.0.md) |
| Java | [reference.md](https://github.com/hiddenlayerai/hiddenlayer-sdk-java/blob/main/reference.md) | [Breaking changes in 3.0.0](https://github.com/hiddenlayerai/hiddenlayer-sdk-java/blob/main/docs/BREAKING_CHANGES_v3.0.0.md) |

## Clients

| | Python | TypeScript | Java |
| - | - | - | - |
| Client | `HiddenLayer` | `HiddenLayer` | `HiddenLayerClient` |
| Async client | `AsyncHiddenLayer` | Not needed: every method is async | `AsyncHiddenLayerClient` |
| How to build it | Call the constructor | Call the constructor | `new HiddenLayerClientBuilder()`, or `new AsyncHiddenLayerClientBuilder()` |
| Base client without the helpers | `BaseClient` | `HiddenLayerClient` | `BaseHiddenLayerClient` |

Use the clients in the first two rows. The base clients have no model or community scanner, do not read `HIDDENLAYER_TOKEN`, and emit no Beta warnings. In Java, `HiddenLayerClient.builder()` still compiles but is deprecated: it returns the base client.

### Constructor options

```python Python theme={null}
import os

from hiddenlayer import HiddenLayer, HiddenLayerEnvironment

client = HiddenLayer(
    client_id=os.environ["HIDDENLAYER_CLIENT_ID"],
    client_secret=os.environ["HIDDENLAYER_CLIENT_SECRET"],
    environment=HiddenLayerEnvironment.PROD_EU,
    headers={"X-Team": "ml-platform"},
    timeout=30.0,
    max_retries=3,
)
```

```typescript TypeScript theme={null}
import { HiddenLayer, HiddenLayerEnvironment } from "@hiddenlayerai/hiddenlayer-sdk";

const client = new HiddenLayer({
    clientId: process.env.HIDDENLAYER_CLIENT_ID,
    clientSecret: process.env.HIDDENLAYER_CLIENT_SECRET,
    environment: HiddenLayerEnvironment.ProdEu,
    headers: { "X-Team": "ml-platform" },
    timeoutInSeconds: 30,
    maxRetries: 3,
});
```

```java Java theme={null}
import com.hiddenlayer.api.HiddenLayerClient;
import com.hiddenlayer.api.HiddenLayerClientBuilder;
import com.hiddenlayer.api.core.Environment;

HiddenLayerClient client = new HiddenLayerClientBuilder()
    .clientId(System.getenv("HIDDENLAYER_CLIENT_ID"))
    .clientSecret(System.getenv("HIDDENLAYER_CLIENT_SECRET"))
    .environment(Environment.PROD_EU)
    .addHeader("X-Team", "ml-platform")
    .timeout(30)
    .maxRetries(3)
    .build();
```

> [tab] Python
>
> | Argument | Default | Description |
> | - | - | - |
> | `token` | `HIDDENLAYER_TOKEN` | An API key or access token, sent as a bearer token and never refreshed. Also takes a function that returns the token, called before each request. |
> | `async_token` | None | `AsyncHiddenLayer` only: an async function that returns the token. |
> | `client_id` | `HIDDENLAYER_CLIENT_ID` | Client ID, exchanged with the client secret for an access token. |
> | `client_secret` | `HIDDENLAYER_CLIENT_SECRET` | Client secret. |
> | `environment` | US region | `"prod-us"`, `"prod-eu"`, or a `HiddenLayerEnvironment` value. |
> | `base_url` | `HIDDENLAYER_BASE_URL` | Any base URL. Wins over `environment`. The variable is read only when neither is given. |
> | `headers` | None | Headers sent with every request. |
> | `timeout` | 60 | Request timeout in seconds, as a `float`. |
> | `max_retries` | 2 | Retries for retryable failures. `0` disables retries. |
> | `httpx_client` | SDK default | Your own `httpx.Client` (`httpx.AsyncClient` for the async client), for proxies, custom TLS, or shared connection pools. |
> | `logging` | Off | Log configuration. See [Logging](https://docs.hiddenlayer.ai/docs/integrations/sdk/core_concepts.md#logging). |
> | `follow_redirects` | `True` | Whether the client follows redirects. |

> [tab] TypeScript
>
> | Option | Default | Description |
> | - | - | - |
> | `token` | `HIDDENLAYER_TOKEN` | An API key or access token, sent as a bearer token and never refreshed. Also takes a function that returns the token, called before each request. |
> | `clientId` | `HIDDENLAYER_CLIENT_ID` | Client ID, exchanged with the client secret for an access token. |
> | `clientSecret` | `HIDDENLAYER_CLIENT_SECRET` | Client secret. |
> | `environment` | US region | `"prod-us"`, `"prod-eu"`, or a `HiddenLayerEnvironment` value. |
> | `baseUrl` | `HIDDENLAYER_BASE_URL` | Any base URL. Wins over `environment`. The variable is read only when neither is given. |
> | `headers` | None | Headers sent with every request. |
> | `timeoutInSeconds` | 60 | Request timeout in seconds. |
> | `maxRetries` | 2 | Retries for retryable failures. `0` disables retries. |
> | `fetch` | Global `fetch` | Your own `fetch` function, for proxies or custom TLS. |
> | `logging` | Off | Log configuration. See [Logging](https://docs.hiddenlayer.ai/docs/integrations/sdk/core_concepts.md#logging). |
> | `auth: false` | None | Send requests without credentials, for a deployment that takes unauthenticated requests. |

> [tab] Java
>
> | Builder method | Default | Description |
> | - | - | - |
> | `token(String)` | `HIDDENLAYER_TOKEN` | An API key or access token, sent as a bearer token and never refreshed. |
> | `clientId(String)` | `HIDDENLAYER_CLIENT_ID` | Client ID, exchanged with the client secret for an access token. |
> | `clientSecret(String)` | `HIDDENLAYER_CLIENT_SECRET` | Client secret. |
> | `environment(Environment)` | US region | `Environment.PROD_US` or `Environment.PROD_EU`. |
> | `url(String)` | `HIDDENLAYER_BASE_URL` | Any `http` or `https` base URL. `url` and `environment` set the same value, so the one called last wins. The variable is read only when neither is called. |
> | `addHeader(name, value)` | None | A header sent with every request. |
> | `timeout(int)` | 60 | Request timeout in seconds. |
> | `maxRetries(int)` | 2 | Retries for retryable failures. `0` disables retries. |
> | `httpClient(OkHttpClient)` | SDK default | Your own `OkHttpClient`, for proxies, custom TLS, or a shared connection pool. |
> | `logging(LogConfig)` | Off | Log configuration. See [Logging](https://docs.hiddenlayer.ai/docs/integrations/sdk/core_concepts.md#logging). |
> | `addInterceptor(Interceptor)` | None | Add an OkHttp interceptor. |
> | `maxConcurrentRequests(int)` | None | Limit the client's concurrent requests. |
> | `retryOnStatusCodes`, `retryDelays`, `initialRetryDelayMillis`, `maxRetryDelayMillis`, `retryJitterFactor` | 408, 429, 5xx; 1 s; 60 s; 0.2 | Tune which responses are retried and the backoff. |

A default in the form `HIDDENLAYER_...` is the environment variable read when you don't pass the option. Credentials resolve in this order: `token`, then the client ID and secret, then `HIDDENLAYER_TOKEN`, then `HIDDENLAYER_CLIENT_ID` and `HIDDENLAYER_CLIENT_SECRET`. With no credentials at all, Python and TypeScript build the client but fail each request with an error that names what to set, and Java's `build()` throws an `IllegalStateException`. See [Authentication and configuration](https://docs.hiddenlayer.ai/docs/integrations/sdk/authentication.md).

### Client members

> [tab] Python
>
> | Member | Access |
> | - | - |
> | API resources | `client.models`, `client.scans`, `client.runtime`, and so on |
> | Model scanner | `client.model_scanner` |
> | Community scanner | `client.community_scanner` |
> | Red team session helper | `client.evaluation_sessions.red_team` |
> | Raw responses | `client.<resource>.with_raw_response.<method>(...)` |
> | Release connections | `client.close()` or a `with` block. For `AsyncHiddenLayer`, `await client.aclose()` or `async with`. |

> [tab] TypeScript
>
> | Member | Access |
> | - | - |
> | API resources | `client.models`, `client.scans`, `client.runtime`, and so on |
> | Model scanner | `client.modelScanner` |
> | Community scanner | `client.communityScanner` |
> | Raw responses | `client.<resource>.<method>(...).withRawResponse()`. A paginated method has no `withRawResponse()`: read `rawResponse` on the page it returns. |
> | Request to any path | `client.fetch(input, init, requestOptions)` |
>
> There is no red team session helper and no method to release connections.

> [tab] Java
>
> | Member | Access |
> | - | - |
> | API resources | `client.models()`, `client.scans()`, `client.runtime()`, and so on |
> | Model scanner | `client.modelScanner()` |
> | Community scanner | `client.communityScanner()` |
> | Raw responses | `client.<resource>().withRawResponse().<method>(...)` |
> | Release connections | `client.close()`; the client is `AutoCloseable` |
>
> There is no red team session helper.

## Module-level exports

> [tab] Python
>
> **`hiddenlayer`**
>
> * Clients: `HiddenLayer`, `AsyncHiddenLayer`, `HiddenLayerEnvironment`.
> * Every request and response type, such as `ScanReportOfRecordV3` and `InteractionEvaluationRequestMetadata`.
> * The typed errors, such as `NotFoundError`.
> * Scanners: `ModelScanner`, `AsyncModelScanner`, `CommunityScanner`, `AsyncCommunityScanner`.
> * Beta warnings: `BetaWarning` and `warn_beta`.
> * HTTP clients for the async client: `DefaultAioHttpClient` and `DefaultAsyncHttpxClient`.
> * `__version__`, the installed version.
>
> **`hiddenlayer.core`**: `ApiError`, `ParsingError`, `RequestOptions`, `SyncPager`, `AsyncPager`, `HttpResponse`, `AsyncHttpResponse`, `LogConfig`, `LogLevel`, `ILogger`.
>
> **`hiddenlayer.errors`**: the typed errors, also exported from `hiddenlayer`.
>
> **`hiddenlayer.lib`**: `CommunityScanSource`, the scanner classes, `check_beta_endpoint`, and the `red_team_exceptions` module.
>
> **`hiddenlayer.<resource>`**: types that only one resource uses, such as `hiddenlayer.scans.StartUploadResponse`.

> [tab] TypeScript
>
> **`@hiddenlayerai/hiddenlayer-sdk`**
>
> * Clients: `HiddenLayer` (also the default export), `HiddenLayerClient`, `HiddenLayerEnvironment`, `HiddenLayerEnvironmentName`.
> * Errors: `HiddenLayerError` and `HiddenLayerTimeoutError`.
> * The `HiddenLayerApi` namespace, with every request and response type and the typed error classes.
> * The `logging` namespace.
> * Scanners: `ModelScanner`, `CommunityScanner`, `CommunityScanSource`, `getScanResults`, `waitForScanResults`, `ScanStatus`, and the `ScanReport` type.
> * Beta warnings: `warnBeta` and `checkBetaEndpoint`.
>
> **`@hiddenlayerai/hiddenlayer-sdk/<resource>`**: one resource's types, such as `@hiddenlayerai/hiddenlayer-sdk/scans`.
>
> The package ships CommonJS and ESM builds. In CommonJS, use `const { HiddenLayer } = require("@hiddenlayerai/hiddenlayer-sdk")`.

> [tab] Java
>
> **`com.hiddenlayer.api`**: `HiddenLayerClient`, `HiddenLayerClientBuilder`, `AsyncHiddenLayerClient`, `AsyncHiddenLayerClientBuilder`, and the base clients `BaseHiddenLayerClient` and `AsyncBaseHiddenLayerClient`.
>
> **`com.hiddenlayer.api.core`**: `Environment`, `RequestOptions`, `LogConfig`, `LogLevel`, `HiddenLayerException`, `HiddenLayerApiException`, `BaseHiddenLayerClientHttpResponse`.
>
> **`com.hiddenlayer.api.core.pagination`**: `SyncPagingIterable`, `SyncPage`.
>
> **`com.hiddenlayer.api.errors`**: the typed errors, such as `NotFoundError`.
>
> **`com.hiddenlayer.api.types`**: request and response types that more than one resource uses.
>
> **`com.hiddenlayer.api.resources.<resource>.requests`** and **`.types`**: one resource's request and response types. The resource's directory is its name in lower case with no separators, such as `resources.promptanalyzer` and `resources.evaluations.redteam`.
>
> **`com.hiddenlayer.api.lib`**: `ModelScanner`, `AsyncModelScanner`, `CommunityScanner`, `AsyncCommunityScanner`, `ScanFileOptions`, `ScanFolderOptions`, `CommunityScanOptions`, `CommunityScanSource`, `ScanUtils`, `BetaWarning`.

## Per-request options

Every resource method takes optional per-request options as its last argument: `request_options={...}` in Python, a second options object in TypeScript, and `RequestOptions.builder()...build()` in Java. The high-level helpers do not take them.

| Option | Python | TypeScript | Java |
| - | - | - | - |
| Timeout | `timeout` | `timeoutInSeconds` | `timeout(Integer)` or `timeout(Integer, TimeUnit)` |
| Retries | `max_retries` | `maxRetries` | `maxRetries(Integer)` |
| Extra headers | `additional_headers` | `headers` | `addHeader` |
| Extra query parameters | `additional_query_parameters` | `queryParams` | `addQueryParameter` |
| Extra body fields | `additional_body_parameters` | `additionalBodyParameters` | `addBodyProperty` |
| Cancel the request | None | `abortSignal` | None |

See [Set per-request options](https://docs.hiddenlayer.ai/docs/integrations/sdk/api_examples.md#set-per-request-options) for examples.

## Models

| Operation | Endpoint | Returns |
| - | - | - |
| Retrieve a model | `GET /api/v2/models/{model_id}` | `SensorSorModel` |
| Delete a model (irreversible) | `DELETE /api/v2/models/{model_id}` | Nothing |
| List model cards (**Deprecated**: use `GET /asset-inventory/v2/assets`) | `GET /models/v4/cards` | Page of `ModelCardV4` |

```python Python theme={null}
# Retrieve a model
client.models.retrieve(model_id)
# Delete a model
client.models.delete(model_id)
# List model cards (deprecated)
client.models.cards.list(...)
```

```typescript TypeScript theme={null}
// Retrieve a model
client.models.retrieve({ model_id })
// Delete a model
client.models.delete({ model_id })
// List model cards (deprecated)
client.models.cards.list({ ... })
```

```java Java theme={null}
// Retrieve a model
client.models().retrieve(modelId)
// Delete a model
client.models().delete(modelId)
// List model cards (deprecated)
client.models().cards().list(...)
```

## Evaluations: red team

All `evaluations.red_team` endpoints are **Beta**. Python users can drive a workflow with the [session helper](#evaluation-sessions-red-team-python) instead. See [Attack simulation](https://docs.hiddenlayer.ai/docs/integrations/sdk/attack_simulation.md).

| Operation | Endpoint | Returns |
| - | - | - |
| Start a workflow | `POST /evaluations/v1/red-team` | `StartWorkflowResponse` |
| Workflow status | `GET /evaluations/v1/red-team/{workflow_id}/status` | `WorkflowStatusResponse` |
| Next action, such as an attack prompt | `GET /evaluations/v1/red-team/{workflow_id}/next-action` | `NextActionResponse` |
| Submit your target's reply | `POST /evaluations/v1/red-team/{workflow_id}/target-response` | `SubmitTargetResponseResult` |
| Results and report | `GET /evaluations/v1/red-team/{workflow_id}` | `WorkflowResultResponse` |
| Stop a running workflow (cannot be undone) | `POST /evaluations/v1/jobs/{workflow_id}/termination` | Nothing |
| List workflows | `GET /evaluations/v1/red-team` | Page of `RedTeamResultItem` |

```python Python theme={null}
red_team = client.evaluations.red_team

# Start a workflow
red_team.create(name=..., target_model=..., ...)
# Workflow status
red_team.retrieve_status(workflow_id)
# Next action
red_team.retrieve_next_action(workflow_id)
# Submit your target's reply
red_team.submit_target_response(workflow_id, session_id=..., target_response=...)
# Results and report
red_team.retrieve_evaluation_results(workflow_id)
# Stop a running workflow
red_team.terminate(workflow_id)
# List workflows
red_team.list(...)
```

```typescript TypeScript theme={null}
const redTeam = client.evaluations.redTeam;

// Start a workflow
redTeam.create({ name, target_model, ... })
// Workflow status
redTeam.retrieveStatus({ workflow_id })
// Next action
redTeam.retrieveNextAction({ workflow_id })
// Submit your target's reply
redTeam.submitTargetResponse({ workflow_id, session_id, target_response })
// Results and report
redTeam.retrieveEvaluationResults({ workflow_id })
// Stop a running workflow
redTeam.terminate({ workflow_id })
// List workflows
redTeam.list({ ... })
```

```java Java theme={null}
RedTeamClient redTeam = client.evaluations().redTeam();

// Start a workflow
redTeam.create(ClientRedTeamBody)
// Workflow status
redTeam.retrieveStatus(workflowId)
// Next action
redTeam.retrieveNextAction(workflowId)
// Submit your target's reply
redTeam.submitTargetResponse(workflowId, SubmitTargetResponseBody)
// Results and report
redTeam.retrieveEvaluationResults(workflowId)
// Stop a running workflow
redTeam.terminate(workflowId)
// List workflows
redTeam.list(...)
```

## Evaluation sessions: red team (Python)

**Beta** (wraps the Beta `evaluations.red_team` endpoints). Python only: the TypeScript and Java SDKs have no session helper. Access it through `client.evaluation_sessions.red_team`. See [Attack simulation](https://docs.hiddenlayer.ai/docs/integrations/sdk/attack_simulation.md) for a walkthrough.

```python theme={null}
client.evaluation_sessions.red_team.start_session(
    *,
    name: str,
    target_model: str,
    target_system_prompt: str = "",
    objective_ids: Optional[List[str]] = None,
    refusal_judge_model: Optional[str] = None,
    objective_judge_model: Optional[str] = None,
    attacker_model: Optional[str] = None,
    evaluation_report_model: Optional[str] = None,
    attacker_guidance: Optional[str] = None,
    severity_mapping: Optional[SeverityMapping] = None,
    config_id: Optional[str] = None,
    max_turns: int = 3,
    execution_strategy_type: str = "random",
    attacker_max_generation_attempts: int = 2,
    n_random_techniques: int = 1,
    max_parallel_techniques: int = 1,
    prompt_set_id: Optional[str] = None,
    hiddenlayer_project_id: Optional[str] = None,
    poll_interval: float = 2.0,
    poll_max_wait: Optional[float] = None,
    sessions_per_technique: Optional[int] = 1,
) -> RedTeamSession  # AsyncRedTeamSession on AsyncHiddenLayer

client.evaluation_sessions.red_team.resume_session(
    workflow_id: str,
    *,
    poll_interval: float = 2.0,
    poll_max_wait: Optional[float] = None,
    max_parallel_techniques: Optional[int] = None,
) -> RedTeamSession

client.evaluation_sessions.red_team.terminate_session(workflow_id: str) -> None
```

`execution_strategy_type` must be `"single"`, `"random"`, or `"static_prompt_set"`; any other value raises `ValueError`. `"static_prompt_set"` requires `prompt_set_id`.

The session that `start_session` and `resume_session` return has these members:

```python theme={null}
session.workflow_id: str
session.name: str
session.get_next_action(*, block: bool = True) -> NextActionResponse
session.wait_for_completion(
    poll_interval: float = 3.0,
    max_wait: Optional[float] = 300.0,
    verbose: bool = False,
) -> None
session.iterate_actions() -> Iterator[NextActionResponse]
session.run_with_callback(handler) -> None

# Async session only
session.get_available_actions(max_actions: int = 10) -> list[NextActionResponse]
session.run_with_callback_parallel(
    handler,
    max_parallel: Optional[int] = None,
    poll_batch_interval: float = 0.5,
) -> None
```

| Member | Description |
| - | - |
| `workflow_id` | The workflow ID. Save it to resume or terminate later. |
| `name` | The session name. |
| `get_next_action` | Polls for the next action. With `block=True`, waits until one is ready. |
| `wait_for_completion` | Polls until a terminal status: `COMPLETED`, `FAILED`, `CANCELLED`, `TERMINATED`, or `TIMED_OUT`. Raises `PollTimeoutError` after `max_wait` seconds. |
| `iterate_actions` | Yields attack actions until the workflow completes. Use `async for` on the async session. |
| `run_with_callback` | Drives the session one action at a time and waits for completion. `handler(attack_prompt, history, session_id, target_system_prompt)` returns your target's reply as a `str` (a coroutine on the async session). |
| `get_available_actions` | Async only. Non-blocking fetch of up to `max_actions` ready actions. |
| `run_with_callback_parallel` | Async only. Processes actions in parallel. When `max_parallel` is `None`, uses the session's `max_parallel_techniques`. |

## Prompt Analyzer

| Operation | Endpoint | Returns |
| - | - | - |
| Analyze a prompt and optional output | `POST /api/v1/submit/prompt-analyzer` | `HiddenLayerPromptAnalyzerResponse` |

```python Python theme={null}
client.prompt_analyzer.create(
    prompt=..., model=..., output=..., hl_project_id=..., requester_id=...
)
```

```typescript TypeScript theme={null}
client.promptAnalyzer.create({
    prompt, model, output, "HL-Project-Id", "X-Requester-Id"
})
```

```java Java theme={null}
client.promptAnalyzer().create(PromptAnalyzerRequest)
```

The response includes `verdict`, `categories`, `results`, `policy`, `frameworks`, `model`, `provider`, and `elapsed_ms`.

## Interactions (v1)

| Operation | Endpoint | Returns |
| - | - | - |
| Analyze LLM input and output | `POST /detection/v1/interactions` | `EnrichedResponse` |

```python Python theme={null}
client.interactions.analyze(metadata=..., input=..., output=..., hl_project_id=...)
```

```typescript TypeScript theme={null}
client.interactions.analyze({ metadata, input, output, "HL-Project-Id" })
```

```java Java theme={null}
client.interactions().analyze(InteractionsRequest)
```

The v1 Interactions endpoint remains available for existing integrations. New integrations use the v2 evaluation endpoints under [Runtime](#runtime), which accept provider-native payloads and agentic content such as tool calls.

## Runtime

The AI Runtime Security v2 evaluation endpoints. See [Runtime security](https://docs.hiddenlayer.ai/docs/integrations/sdk/runtime_security.md).

| Operation | Endpoint | Returns |
| - | - | - |
| Evaluate an interaction | `POST /detection/v2/interaction-evaluations` | `InteractionEvaluationResponse` |
| Evaluate a provider request inline | `POST /detection/v2/request-evaluations` | The provider payload |
| Evaluate a provider response inline | `POST /detection/v2/response-evaluations` | The provider payload |

```python Python theme={null}
# Evaluate an interaction
client.runtime.evaluate_interaction(metadata=..., interaction=..., hl_project_id=...)
# Evaluate a provider request inline; returns a dict
client.runtime.evaluate_request(
    request=..., hl_project_id=..., hl_runtime_session_id=...
)
# Evaluate a provider response inline; returns a dict
client.runtime.evaluate_response(
    request=..., hl_project_id=..., hl_runtime_session_id=...
)
```

```typescript TypeScript theme={null}
// Evaluate an interaction
client.runtime.evaluateInteraction({ metadata, interaction, "HL-Project-Id" })
// Evaluate a provider request inline; returns a ProviderPayload object
client.runtime.evaluateRequest({ body, "HL-Project-Id", "HL-Runtime-Session-Id" })
// Evaluate a provider response inline; returns a ProviderPayload object
client.runtime.evaluateResponse({ body, "HL-Project-Id", "HL-Runtime-Session-Id" })
```

```java Java theme={null}
// Evaluate an interaction
client.runtime().evaluateInteraction(InteractionEvaluationRequest)
// Evaluate a provider request inline; returns a Map<String, Object>
client.runtime().evaluateRequest(Map<String, Object>)
client.runtime().evaluateRequest(EvaluateRequestRuntimeRequest)
// Evaluate a provider response inline; returns a Map<String, Object>
client.runtime().evaluateResponse(Map<String, Object>)
client.runtime().evaluateResponse(EvaluateResponseRuntimeRequest)
```

`interaction` takes either the canonical form (`CanonicalInteraction`, with `messages` and optional `tools_available`) or a provider-native payload: OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, TypeSafe System One, or OpenAI Decisions. `metadata` requires `model`, `requester_id`, and `provider`, and accepts an optional `external_session_id`. The response includes `outcome` (`action`, `threat_level`, `detections`, `effective_interaction`), `evaluated_interaction`, and `metadata`.

The request-evaluations and response-evaluations endpoints return `200` whether or not the policy blocks the payload. Read the `hl-runtime-action` response header with a raw response to detect a block.

## Sensors

**Deprecated.** The API states that each sensors endpoint "will be removed after April 13, 2026". Do not use these methods in new code.

| Operation | Endpoint | Returns |
| - | - | - |
| Create a sensor | `POST /api/v2/sensors/create` | `SensorSorItemResponse` |
| Retrieve a sensor | `GET /api/v2/sensors/{sensor_id}` | `SensorSorItemResponse` |
| Update a sensor | `PUT /api/v2/sensors/{sensor_id}` | `SensorSorUpdateResponseModel` |
| Delete a sensor | `DELETE /api/v2/sensors/{sensor_id}` | Nothing |
| Query sensors | `POST /api/v2/sensors/query` | Page of `SensorSorItemResponse` |

```python Python theme={null}
# Create a sensor
client.sensors.create(plaintext_name=..., ...)
# Retrieve a sensor
client.sensors.retrieve(sensor_id)
# Update a sensor
client.sensors.update(sensor_id, ...)
# Delete a sensor
client.sensors.delete(sensor_id)
# Query sensors
client.sensors.query(filter=..., ...)
```

```typescript TypeScript theme={null}
// Create a sensor
client.sensors.create({ plaintext_name, ... })
// Retrieve a sensor
client.sensors.retrieve({ sensor_id })
// Update a sensor
client.sensors.update({ sensor_id, ... })
// Delete a sensor
client.sensors.delete({ sensor_id })
// Query sensors
client.sensors.query({ filter, ... })
```

```java Java theme={null}
// Create a sensor
client.sensors().create(SensorSorItemCreateRequest)
// Retrieve a sensor
client.sensors().retrieve(sensorId)
// Update a sensor
client.sensors().update(sensorId, SensorSorItemUpdateRequest)
// Delete a sensor
client.sensors().delete(sensorId)
// Query sensors
client.sensors().query(SensorSorQueryRequest)
```

## Scans: results

| Operation | Endpoint | Returns |
| - | - | - |
| File results, cursor paginated | `GET /scan/v3/results/{scan_id}/files` | Page of `ScanFileResultWithComplianceV3` |
| Summary without file results | `GET /scan/v3/results/{scan_id}/summary` | `ScanReportSummaryResponseV3` |
| SARIF export | `GET /scan/v3/results/{scan_id}/sarif` | The SARIF log as untyped JSON: a `dict` (Python), an object (TypeScript), or a `Map<String, Object>` (Java) |

```python Python theme={null}
# File results
client.scans.results.list_files(scan_id, page_size=..., has_detections=..., ...)
# Summary
client.scans.results.retrieve_summary(scan_id)
# SARIF export
client.scans.results.sarif(scan_id)
```

```typescript TypeScript theme={null}
// File results
client.scans.results.listFiles({ scan_id, page_size, has_detections, ... })
// Summary
client.scans.results.retrieveSummary({ scan_id })
// SARIF export
client.scans.results.sarif({ scan_id })
```

```java Java theme={null}
// File results
client.scans().results().listFiles(scanId, ListFilesResultsRequest)
// Summary
client.scans().results().retrieveSummary(scanId)
// SARIF export
client.scans().results().sarif(scanId)
```

Each method also takes an optional `include_threat_types` flag, which adds threat types to the findings.

## Scans: jobs

| Operation | Endpoint | Returns |
| - | - | - |
| Full scan report | `GET /scan/v3/results/{scan_id}` | `ScanReportOfRecordV3` |
| List scans, offset paginated | `GET /scan/v3/results` | Page of `ScanReportOfRecordV3Summary` |
| Request a scan of a remote model | `POST /scan/v3/jobs` | `ScanJob` |

```python Python theme={null}
# Full scan report
client.scans.jobs.retrieve(scan_id, has_detections=...)
# List scans
client.scans.jobs.list(limit=..., model_name=..., ...)
# Request a scan of a remote model
client.scans.jobs.request(access=..., inventory=...)
```

```typescript TypeScript theme={null}
// Full scan report
client.scans.jobs.retrieve({ scan_id, has_detections })
// List scans
client.scans.jobs.list({ limit, model_name, ... })
// Request a scan of a remote model
client.scans.jobs.request({ access, inventory })
```

```java Java theme={null}
// Full scan report
client.scans().jobs().retrieve(scanId, RetrieveJobsRequest)
// List scans
client.scans().jobs().list(ListJobsRequest)
// Request a scan of a remote model
client.scans().jobs().request(ScanJobRequest)
```

The list's response envelope, `ListJobsResponse` with `total`, is the page's response. The community scanner wraps the request method.

## Scans: upload

These methods implement the multipart upload the model scanner uses. Most users should call the model scanner instead.

| Operation | Endpoint | Returns |
| - | - | - |
| Start an upload session | `POST /scan/v3/upload` | `StartUploadResponse` |
| Register a file | `POST /scan/v3/upload/{scan_id}/file` | `AddFileResponse` |
| Mark one file uploaded | `PATCH /scan/v3/upload/{scan_id}/file/{file_id}` | `CompleteFileResponse` |
| Mark all files uploaded and start scanning | `PATCH /scan/v3/upload/{scan_id}` | `CompleteAllUploadResponse` |

```python Python theme={null}
# Start an upload session
client.scans.upload.start(model_name=..., model_version=..., requesting_entity=..., ...)
# Register a file
client.scans.upload.file.add(scan_id, file_content_length=..., file_name=...)
# Mark one file uploaded
client.scans.upload.file.complete(scan_id, file_id)
# Mark all files uploaded and start scanning
client.scans.upload.complete_all(scan_id)
```

```typescript TypeScript theme={null}
// Start an upload session
client.scans.upload.start({ model_name, model_version, requesting_entity, ... })
// Register a file
client.scans.upload.file.add({ scan_id, "file-content-length", "file-name" })
// Mark one file uploaded
client.scans.upload.file.complete({ scan_id, file_id })
// Mark all files uploaded and start scanning
client.scans.upload.completeAll({ scan_id })
```

```java Java theme={null}
// Start an upload session
client.scans().upload().start(MultiFileUploadRequestV3)
// Register a file
client.scans().upload().file().add(scanId, AddFileRequest)
// Mark one file uploaded
client.scans().upload().file().complete(scanId, fileId)
// Mark all files uploaded and start scanning
client.scans().upload().completeAll(scanId)
```

## Model scanner

High-level helper that uploads model files, starts the scan, and by default waits for it to finish. Each method returns the scan report, `ScanReportOfRecordV3` (exported as `ScanReport` in TypeScript). See [Model scanning](https://docs.hiddenlayer.ai/docs/integrations/sdk/model_scanning.md).

| Operation | Python | TypeScript | Java |
| - | - | - | - |
| Scan one local file | Yes | Yes | Yes |
| Scan a folder as one model | Yes | Yes | Yes |
| Scan a model in AWS S3 | Yes | Yes | No |
| Scan a model in Azure Blob Storage | Yes | Yes | No |
| Scan a Hugging Face repository | Yes | Yes | No |
| Read an existing scan's report | Yes | Yes | Yes |

```python Python theme={null}
scanner = client.model_scanner

# Scan one local file
scanner.scan_file(
    model_name=..., model_path=..., model_version="1", wait_for_results=True,
    request_source="API Upload", origin="",
)
# Scan a folder as one model
scanner.scan_folder(
    model_name=..., path=..., allow_file_patterns=None, ignore_file_patterns=None, ...
)
# Scan a model in AWS S3
scanner.scan_s3_model(model_name=..., bucket=..., key=..., s3_client=None, ...)
# Scan a model in Azure Blob Storage
scanner.scan_azure_blob_model(
    model_name=..., account_url=..., container=..., blob=...,
    blob_service_client=None, credential=None, ...
)
# Scan a Hugging Face repository
scanner.scan_huggingface_model(
    repo_id=..., model_name=None, revision=None, local_dir="/tmp",
    allow_file_patterns=None, ignore_file_patterns=None,
    force_download=False, hf_token=None, ...
)
# Read an existing scan's report
scanner.scan_result(scan_id=...)
```

```typescript TypeScript theme={null}
const scanner = client.modelScanner;

// Scan one local file
scanner.scanFile({
    modelName, modelPath, modelVersion?, waitForResults?, requestSource?, origin?
})
// Scan a folder as one model
scanner.scanFolder({ modelName, path, allowFilePatterns?, ignoreFilePatterns?, ... })
// Scan a model in AWS S3
scanner.scanS3Model({ modelName, bucket, key, s3Client?, ... })
// Scan a model in Azure Blob Storage
scanner.scanAzureBlobModel({
    modelName, accountUrl, container, blob, blobServiceClient?, credential?, ...
})
// Scan a Hugging Face repository
scanner.scanHuggingFaceModel({
    repoId, modelName?, revision?, localDir?, allowFilePatterns?, ignoreFilePatterns?,
    hfToken?, ...
})
// Read an existing scan's report, or wait for it to finish
getScanResults(client, scanId)
waitForScanResults(client, scanId)
```

```java Java theme={null}
ModelScanner scanner = client.modelScanner();

// Scan one local file
scanner.scanFile(ScanFileOptions)
scanner.scanFile(modelName, modelPath, ...)
// Scan a folder as one model
scanner.scanFolder(ScanFolderOptions)
scanner.scanFolder(modelName, path, ...)
// No S3, Azure Blob Storage, or Hugging Face helpers: download the model with
// your provider's SDK, then call scanFile or scanFolder.

// Read an existing scan's report, or wait for it to finish
ScanUtils.getScanResults(client, scanId)
ScanUtils.waitForScanResults(client, scanId)
```

The S3, Azure Blob Storage, and Hugging Face helpers need extra packages, which the SDK doesn't install:

| Storage | Python | TypeScript |
| - | - | - |
| AWS S3 | `boto3` | `@aws-sdk/client-s3` |
| Azure Blob Storage | `azure-identity`, `azure-storage-blob` | `@azure/storage-blob` |
| Hugging Face | `huggingface_hub` | `@huggingface/hub` |

Java's `AsyncModelScanner` has the same methods, returning a `CompletableFuture`; the `ScanUtils` methods also have `Async` variants.

The request source defaults to `"API Upload"` and also accepts `"Hybrid Upload"`, `"Integration"`, `"UI Upload"`, and `"AI Asset Discovery"`. When the helper waits for results, it polls until the scan status is `done`, `failed`, or `canceled`, with no overall time limit. A failed scan is returned, not raised, so check the report's status.

## Community scanner

High-level helper that asks HiddenLayer to fetch and scan a model from a remote location, so nothing is downloaded to your machine. It returns the scan report.

```python Python theme={null}
scanner = client.community_scanner

# Scan a remote model
scanner.community_scan(
    model_name, model_path, model_source, model_version="main",
    wait_for_results=True, request_source="API Upload", origin="",
)
# Read an existing scan's report
scanner.scan_result(scan_id=...)
```

```typescript TypeScript theme={null}
const scanner = client.communityScanner;

// Scan a remote model
scanner.communityScan({
    modelName, modelPath, modelSource, modelVersion?, waitForResults?,
    requestSource?, origin?
})
// Read an existing scan's report
getScanResults(client, scanId)
```

```java Java theme={null}
CommunityScanner scanner = client.communityScanner();

// Scan a remote model
scanner.communityScan(CommunityScanOptions)
scanner.communityScan(modelName, modelPath, modelSource, ...)
// Read an existing scan's report
ScanUtils.getScanResults(client, scanId)
```

### `CommunityScanSource`

The model source takes one of these values: `LOCAL`, `AWS_PRESIGNED`, `AWS_IAM_ROLE`, `AZURE_BLOB_SAS`, `AZURE_BLOB_AD`, `GOOGLE_SIGNED`, `GOOGLE_OAUTH`, or `HUGGING_FACE`. Use the `CommunityScanSource` constants from `hiddenlayer.lib` (Python), `@hiddenlayerai/hiddenlayer-sdk` (TypeScript), or `com.hiddenlayer.api.lib` (Java), or pass the string.

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

## Exceptions

| Error | Python | TypeScript | Java |
| - | - | - | - |
| Any error response | `hiddenlayer.core.ApiError` | `HiddenLayerError` | `HiddenLayerApiException` |
| Its status, headers, and body | `status_code`, `headers`, `body` | `statusCode`, `rawResponse`, `body` | `statusCode()`, `headers()`, `body()` |
| Typed errors, such as `NotFoundError` | From `hiddenlayer` | Under `HiddenLayerApi` | In `com.hiddenlayer.api.errors` |
| Timeout | `httpx.TimeoutException` | `HiddenLayerTimeoutError` | `HiddenLayerException`, cause `InterruptedIOException` |
| No response | `httpx.TransportError` | `HiddenLayerError` without `statusCode` | `HiddenLayerException`, cause `IOException` |
| Unexpected response | `hiddenlayer.core.ParsingError` | Not validated | `HiddenLayerException` |
| Red team session | `hiddenlayer.lib.red_team_exceptions` | None | None |

The typed errors have the same names in all three SDKs: `BadRequestError`, `UnauthorizedError`, `ForbiddenError`, `NotFoundError`, `ConflictError`, `GoneError`, `PreconditionFailedError`, `ContentTooLargeError`, `UnsupportedMediaTypeError`, `UnprocessableEntityError`, `InternalServerError`, `NotImplementedError`, `BadGatewayError`, and `ServiceUnavailableError`. The Python red team session raises `RedTeamSessionError`, `PollTimeoutError`, `WorkflowNotFoundError`, and `InvalidSessionError`.

A method raises a typed error only for the statuses its endpoint declares; any other status raises the base class. See [Error handling](https://docs.hiddenlayer.ai/docs/integrations/sdk/error_handling.md) for the full hierarchy and patterns.
