# Estimate depth

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

`POST https://api.openrobotics.dev/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

`Authorization: Bearer sk-orb-v1-…`, your [API key](https://www.openrobotics.dev/docs/authentication), or a free [test key](https://www.openrobotics.dev/docs/authentication#test-keys) (`sk-orb-test-…`; no account? get one with [`POST /sandbox/keys`](https://www.openrobotics.dev/docs/api/create-sandbox-key)).

## Request body

JSON, with `Content-Type: application/json`.

- `model` (string, required): The depth model to run, e.g. `bytedance/depth-anything-v2`. The live models for this endpoint are listed below.
- `image` (string, required): The image (the left image of a stereo pair), base64 JPEG or PNG. Under 4 MB of base64. Required unless you send `frames`.
- `intrinsics` (number[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_image` (string): Stereo models: the right image of the rectified pair, the same size as `image`. With `intrinsics` and `baseline` the depth is in meters.
- `baseline` (number): Stereo models: the distance between the two cameras, in meters (0–10).
- `prompt_depth` (string): 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.
- `frames` (string[]): 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

- `id` (string): Unique id of this call, e.g. `dep_48213`. It matches the call in your Activity dashboard.
- `model` (string): The model that answered.
- `backend` (string): `"http"`: the real model ran on a GPU. `"simulated"`: stand-in output of the same shape, as test keys get.
- `sandbox` (boolean): `true` when the call was made with a [test key](https://www.openrobotics.dev/docs/authentication#test-keys): the output is simulated, nothing ran on a GPU and nothing was charged. Absent otherwise.
- `depth` (object): The depth map (for a clip, the last frame's).
  - `width` (integer): Map width in pixels.
  - `height` (integer): Map height in pixels.
  - `unit` (string): `"m"`: meters. `"relative_inverse"`: unitless inverse depth, larger is closer. `"relative"`: unitless depth, larger is farther, with unknown scale and shift.
  - `scale` (number): Map width ÷ your image's width (1 when the image is 256 pixels or smaller).
  - `data` (number[]): `width × height` values, row by row from the top-left.
- `frames` (object[]): For a clip: one depth map per frame, oldest first, on one consistent scale.
- `usage` (object): What the call cost.
  - `cost_usd` (number): Charged to your credits, in US dollars.
  - `latency_ms` (integer): Time the model took, in milliseconds.

## Errors

Plus the errors every endpoint shares: see [Errors](https://www.openrobotics.dev/docs/errors).

## Example request

Python:

```python
import os, requests

res = requests.post(
  "https://api.openrobotics.dev/v1/depth",
  headers={"Authorization": f"Bearer {os.environ['OPENROBOTICS_API_KEY']}"},
  json={
    "model": "bytedance/depth-anything-v2",
    "image": "<base64 JPEG or PNG>",
  },
).json()
res["depth"]["data"]    # row-major depth map
```

TypeScript:

```typescript
const res = await fetch("https://api.openrobotics.dev/v1/depth", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPENROBOTICS_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "bytedance/depth-anything-v2",
    image: "<base64 JPEG or PNG>",
  }),
}).then((r) => r.json());
```

cURL:

```bash
curl https://api.openrobotics.dev/v1/depth \
  -H "Authorization: Bearer $OPENROBOTICS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"bytedance/depth-anything-v2","image":"<base64 JPEG or PNG>"}'
```

## Example response

```json
{
  "id": "dep_48213",
  "model": "bytedance/depth-anything-v2",
  "backend": "http",
  "depth": {
    "width": 256,
    "height": 192,
    "unit": "relative_inverse",
    "scale": 0.4,
    "data": [0.412, 0.415, …]
  },
  "usage": { "cost_usd": 0.00005, "latency_ms": 96 }
}
```

## Models

12 live for `/depth`:

- [Depth Anything V2](https://www.openrobotics.dev/models/bytedance/depth-anything-v2.md): `bytedance/depth-anything-v2`, $0.10 per 1,000 calls
- [Depth Anything 3](https://www.openrobotics.dev/models/bytedance/depth-anything-3.md): `bytedance/depth-anything-3`, $0.10 per 1,000 calls
- [FoundationStereo](https://www.openrobotics.dev/models/nvidia/foundationstereo.md): `nvidia/foundationstereo`, $0.10 per 1,000 calls
- [MoGe-2](https://www.openrobotics.dev/models/microsoft/moge-2.md): `microsoft/moge-2`, $0.10 per 1,000 calls
- [Prompt Depth Anything](https://www.openrobotics.dev/models/bytedance/prompt-depth-anything.md): `bytedance/prompt-depth-anything`, $0.10 per 1,000 calls
- [Video Depth Anything](https://www.openrobotics.dev/models/bytedance/video-depth-anything.md): `bytedance/video-depth-anything`, $0.10 per 1,000 calls
- [Lotus (Depth G v2.1)](https://www.openrobotics.dev/models/hkust-gz/lotus.md): `hkust-gz/lotus`, $0.10 per 1,000 calls
- [Pixel-Perfect Depth](https://www.openrobotics.dev/models/hust/pixel-perfect-depth.md): `hust/pixel-perfect-depth`, $0.10 per 1,000 calls
- [MetricAnything (Student DepthMap)](https://www.openrobotics.dev/models/metric-anything/metricanything.md): `metric-anything/metricanything`, $0.10 per 1,000 calls
- [Fast-FoundationStereo (C-Fast-FoundationStereo)](https://www.openrobotics.dev/models/nvidia/fast-foundationstereo.md): `nvidia/fast-foundationstereo`, $0.10 per 1,000 calls
- [Marigold Depth v1.1](https://www.openrobotics.dev/models/prs-eth/marigold-depth-v1-1.md): `prs-eth/marigold-depth-v1-1`, $0.10 per 1,000 calls
- [Distill Any Depth](https://www.openrobotics.dev/models/westlake/distill-any-depth.md): `westlake/distill-any-depth`, $0.10 per 1,000 calls
