Perception

Segment objects

Get object masks for an image from point, box or text prompts.

View as Markdown
POST/v1/segment

Send at least one prompt. Text prompts return a mask for every instance of the concept, each labelled with the text it answers.

Authorization

Request body

JSON, with Content-Type: application/json.

  • modelstringrequired

    The segmentation model to run, e.g. meta/sam-3. The live models for this endpoint are listed below.

  • imagestringrequired

    The image, base64 JPEG or PNG (a data: URL works too). Under 4 MB of base64.

  • pointsnumber[][]

    Up to 32 [x, y] pixel positions on the object.

  • boxesnumber[][]

    Up to 32 boxes, each [x0, y0, x1, y1] in pixels.

  • textstring | string[]

    What to find, e.g. "red cup", or up to 16 phrases. For models that take text (e.g. SAM 3).

Response

  • idstring

    Unique id of this call, e.g. seg_48213. It matches the call in your Activity dashboard.

  • modelstring

    The model that answered.

  • backendstring

    "http": the real model ran on a GPU. "simulated": stand-in output of the same shape, as test keys get.

  • sandboxboolean

    true when the call was made with a test key: the output is simulated, nothing ran on a GPU and nothing was charged. Absent otherwise.

  • masksobject[]

    One per object found.

    Show 5 child attributes
    • scorenumber

      Confidence, 0–1.

    • boxnumber[4]

      The mask's bounding box, [x0, y0, x1, y1] in pixels.

    • areainteger

      Mask area in pixels.

    • rleobject

      The mask as uncompressed COCO RLE: { size: [height, width], counts }, column-major (the format pycocotools decodes).

    • textstring

      For text prompts: the phrase this mask answers.

  • usageobject

    What the call cost.

    Show 2 child attributes
    • cost_usdnumber

      Charged to your credits, in US dollars.

    • latency_msinteger

      Time the model took, in milliseconds.

Errors

The errors every endpoint shares: invalid input, keys, credits and cold starts. See Errors.

Models

7 live models for /segment. Each page has a ready-made request.