# Score task progress

> Send a clip of a robot (or a person) doing a task and get per-frame task progress and success probability from a reward model.

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

Reward models judge how far a clip has got with a task, frame by frame: dense rewards for reinforcement learning, success detection, and filtering or ranking demonstrations. Sample the video at a few frames per second; each model takes up to its own number of frames (Robometer: 8) and refuses more with a `400`.

## 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 reward model to run, e.g. `usc/robometer`. The live models for this endpoint are listed below.
- `instruction` (string, required): The task the clip should be doing, e.g. `"put the green stick in the brown bowl"`. 1–1,000 characters.
- `frames` (string[], required): The clip, oldest first: 1–32 frames, base64 JPEG or PNG, all the same size, under 4 MB of base64 together.

## Response

- `id` (string): Unique id of this call, e.g. `rwd_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.
- `progress` (number[]): One per frame, oldest first: task progress from `0` (not started) to `1` (done).
- `success` (number[]): One per frame: the probability that the task is complete at that frame. Only from models with a success head (Robometer has one).
- `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

- `400`: More frames than the model takes, frames of different sizes, or no instruction.

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/reward",
  headers={"Authorization": f"Bearer {os.environ['OPENROBOTICS_API_KEY']}"},
  json={
    "model": "usc/robometer",
    "instruction": "put the green stick in the brown bowl",
    "frames": ["<base64 JPEG or PNG>", "<base64 JPEG or PNG>", "<base64 JPEG or PNG>", "<base64 JPEG or PNG>"],
  },
).json()
res["progress"], res["success"]  # per frame, 0–1
```

TypeScript:

```typescript
const res = await fetch("https://api.openrobotics.dev/v1/reward", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPENROBOTICS_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "usc/robometer",
    instruction: "put the green stick in the brown bowl",
    frames: ["<base64 JPEG or PNG>", "<base64 JPEG or PNG>", "<base64 JPEG or PNG>", "<base64 JPEG or PNG>"],
  }),
}).then((r) => r.json());
```

cURL:

```bash
curl https://api.openrobotics.dev/v1/reward \
  -H "Authorization: Bearer $OPENROBOTICS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"usc/robometer","instruction":"put the green stick in the brown bowl","frames":["<base64 JPEG or PNG>","<base64 JPEG or PNG>","<base64 JPEG or PNG>","<base64 JPEG or PNG>"]}'
```

## Example response

```json
{
  "id": "rwd_48213",
  "model": "usc/robometer",
  "backend": "http",
  "progress": [0.04, 0.31, 0.68, 0.97],
  "success": [0.01, 0.03, 0.22, 0.94],
  "usage": { "cost_usd": 0.0005, "latency_ms": 400 }
}
```

## Models

1 live for `/reward`:

- [Robometer](https://www.openrobotics.dev/models/usc/robometer.md): `usc/robometer`, $0.50 per 1,000 calls
