Integrate
CLI
The gpu-router command line: the same API the dashboard uses, with a readable summary or raw JSON.
Install and log in#
uvx --from git+https://github.com/sofiabod/gpu-router.git gpu-router login --base-url https://gpu-router.comFrom a checkout, uvx --from /path/to/gpu-router gpu-router or python -m api.cli work the same.
login prompts for the key without echo (or takes --key), checks it against the server, and stores the base URL and key in ~/.config/gpu-router/config.json with mode 0600. --base-url defaults to http://localhost:8000.
| Command | Does |
|---|---|
login [--base-url URL] [--key KEY] | Store a key from the Developer access page. |
whoami | Show the stored base URL and key prefix. |
logout | Remove the stored key. |
JSON output and exit codes#
--json works on every command, before or after the command name. It prints the API response as JSON; on an error it prints the error envelope to stderr.
gpu-router --json jobs
gpu-router jobs $JOB_ID --json| Exit code | Meaning |
|---|---|
0 | Success. |
1 | The API answered with an error. Also run when the job failed, and wait when the event is job.failed. |
2 | Usage error, not logged in, or the server could not be reached. |
Without --json, an API error prints CODE: message and one indented line per validation detail.
Run a job#
gpu-router run --sample --budget 1
gpu-router run --image ghcr.io/you/train:1 --cmd "python train.py --epochs 1" \
--env HF_TOKEN=hf_... --input https://example.com/data.jsonl:/data/data.jsonl \
--gpu-memory 24 --budget 5| Flag | Default | Meaning |
|---|---|---|
--sample [ID] | lora when bare | Run a sample job instead of an image. |
--image, --cmd | Image reference and command, split like a shell. | |
--env NAME=VALUE | Environment variable; repeatable. | |
--input URL:PATH | HTTPS file mounted at PATH; repeatable. | |
--output-dir | /outputs | Where the job writes outputs. |
--gpu-memory GB | 16 | Minimum GPU memory (min_vram_gb). |
--budget USD | 2 | Hard cap on GPU spend for the whole job. |
--gpus GPU | Shortlist: only these GPUs are benchmarked or run; repeatable. | |
--max-benchmark-gpus N | 3 | GPUs to benchmark, 2 or 3. |
--wait / --no-wait | wait on a terminal | Stream job steps to stderr until it finishes. |
--idempotency-key | a new key per call | Reuse a key to retry without a second launch. |
Custom jobs are sent with 2 CPU cores, 8 GB of memory, a 1800 second timeout and workload_class custom. For other values, route a full JobSpec file with gpu-router route spec.json.
Commands#
Routes and prices#
| Command | Does |
|---|---|
samples [ID] | List the sample jobs, or print one spec. |
gpus | List the GPU catalog with listed rates. |
prices GPU | Compare one GPU's prices across providers and tiers. |
route SPEC.json | --sample [ID] [--gpu GPU] | Route a job spec. Nothing is launched. |
routes [ID] [--limit N] [--offset N] | List your routes, or show one. |
evidence ROUTE_ID | List the measurements behind a route. |
route-prices ROUTE_ID | Compare prices for a route's spec across providers and tiers. |
Benchmarks#
| Command | Does |
|---|---|
benchmark quote ROUTE_ID --gpu A --gpu B --max-seconds N [--runs-per-gpu N] | Show the hard cap. Free. |
benchmark start ROUTE_ID --gpu A --gpu B --max-seconds N --max-cost-usd USD --confirm | Launch the probes. Paid, up to the cap. |
benchmark ROUTE_ID | Show the results and ranking. |
start also takes --max-steps (default 50), --seed, --loss-tolerance-pct and --idempotency-key.
Jobs and runs#
| Command | Does |
|---|---|
run ... | Route, benchmark, pick the cheapest GPU and run. Paid. |
run ROUTE_ID [--gpu GPU], launch ROUTE_ID [--gpu GPU] | Launch a route as one run. Paid. |
jobs [ID] | List your jobs, or show one. |
wait JOB_ID [--timeout SECONDS] | Wait until the job is done or failed and print its event. |
runs [ID], status RUN_ID | List your runs, or show one. |
cancel RUN_ID | Request cancellation of a launching or running run. |
logs RUN_ID | Print the recorded log tail. |
verification RUN_ID | Show the per-check verification report. |
outputs RUN_ID [--get PATH] [-o FILE] | List output files, or download one. |
measurements [--limit N] | List your measured runs with cost and estimate. |
Connections#
| Command | Does |
|---|---|
connect PROVIDER --credential NAME=VALUE ... | Connect a provider: modal, runpod, lambda, vast, nebius, nationalcompute or ghcr. |
connections [ID] | List your connections, or show one. |
recheck ID | Check a connection's credentials again. |
disconnect ID | Remove a connection. |
Modal needs token_id and token_secret. Only Modal launches runs. RunPod, Lambda, Vast.ai and Nebius connections are checked and stored but cannot run a job yet; nationalcompute reads your auction prices and ghcr pulls private images.
Webhooks#
| Command | Does |
|---|---|
webhooks | List your endpoints. |
webhooks add URL [--event TYPE ...] [--format json|slack|discord] | Register an endpoint. The signing secret is shown once. |
webhooks show ID | Show an endpoint. |
webhooks test ID | Send a webhook.test event. |
webhooks deliveries ID [--limit N] | List deliveries, newest first. |
webhooks retry ID DELIVERY_ID | Queue a failed delivery again. |
webhooks delete ID | Remove an endpoint and its log. |
Next steps#
- Quickstart: a full run with real output.
- Errors: every code the CLI can print.