Perception

Estimate depth

Get a depth map for an image, a rectified stereo pair or a short clip.

View as Markdown
POST/v1/depth

The map comes back at the image's aspect ratio with its longest side at most 256 pixels. Which inputs a model uses depends on the model: stereo models need right_image, depth-prompted models take prompt_depth, and video depth models take frames.

Authorization

Request body

JSON, with Content-Type: application/json.

  • modelstringrequired

    The depth model to run, e.g. bytedance/depth-anything-v2. The live models for this endpoint are listed below.

  • imagestringrequired

    The image (the left image of a stereo pair), base64 JPEG or PNG. Under 4 MB of base64. Required unless you send frames.

  • intrinsicsnumber[4]

    [fx, fy, cx, cy] in pixels of the image (fx, fy > 0). Metric models that need the focal length use it; stereo models need it for meters.

  • right_imagestring

    Stereo models: the right image of the rectified pair, the same size as image. With intrinsics and baseline the depth is in meters.

  • baselinenumber

    Stereo models: the distance between the two cameras, in meters (0–10).

  • prompt_depthstring

    Depth-prompted models: a low-resolution depth map of the same view (e.g. from LiDAR) as a 16-bit grayscale PNG in millimetres, 0 for no measurement.

  • framesstring[]

    Video depth models: a clip of 1–16 frames, oldest first, all the same size, under 4 MB of base64 together. Send it instead of image; it can't be combined with right_image, baseline or prompt_depth.

Response

  • idstring

    Unique id of this call, e.g. dep_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.

  • depthobject

    The depth map (for a clip, the last frame's).

    Show 5 child attributes
    • widthinteger

      Map width in pixels.

    • heightinteger

      Map height in pixels.

    • unitstring

      "m": meters. "relative_inverse": unitless inverse depth, larger is closer. "relative": unitless depth, larger is farther, with unknown scale and shift.

    • scalenumber

      Map width ÷ your image's width (1 when the image is 256 pixels or smaller).

    • datanumber[]

      width × height values, row by row from the top-left.

  • framesobject[]

    For a clip: one depth map per frame, oldest first, on one consistent scale.

  • 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

12 live models for /depth. Each page has a ready-made request.