# Sam 2 Auto Segment SAM2 Auto Segment creates image segmentation masks from a source image, returning combined and individual masks for object isolation workflows. ## API Information - **Model Slug:** sam2-auto-segment - **Branded URL:** https://www.eachlabs.ai/eachlabs/utility-tools/sam2-auto-segment - **Provider:** each::labs - **Category:** Image to Image - **Output Type:** object - **Status:** active - **Base Cost:** $0.001 per processing second - **Estimated Processing Time:** 60 seconds - **Interactive Demo:** https://www.eachlabs.ai/ai-models/sam2-auto-segment ## Pricing - **Charge Type:** dynamic - **Estimate:** $0.001 per processing second - **Pricing Details:** default: $0.001 ## Input Schema | Parameter | Type | Required | Default | Constraints | Description | |-----------|------|----------|---------|-------------|-------------| | image_url | string | Yes | - | - | URL of the image to segment. | | output_format | string | No | png | png, jpeg | Output mask image format. Default: png. | | points_per_side | integer | No | 32 | 1–128 | Number of points sampled along each side. Default: 32. | | pred_iou_thresh | number | No | 0.88 | 0–1 | Predicted IoU threshold for mask filtering. Default: 0.88. | | stability_score_thresh | number | No | 0.95 | 0–1 | Stability score threshold for mask filtering. Default: 0.95. | | min_mask_region_area | integer | No | 100 | 0–1000000 | Minimum mask region area in pixels. Default: 100. | ## Example Request ```bash curl -X POST https://api.eachlabs.ai/v1/prediction/ \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sam2-auto-segment", "input": { "image_url": "https://cdn-us.eachlabs.ai/defaults/81e7007d9b8942678c63c3beed4439b2.png" } }' ``` ## Output Schema Response returned by `GET /v1/prediction/{id}` when the job completes: ```json { "status": "success", "predictionID": "string", "output": "object", "metrics": { "predict_time": "number (seconds)" } } ``` ## Polling ```bash curl https://api.eachlabs.ai/v1/prediction/{PREDICTION_ID} \ -H "Authorization: Bearer YOUR_API_KEY" ``` | Status | Meaning | |--------|---------| | `processing` | Still running — poll again | | `success` | Done — read `output` | | `error` | Failed — read `message` / `details` | ## Webhook (alternative to polling) Pass `"webhook_url": "https://your.host/path"` in the create request. Eachlabs POSTs this payload when the job ends: ```json { "exec_id": "prediction-uuid", "status": "succeeded", "output": "https://...", "error": "" } ``` `status` is `"succeeded"` or `"failed"`. `exec_id` equals the `predictionID` from create. Return 2xx within 30 seconds. ## Errors Error body: `{ "status": "error", "message": "...", "details": "..." }` | Code | Meaning | |------|---------| | `400` | Invalid input | | `401` | Missing / invalid `Authorization` bearer token | | `404` | Unknown model or prediction id | | `429` | Rate limit — 100 creates / min, 10 concurrent per key | | `5xx` | Retry with backoff | ## Usage Notes - API Base URL: `https://api.eachlabs.ai/v1` - Authentication: send `Authorization: Bearer YOUR_API_KEY`. Generate a key from the Eachlabs dashboard at https://www.eachlabs.ai/dashboard/api-keys. - File-typed parameters (`*_url`, `image_url`, `video_url`, `audio_url`, etc.) accept publicly-reachable HTTPS URLs only. Upload your asset first (GCS / S3 / your CDN) and pass the resulting URL. Data-URIs and localhost URLs are rejected. - For structured parameters (arrays / objects) send real JSON values, not stringified payloads. - Monetary values are reported in USD; per-token / per-megapixel rates may be billed in micro-cents internally. - Prefer `webhook_url` over polling for long-running predictions — see the Webhook Callback section.