Skip to main content
Client-agnostic endpoint model. Provides a single EndpointModel that pairs a ModelSpec with any Client implementation (HTTP, AWS SageMaker, GCP, Azure, …). This eliminates the need for per-backend model subclasses.

EndpointModel

class EndpointModel()
Model endpoint backed by a pluggable client. Combines a ModelSpec (what the model expects and produces) with a Client (how to reach it). Supports both synchronous (predict / embed) and asynchronous (predict_async / embed_async) dispatch.
model_spec
Model specification describing input requirements and output shape.
transport
A configured Client instance (e.g. HTTPClient, AWSClient).
input_gene_names
Optional ordered Ensembl IDs expected as bulk RNA input (M-Optimus ).
output_gene_names
Optional ordered Ensembl IDs of predicted output genes (M-Optimus).
Example:
from bioptimus.models.clients.http import HTTPClient

client = HTTPClient(
    "http://localhost:8080",
    endpoints={"embedding": "/api/embed/h0-mini"},
)
model = EndpointModel(H0_MINI_SPEC, client)
response = model(request)

model_spec

@property
def model_spec() -> ModelSpec
Model specification including tile and output config.

input_gene_names

@property
def input_gene_names() -> list[str] | None
Ordered Ensembl IDs expected as bulk RNA input.

output_gene_names

@property
def output_gene_names() -> list[str] | None
Ordered Ensembl IDs of predicted output genes.

predict

def predict(request: ModelRequest) -> ModelResponse
Send a prediction request to the endpoint.
request
ModelRequest
required
Tile request payload to send.
returns
ModelResponse
Parsed model response with predictions.

embed

def embed(request: ModelRequest) -> ModelResponse
Send an embedding request to the endpoint.
request
ModelRequest
required
Tile request payload to send.
returns
ModelResponse
Parsed model response with embeddings.

predict_async

async def predict_async(request: ModelRequest,
                        session: Any = None) -> ModelResponse
Send a prediction request asynchronously.
request
ModelRequest
required
Tile request payload to send.
session
Any
An ClientSession for connection pooling.
returns
ModelResponse
Parsed model response with predictions.

embed_async

async def embed_async(request: ModelRequest,
                      session: Any = None) -> ModelResponse
Send an embedding request asynchronously.
request
ModelRequest
required
Tile request payload to send.
session
Any
An ClientSession for connection pooling.
returns
ModelResponse
Parsed model response with embeddings.