---
name: gpu-setup
description: >
  First-run setup for video-factory GPU infrastructure: detect provider CLIs
  (runpodctl, vastai, modal, prime), install missing ones after asking
  permission, authenticate each provider, and write the provider registry at
  .pi/gpu/providers.json. Use when the user asks to set up GPU access, or when
  providers.json is missing or shows unauthenticated providers.
---

# GPU Cloud Setup (Claude Code)

Goal: end with `.pi/gpu/providers.json` showing every provider the user wants
as `"authenticated": true`. You have no special GPU tools — you are the tool.
The registry is plain JSON; maintain it with `jq` or direct file writes.

## Step 1 — Detect

```bash
for bin in runpodctl vastai modal prime; do command -v $bin >/dev/null 2>&1 && echo "$bin: $(command -v $bin)" || echo "$bin: missing"; done
```

| Provider | CLI | Install if missing (ask first) |
| --- | --- | --- |
| RunPod | runpodctl | `curl -sSL https://github.com/runpod/runpodctl/releases/latest/download/runpodctl-linux-amd64 -o /usr/local/bin/runpodctl && chmod +x /usr/local/bin/runpodctl` |
| Vast.ai | vastai | `pip install -U vastai` |
| Modal | modal | `pip install modal` |
| Prime | prime | `pip install prime` — verify current name at docs.primeintellect.ai |
| Lambda | (none) | API key only → `export LAMBDA_API_KEY=...` |
| Salad | (none) | API key + org + project → `export SALAD_API_KEY SALAD_ORG SALAD_PROJECT` |

If the user has no preference: RunPod + Vast first (managed pods + the
marketplace cover the cheapest 80% of cases).

## Step 2 — Authenticate

- **RunPod:** `runpodctl config --apiKey $RUNPOD_API_KEY` · verify `runpodctl get pods --output json`
- **Vast.ai:** `vastai set api-key $VAST_API_KEY` · verify `vastai show instances`
- **Modal:** `modal token new` (browser) or `modal token set --token-id ... --token-secret ...` · verify `modal profile current`
- **Lambda:** `curl -s https://api.lambdalabs.com/v1/instances -H "Authorization: Bearer $LAMBDA_API_KEY"`
- **Salad:** `test -n "$SALAD_API_KEY" && curl -s https://api.salad.com/api/public/gpu-classes -H "Salad-Api-Key: $SALAD_API_KEY"`
- **Prime:** `prime --help`, then their login flow

Never print full API keys into the chat or files that get committed.

## Step 3 — Write the registry

```json
{
  "id": "vast",
  "name": "Vast.ai",
  "kind": "instance",
  "cli": "vastai",
  "installed": true,
  "cliVersion": "0.3.x",
  "authenticated": true,
  "authHint": null,
  "detectedAt": "<ISO date>"
}
```

Write one entry per detected provider to `.pi/gpu/providers.json` (create the
dir). An authenticated provider is also an authorization to spend money on it —
confirm with the user which providers they want active, and respect the spend
policy in `.pi/gpu/policy.json` (defaults: confirm above $1, per-job ceiling
$5, daily $40, monthly $400 — lower them for a new user).
