Skip to main content
Glama

Segment an image (SAM 2 / Grounded-SAM)

replicate_segment

Generate segmentation masks from images using point, box, or text prompts. Supports auto-masking with SAM 2 and text-prompted segmentation with Grounded-SAM.

Instructions

Produce a segmentation mask of an image. Use SAM 2 for point/box-prompt masks (auto-mask everything when no prompt given) or Grounded-SAM for text-prompt masking like "the red car".

DISPLAY REQUIREMENT — embed the mask result inline using one of the three blocks printed by the tool.

Args:

  • image (URL): Source image.

  • prompt (string, optional): Text prompt for grounded segmentation. Required for grounded-sam.

  • model (default "sam-2"): Curated (sam-2, grounded-sam) or "owner/name".

  • extra_input (object, optional): SAM-specific tuning (e.g. {points_per_side: 32}).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYesURL of the image to segment.
modelNoSegmentation model. Curated: sam-2, grounded-sam. Or "owner/name".sam-2
promptNoText-prompt for grounded segmentation (e.g. 'the red car'). Required for grounded-sam.
downloadNo
timeout_msNoMax ms to wait for the prediction. If exceeded, returns the prediction ID so you can poll via replicate_get_prediction. Default: 300000 (5min).
extra_inputNoModel-specific extras (e.g. {points_per_side: 32} for SAM 2 auto-mask).
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses async behavior with timeout and polling fallback via replicate_get_prediction, and display requirement for embedding results. Annotations are consistent (non-read-only, not idempotent, not destructive).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Concise with front-loaded purpose and structured args. Slight redundancy with schema but minimal waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers key aspects: mask result display, timeout/async behavior, model selection. No output schema, but description explains how to use the result. Adequate for complexity level.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Adds meaning beyond schema: explains prompt required for grounded-sam, model curated options, extra_input for SAM tuning. Doesn't enrich download parameter, but overall compensates for schema coverage (83%).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the tool produces segmentation masks, distinguishes between SAM 2 (point/box-prompt) and Grounded-SAM (text-prompt), and differentiates from sibling tools like replicate_generate_image or replicate_inpaint.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides clear usage context: when to use SAM 2 vs Grounded-SAM, and that prompt is required for Grounded-SAM. Lacks explicit exclusions or when-not-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sena-labs/replicate-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server