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

# bioptimus.models.clients.aws

AWS SageMaker client.

Sends JSON payloads to a SageMaker endpoint via the `sagemaker-runtime` `invoke_endpoint` API.  The `model_name` field is injected into every request body for multi-model dispatch.

## AWSClient

```python theme={null}
class AWSClient(endpoint_name: str,
                model_name: str,
                region_name: str | None = None,
                boto_session: boto3.Session | None = None,
                timeout: float = 60.0)
```

Sends JSON payloads to an AWS SageMaker endpoint.

**endpoint\_name**

Name of the SageMaker endpoint.

**model\_name**

Model identifier injected into the request body for SageMaker multi-model dispatch.

**region\_name**

AWS region. When *None*, uses the default from the environment or *boto\_session*.

**boto\_session**

Optional pre-configured `boto3.Session` (e.g. with explicit credentials or a custom profile). When *None*, a default session is created using the standard credential chain.

**timeout**

Read timeout in seconds.

**Example**:

```python theme={null}
client = AWSClient(
    endpoint_name="h1-prod",
    model_name="h1",
)
resp_json = client.predict(request_json)
```

***

#### predict

```python theme={null}
@log_failures
def predict(body: str) -> str
```

Invokes the SageMaker endpoint for prediction.

**body**

Serialized JSON request payload.

**Returns**:

Response body as a JSON string.

***

#### embed

```python theme={null}
@log_failures
def embed(body: str) -> str
```

Invokes the SageMaker endpoint for embedding.

**body**

Serialized JSON request payload.

**Returns**:

Response body as a JSON string.

***

#### predict\_with\_embedding

```python theme={null}
@log_failures
def predict_with_embedding(body: str) -> str
```

Invokes the SageMaker endpoint for the combined prediction+embedding mode.

Returns both the gene prediction and the tile embedding from a single forward pass (the embedding is a free byproduct of the prediction backbone).

**body**

Serialized JSON request payload.

**Returns**:

Response body as a JSON string, with `embedding` populated
alongside `output`.

***

#### metadata

```python theme={null}
@log_failures
def metadata() -> str
```

Fetches model metadata via `/invocations`.

Sends a minimal request with `mode` set to `"metadata"` so the server returns model metadata instead of running inference.

**Returns**:

Response body as a JSON string.

***

#### predict\_async

```python theme={null}
@log_failures
async def predict_async(body: str, session: Any = None) -> str
```

Predicts asynchronously via `run_in_executor`.

`boto3` is not natively async, so the synchronous `predict` call is delegated to a thread pool.

**body**

Serialized JSON payload.

**session**

Unused. Accepted for interface compatibility with the `Client` protocol.

**Returns**:

Response body as a string.

***

#### embed\_async

```python theme={null}
@log_failures
async def embed_async(body: str, session: Any = None) -> str
```

Embeds asynchronously via `run_in_executor`.

**body**

Serialized JSON payload.

**session**

Unused. Accepted for interface compatibility.

**Returns**:

Response body as a string.

***

#### predict\_with\_embedding\_async

```python theme={null}
@log_failures
async def predict_with_embedding_async(body: str, session: Any = None) -> str
```

Combined prediction+embedding asynchronously via `run_in_executor`.

**body**

Serialized JSON payload.

**session**

Unused. Accepted for interface compatibility.

**Returns**:

Response body as a string.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.