# Plan grasps

> Send a point cloud and get ranked gripper poses for picking up what's in it.

`POST https://api.openrobotics.dev/v1/grasp`

## 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 grasp model to run. The models for this endpoint are listed below.
- `points` (number[][], required): The point cloud: 3–20,000 `[x, y, z]` points in meters, in the camera or robot frame.
- `top_k` (integer): How many grasps to return, 1–50.
- `gripper` (string | object): Gripper-conditioned models (GraspGen-X): a gripper the model knows by name (e.g. `franka_panda`, `robotiq_2f_85`), or any gripper's sweep volumes `{ extents_open, offset_open, extents_mid, offset_mid }`, each `[x, y, z]` in meters in the gripper frame (z = approach, x = closing).
- `seed` (integer): Sampling models: the same seed and request give the same grasps.

## Response

- `id` (string): Unique id of this call, e.g. `grp_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.
- `grasps` (object[]): Best first, in the frame of your points.
  - `position` (number[3]): `[x, y, z]` in meters.
  - `rotation` (number[4]): Quaternion `[qx, qy, qz, qw]`.
  - `width` (number): Gripper opening, in meters.
  - `score` (number): Quality, 0–1.
- `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/grasp",
  headers={"Authorization": f"Bearer {os.environ['OPENROBOTICS_API_KEY']}"},
  json={
    "model": "<grasp model id>",
    "points": [[0.41, -0.02, 0.13], [0.42, -0.01, 0.13], "…"],
    "top_k": 5,
  },
).json()
res["grasps"]          # position, rotation, width, score
```

TypeScript:

```typescript
const res = await fetch("https://api.openrobotics.dev/v1/grasp", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPENROBOTICS_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "<grasp model id>",
    points: [[0.41, -0.02, 0.13], [0.42, -0.01, 0.13], "…"],
    top_k: 5,
  }),
}).then((r) => r.json());
```

cURL:

```bash
curl https://api.openrobotics.dev/v1/grasp \
  -H "Authorization: Bearer $OPENROBOTICS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"<grasp model id>","points":[[0.41,-0.02,0.13],[0.42,-0.01,0.13],"…"],"top_k":5}'
```

## Example response

```json
{
  "id": "grp_48213",
  "model": "<grasp model id>",
  "backend": "http",
  "grasps": [
    {
      "position": [0.42, -0.01, 0.16],
      "rotation": [0, 1, 0, 0],
      "width": 0.06,
      "score": 0.88
    }
  ],
  "usage": { "cost_usd": 0.0002, "latency_ms": 220 }
}
```

## Models

1 live for `/grasp`:

- [GraspGen-X](https://www.openrobotics.dev/models/nvidia/graspgen-x.md): `nvidia/graspgen-x`, $0.10 per 1,000 calls
