Metadata-Version: 2.5
Name: openrobotics-sdk
Version: 0.1.0
Summary: Python client and CLI for the OpenRobotics API: robot policies, world models, perception and vision encoders behind one key
Project-URL: Homepage, https://www.openrobotics.dev
Project-URL: Documentation, https://www.openrobotics.dev/docs
Author: OpenRobotics
License-Expression: MIT
License-File: LICENSE
Keywords: api,inference,perception,robotics,vla,world-models
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx<1,>=0.24
Provides-Extra: images
Requires-Dist: numpy>=1.21; extra == 'images'
Requires-Dist: pillow>=9; extra == 'images'
Description-Content-Type: text/markdown

# openrobotics

Python client and CLI for the [OpenRobotics API](https://www.openrobotics.dev/docs): robot policies (VLAs),
world models, perception and vision encoders behind one key.

```bash
pip install openrobotics-sdk            # or: uv add openrobotics-sdk
pip install "openrobotics-sdk[images]"  # also pass PIL images and numpy arrays
```

Python 3.9+. The only dependency is `httpx`.

## Quickstart

```bash
openrobotics login          # opens your browser, saves a key to ~/.config/openrobotics/credentials.json
openrobotics models --endpoint act --live
```

```python
from openrobotics import OpenRobotics

client = OpenRobotics()  # $OPENROBOTICS_API_KEY, else the key saved by `openrobotics login`

out = client.act(
    "physical-intelligence/pi0",
    instruction="put the black bowl on the plate",
    observation={"image": "agentview.jpg", "state": [0.1, 0.2, 0.3, 0, 0, 0, 0.04]},
)
print(out["actions"][0], out["usage"])
```

Every endpoint is a method taking the model id first, then the fields from the
[API reference](https://www.openrobotics.dev/docs/api); extra fields go through as keyword arguments:

| Method | Endpoint |
| --- | --- |
| `act(model, instruction, observation)` | robot actions from a VLA |
| `embed(model, image)` / `embed(model, frames=[…])` | vision-encoder embedding |
| `depth(model, image)` | depth map (stereo: `right_image=`, `intrinsics=`, `baseline=`) |
| `segment(model, image, points=/boxes=/text=)` | masks |
| `detect(model, image, labels)` | open-vocabulary boxes |
| `track(model, frames, points)` | point tracks |
| `pose(model, image, object=…)` | 6D object poses |
| `grasp(model, points)` | grasps from a point cloud |
| `hands(model, image)` | hand keypoints |
| `reconstruct(model, images)` | cameras + point cloud |
| `reason(model, prompt, image)` | embodied reasoning |
| `reward(model, instruction, frames)` | per-frame progress |
| `predict(model, prompt, image=…, wait=True)` | world-model job (video or latents) |

Plus `client.key()`, `client.models.list(endpoint="act", status="live")`, `client.models.get(id)`,
`client.jobs.get(id)`, `client.jobs.wait(id, poll=2)` and `client.jobs.download(id, "video.mp4", path)`.

### Images

Anywhere the API wants a base64 JPEG/PNG (`image`, `frames`, `images`, `observation.images`, `depth`, …)
you can pass a file path, `bytes`, a PIL `Image`, a numpy array (uint8, float 0–1, or uint16 for depth
PNGs) or a base64 string. `openrobotics.to_base64(x)` does the conversion on its own.

### World-model jobs

```python
job = client.predict("nvidia/cosmos-predict-2.5", prompt="the robot opens the drawer", image="first.jpg")
job = client.jobs.wait(job, on_progress=lambda j: print(j["status"], j["progress"]))
client.jobs.download(job, "video.mp4", "out/video.mp4")
```

### Cold starts, retries and errors

GPUs boot on demand: the first call to an idle model gets `503 model_warming` with `Retry-After` for a
few minutes. The client waits and retries on its own (up to `max_warm_wait`, 15 minutes by default),
logging to the `openrobotics` logger and calling `on_retry` if you pass one. `429` and `5xx` responses
and connection errors are retried `max_retries` times (default 2) with backoff.

```python
from openrobotics import OpenRobotics, InsufficientCreditsError, ModelWarmingError

client = OpenRobotics(timeout=60, max_retries=3, max_warm_wait=300, on_retry=lambda e: print(f"{e.reason}: retrying in {e.wait:.0f}s"))
try:
    client.depth("bytedance/depth-anything-v2", "kitchen.jpg")
except InsufficientCreditsError:
    print("Add credits at https://www.openrobotics.dev/billing")
except ModelWarmingError:
    print("Still warming up; try again in a minute")
```

Errors map from the API's `error.type`: `AuthenticationError` (401), `InsufficientCreditsError` (402),
`PermissionDeniedError` (403), `NotFoundError` (404), `InvalidRequestError` (400), `RateLimitError`
(429), `ModelWarmingError` / `ServerError` (5xx), all subclasses of `APIError` with `.status`, `.type`,
`.message` and `.docs_url`. `APIConnectionError` and `APITimeoutError` mean no response arrived.

### Async

```python
import asyncio
from openrobotics import AsyncOpenRobotics


async def main():
    async with AsyncOpenRobotics() as client:
        out = await client.embed("google/siglip2-so400m", "frame.jpg")
        print(out["dim"])


asyncio.run(main())
```

### Sandbox keys

`openrobotics login --test` creates a sandbox key (`sk-orb-test-…`): calls are free, the output is
simulated, and responses carry `"sandbox": true`. `client.sandbox` tells you which kind is in use.

## CLI

```text
openrobotics login [--test] [--no-browser]   sign in with your browser, save a key
openrobotics logout                          forget the saved key
openrobotics whoami                          the key in use (GET /v1/key)
openrobotics models [--endpoint act] [--live] [--type …] [--provider …] [-q …] [--json]
openrobotics call <endpoint> --model <id> --json body.json   (or --json - for stdin, or inline JSON)
openrobotics call predict --model <id> --json body.json --wait
```

Image fields in a `call` body may be file paths (relative to the current directory).

## Configuration

| Setting | Argument | Environment | Default |
| --- | --- | --- | --- |
| API key | `api_key=` / `--api-key` | `OPENROBOTICS_API_KEY` | saved login |
| API URL | `base_url=` / `--base-url` | `OPENROBOTICS_BASE_URL` | `https://api.openrobotics.dev/v1` |
| Login site | `--web-url` | `OPENROBOTICS_WEB_URL` | `https://www.openrobotics.dev` |

The saved login lives in `$XDG_CONFIG_HOME/openrobotics/credentials.json` (default `~/.config/…`),
readable only by you (0600).
