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

# schemas

Request and response schemas for model inference.

These Pydantic models define the JSON payloads exchanged between clients and a deployed model endpoint (e.g. SageMaker or a local server). Each request/response pair corresponds to a single tile.

## ModelRequest

```python theme={null}
class ModelRequest(BaseModel)
```

Payload sent to the model endpoint for a single tile.

The tile image is base64-encoded for JSON transport. Bulk RNA counts can optionally be included for multimodal models.

<ParamField body="image_data" type="str" required>
  Base64-encoded tile image (PNG).
</ParamField>

<ParamField body="bulk_rna" type="list[float] | None">
  Optional bulk RNA counts vector.
</ParamField>

<ParamField body="slide_name" type="str" required>
  Stem of the source slide filename.
</ParamField>

<ParamField body="x" type="int" required>
  Tile x-coordinate in the slide.
</ParamField>

<ParamField body="y" type="int" required>
  Tile y-coordinate in the slide.
</ParamField>

<ParamField body="width" type="int" required>
  Tile width in pixels.
</ParamField>

<ParamField body="height" type="int" required>
  Tile height in pixels.
</ParamField>

<ParamField body="tissue_ratio" type="float | None">
  Fraction of tissue in the tile.
</ParamField>

<ParamField body="patch_idx" type="int" required>
  Index of this tile in the extraction plan.
</ParamField>

#### image

```python theme={null}
@property
def image() -> Image.Image
```

Decodes and returns the tile image as PIL.

## ModelResponse

```python theme={null}
class ModelResponse(BaseModel)
```

Payload returned by the model endpoint for a single tile.

Carries the model output together with the full tile metadata from the originating request, so that downstream writers can persist everything without needing a separate schema.

<ParamField body="output" type="list[float]">
  Model output vector for this tile.
</ParamField>

<ParamField body="slide_name" type="str">
  Stem of the source slide filename.
</ParamField>

<ParamField body="x" type="int">
  Tile x-coordinate in the slide.
</ParamField>

<ParamField body="y" type="int">
  Tile y-coordinate in the slide.
</ParamField>

<ParamField body="width" type="int">
  Tile width in pixels.
</ParamField>

<ParamField body="height" type="int">
  Tile height in pixels.
</ParamField>

<ParamField body="tissue_ratio" type="float | None">
  Fraction of tissue in the tile.
</ParamField>

<ParamField body="patch_idx" type="int">
  Index of this tile in the extraction plan.
</ParamField>

<ParamField body="resolution" type="float | None">
  Extraction resolution (MPP) if available.
</ParamField>

## SageMakerRequest

```python theme={null}
class SageMakerRequest(ModelRequest)
```

Extended request for the SageMaker `/invocations` endpoint.

Adds a `model_name` field so the server can dispatch to the correct model and a `mode` field to select the scheduler (`"prediction"` or `"embedding"`).
