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.com

From 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.

CommandDoes
login [--base-url URL] [--key KEY]Store a key from the Developer access page.
whoamiShow the stored base URL and key prefix.
logoutRemove 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 codeMeaning
0Success.
1The API answered with an error. Also run when the job failed, and wait when the event is job.failed.
2Usage 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
FlagDefaultMeaning
--sample [ID]lora when bareRun a sample job instead of an image.
--image, --cmdImage reference and command, split like a shell.
--env NAME=VALUEEnvironment variable; repeatable.
--input URL:PATHHTTPS file mounted at PATH; repeatable.
--output-dir/outputsWhere the job writes outputs.
--gpu-memory GB16Minimum GPU memory (min_vram_gb).
--budget USD2Hard cap on GPU spend for the whole job.
--gpus GPUShortlist: only these GPUs are benchmarked or run; repeatable.
--max-benchmark-gpus N3GPUs to benchmark, 2 or 3.
--wait / --no-waitwait on a terminalStream job steps to stderr until it finishes.
--idempotency-keya new key per callReuse 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#

CommandDoes
samples [ID]List the sample jobs, or print one spec.
gpusList the GPU catalog with listed rates.
prices GPUCompare 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_IDList the measurements behind a route.
route-prices ROUTE_IDCompare prices for a route's spec across providers and tiers.

Benchmarks#

CommandDoes
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 --confirmLaunch the probes. Paid, up to the cap.
benchmark ROUTE_IDShow the results and ranking.

start also takes --max-steps (default 50), --seed, --loss-tolerance-pct and --idempotency-key.

Jobs and runs#

CommandDoes
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_IDList your runs, or show one.
cancel RUN_IDRequest cancellation of a launching or running run.
logs RUN_IDPrint the recorded log tail.
verification RUN_IDShow 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#

CommandDoes
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 IDCheck a connection's credentials again.
disconnect IDRemove 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#

CommandDoes
webhooksList your endpoints.
webhooks add URL [--event TYPE ...] [--format json|slack|discord]Register an endpoint. The signing secret is shown once.
webhooks show IDShow an endpoint.
webhooks test IDSend a webhook.test event.
webhooks deliveries ID [--limit N]List deliveries, newest first.
webhooks retry ID DELIVERY_IDQueue a failed delivery again.
webhooks delete IDRemove an endpoint and its log.

Next steps#

  • Quickstart: a full run with real output.
  • Errors: every code the CLI can print.