Skip to main content
POST
/
api
/
embed
/
h1
H-Optimus (H1) tile embedding
curl --request POST \
  --url http://localhost:8080/api/embed/h1 \
  --header 'Content-Type: application/json' \
  --data '
{
  "image_data": "<base64-png-224x224>",
  "slide_name": "slide_A",
  "x": 0,
  "y": 0,
  "width": 224,
  "height": 224,
  "tissue_ratio": 0.8,
  "patch_idx": 0,
  "resolution": 0.5
}
'
import requests

url = "http://localhost:8080/api/embed/h1"

payload = {
"image_data": "<base64-png-224x224>",
"slide_name": "slide_A",
"x": 0,
"y": 0,
"width": 224,
"height": 224,
"tissue_ratio": 0.8,
"patch_idx": 0,
"resolution": 0.5
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
image_data: '<base64-png-224x224>',
slide_name: 'slide_A',
x: 0,
y: 0,
width: 224,
height: 224,
tissue_ratio: 0.8,
patch_idx: 0,
resolution: 0.5
})
};

fetch('http://localhost:8080/api/embed/h1', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/api/embed/h1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image_data' => '<base64-png-224x224>',
'slide_name' => 'slide_A',
'x' => 0,
'y' => 0,
'width' => 224,
'height' => 224,
'tissue_ratio' => 0.8,
'patch_idx' => 0,
'resolution' => 0.5
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "http://localhost:8080/api/embed/h1"

payload := strings.NewReader("{\n \"image_data\": \"<base64-png-224x224>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 224,\n \"height\": 224,\n \"tissue_ratio\": 0.8,\n \"patch_idx\": 0,\n \"resolution\": 0.5\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("http://localhost:8080/api/embed/h1")
.header("Content-Type", "application/json")
.body("{\n \"image_data\": \"<base64-png-224x224>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 224,\n \"height\": 224,\n \"tissue_ratio\": 0.8,\n \"patch_idx\": 0,\n \"resolution\": 0.5\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("http://localhost:8080/api/embed/h1")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"image_data\": \"<base64-png-224x224>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 224,\n \"height\": 224,\n \"tissue_ratio\": 0.8,\n \"patch_idx\": 0,\n \"resolution\": 0.5\n}"

response = http.request(request)
puts response.read_body
{
  "output": [
    123
  ],
  "slide_name": "<string>",
  "x": 123,
  "y": 123,
  "width": 123,
  "height": 123,
  "tissue_ratio": 123,
  "patch_idx": 123,
  "resolution": 123
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
{
"detail": "Internal server error"
}
{
"status": "loading"
}

Body

application/json
image_data
string
required

Base64-encoded PNG tile. (The SDK also accepts a PIL Image or raw bytes.)

slide_name
string
required

Stem of the source slide filename.

x
integer
required

Tile x-coordinate in the slide.

y
integer
required

Tile y-coordinate in the slide.

width
integer
required

Tile width in pixels.

height
integer
required

Tile height in pixels.

patch_idx
integer
required

Index of this tile in the extraction plan.

bulk_rna
number[] | null

Optional bulk RNA counts vector (M-Optimus prediction only).

tissue_ratio
number | null

Fraction of tissue in the tile.

resolution
number | null

Extraction resolution in microns per pixel.

Response

Embedding result

output
number[]

Model output vector: embeddings (1536), gene predictions, or a flattened mask.

slide_name
string
x
integer
y
integer
width
integer
height
integer
tissue_ratio
number | null
patch_idx
integer
resolution
number | null