Skip to main content
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

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.
image_data
str
required
Base64-encoded tile image (PNG).
bulk_rna
list[float] | None
Optional bulk RNA counts vector.
slide_name
str
required
Stem of the source slide filename.
x
int
required
Tile x-coordinate in the slide.
y
int
required
Tile y-coordinate in the slide.
width
int
required
Tile width in pixels.
height
int
required
Tile height in pixels.
tissue_ratio
float | None
Fraction of tissue in the tile.
patch_idx
int
required
Index of this tile in the extraction plan.

image

@property
def image() -> Image.Image
Decodes and returns the tile image as PIL.

ModelResponse

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.
output
list[float]
Model output vector for this tile.
slide_name
str
Stem of the source slide filename.
x
int
Tile x-coordinate in the slide.
y
int
Tile y-coordinate in the slide.
width
int
Tile width in pixels.
height
int
Tile height in pixels.
tissue_ratio
float | None
Fraction of tissue in the tile.
patch_idx
int
Index of this tile in the extraction plan.
resolution
float | None
Extraction resolution (MPP) if available.

SageMakerRequest

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").