
SAM 2.1 Hiera Large
Click or draw a box on an object and get back a mask outlining it.
Fine-tunableGROUNDED_SAM_2Outlines the things you name in a picture, such as "red car, person with a helmet", with a mask and a box for each one.

Grounding DINO (IDEA-Research/grounding-dino-base, Apache-2.0) finds what the labels name, and SAM 2.1 (facebook/sam2.1-hiera-large, Apache-2.0) outlines it.
| Name | Type | Required | Default | Details |
|---|---|---|---|---|
image | file | Yes | — | The picture: PNG, JPEG or WebP, up to 20 MB and 40 megapixels. Masks have its size, scaled down to 2048 pixels on the longer side. 1–2048 characters · image/png, jpeg, webp |
labels | text | Yes | — | What to outline, comma-separated ("cat, red car") or a JSON array: up to 32 labels of up to 64 characters, in English. The 32 best matches are outlined. Read in at most 2 prompts of 256 tokens, which only very long lists exceed. 1–12418 characters |
text_threshold | number | No | — | How well a detection must match its label, 0 to 1. Empty uses the model's recommended value. 0–1 |
box_threshold | number | No | — | Lowest detection score to outline, 0 to 1; higher returns fewer, surer segments. Empty uses the model's recommended value. 0–1 |
Output. JSON: {"width", "height", "segments": [{"label", "score", "mask_score", "box", "mask"}]}, best first: score = the detection's, box [x0, y0, x1, y1] in pixels, mask a COCO RLE {"size": [h, w], "counts"}.
Send your API key in the X-API-Key header. The run is asynchronous: submit it, then poll it until it finishes. Create an API key.
curl -X POST "https://api.kainguru.com/api/v1/executions?mlFlowId=GROUNDED_SAM_2" \
-H "X-API-Key: kg_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"input": {
"image": "https://example.com/input.png",
"labels": "example"
},
"outputFormat": "json"
}'
# Poll until the execution reaches a terminal state
curl "https://api.kainguru.com/api/v1/executions/{executionId}" \
-H "X-API-Key: kg_your_api_key"from kainguru import KainguruClient
with KainguruClient(api_key="kg_your_api_key", base_url="https://api.kainguru.com/api") as client:
submitted = client.executions.execute(
"GROUNDED_SAM_2",
{
"image": "https://example.com/input.png",
"labels": "example"
},
output_format="json",
)
result = client.executions.await_completion(submitted.id)
print(result.execution.output)You can fine-tune Grounded SAM 2 on your own data and run the tuned model through the same API. Dataset: One ZIP (at most 4 GB, no password) with 4 to 2000 pictures and one COCO annotations JSON (images, 1 to 32 categories, annotations with polygon or RLE segmentation). More in Good to know, in the README.
The steps are in the docs.
Price per image: 0.0874 credits ($0.000874). The price is shown again before every run; all prices are on the pricing page.

Click or draw a box on an object and get back a mask outlining it.
Fine-tunable
Maps water and floods from satellite images: send a Sentinel-2 GeoTIFF and get a water mask at the image's size, with…
Fine-tunable
Fast background removal that returns the subject of a photo on a transparent background, or as a black-and-white mask.
Fine-tunable
Finds every object of 80 everyday kinds in a picture, such as people, vehicles, animals and furniture, and outlines…
Fine-tunable
Removes the background from a photo and returns the subject on a transparent background, or as a black-and-white mask.
Fine-tunable
Finds the clothes a person wears in a photo and returns a mask for the upper body, the lower body and full-body…
Fine-tunable