Command reference
Every legion command grouped by task, with a link to the full flags of each.
Every command has --help with examples. The full reference on GitHub (opens in a new tab) lists every flag. Nouns are singular, with plural aliases, so legion rentals list works.
All commands accept the global flags -o, -p, -q, -y, --api-url, --no-color, --timeout and --debug. See Scripting and automation.
Getting started
| Command | What it does |
|---|---|
legion auth login | Signs you in through the browser and saves an API key. logout removes it, and status shows who you are. |
legion whoami | Shows the user and organization you are logged in as. |
legion offer list | Lists hosts with free GPUs, cheapest first. Filter by GPU model, count, price, country or region. |
legion offer get | Shows one offer. |
legion catalog list | Lists the starter images and premade models. get shows one. |
legion ssh <rental> | Connects to a rental. A shortcut for legion rental ssh. |
Rentals
| Command | What it does |
|---|---|
legion rental create | Rents GPUs and starts a container, after a preview. --env NAME=value and --secret-env NAME (repeatable) set environment variables, --setting key=value a premade model's settings, and --command and --arg the command of your own image. See Configuration. |
legion rental list / get | Lists your rentals or shows one. |
legion rental stop / start | Stops a rental and keeps its workspace, or starts it again. |
legion rental delete | Deletes a rental and destroys its workspace. |
legion rental wait | Waits until a rental is running or stopped. |
legion rental ssh / ssh-config | Connects, or prints an ~/ block so ssh, scp and rsync work. |
legion rental charges | Shows what one rental has cost. |
legion rental serve | Shows the Service URL and service key of a premade model rental. |
legion rental backup . | Estimates, creates, lists, gets, cancels and deletes backups, and makes download links. |
legion rental export . | Creates, lists, gets and cancels workspace exports. |
Services
A service is a public URL for something you run on Legion: a port on one of your rentals, or a model that Legion runs on rented GPUs and scales with traffic. One command group does everything, including exposing a port: legion services, shortened to legion svc. There is no separate legion ports. Commands that create, resume or change spend, and the ones that delete or revoke, ask first, and need --yes in a script.
| Command | What it does |
|---|---|
legion services list | Lists your services with their mode, scaling, status and Service URL. --rental NAME filters; -o wide adds ids and spend. |
legion services get | Shows one service: Service URL, access, status, hardware, replicas and spend. |
legion services create | Creates a service. On a rental: --rental NAME --port 8080 --access keys, with --access public (the default for a port) or keys (the default for a model) and --source CIDR to limit callers. Autoscaled: --catalog or --image --port, optional --gpu MODEL (repeatable, an allow-list: by default Legion picks the cheapest hardware that fits), optional --max-price (total per replica-hour), --monthly-cap (required) and --ack-host-visibility; for your own image --min-gpu-memory and --gpu-counts. It shows the likely hardware and the cost, then asks. |
legion services update | Changes only what you name: --min, --max, --scale-to-zero, --target-concurrency, --gpu (the allow-list), --max-price, --monthly-cap, --spot, --placement, --access public\|keys, --source, or the model with --catalog or --image. --revision refuses the change if the service was edited meanwhile. |
legion services autoscale on | Turns a service on a rental into an autoscaled one. --monthly-cap is required; --keep-rental (the default) or --replace says what happens to the rental. |
legion services autoscale off | Back to one rental: --keep-replica NAME is the replica to keep. |
legion services pause / resume | Stops serving and bills no GPU time, or starts again. |
legion services delete | Deletes a service and its keys. For a service on a rental the rental is untouched. On a terminal you type its name. Deleting an autoscaled service needs a fresh sign-in, which only a browser session gives. |
legion services replicas | Lists the replicas, live and warm. --all adds those retired in the last 7 days. |
legion services usage | Shows usage per day and this month's spend against the cap. --days sets the range and --window 1h\|24h\|7d the traffic window of the request points in -o json. |
legion services events | Shows scaling steps, changes and key activity. --limit sets how many. |
legion services keys list | Lists service keys with prefix, status, expiry and last use. A key marked legacy is a direct key from before services. |
legion services keys create | Makes a service key, shown once. --name, --expires 7d\|30d\|90d\|365d\|never, --rate-limit. -o name prints only the secret. |
legion services keys rotate | Makes a new key and keeps the old one for --overlap-hours (24 by default). |
legion services keys revoke | Revokes a key now. |
legion services create and legion services update also take --env NAME=value, --secret-env NAME, --setting key=value, --command and --arg for an autoscaled service. A secret's value comes from standard input or a hidden prompt, never from an argument, and changing them rolls the replicas. See Configuration.
The same service keys serve every service, whatever its mode, and are managed with legion services keys.
Registry credentials
| Command | What it does |
|---|---|
legion registry add | Saves a username and a read-only token for the registry of --image, after checking they can read it. --name names it, --path-prefix sets which images use it. |
legion registry list | Lists your organization's credentials: name, host, prefix, username, last used. Never a token. |
legion registry replace <id> | Replaces a credential's token (--image, --token-stdin, optionally --username), or renames it (--name). |
legion registry remove <id> | Removes a credential, after confirming. Refused while rentals still use it, and it names them. |
The token is read from a hidden prompt or from standard input with --token-stdin. It is never a flag, so it stays out of your shell history:
echo "$TOKEN" | legion registry add --image ghcr.io/acme/model:v3 --username acme-bot --token-stdinAdding, replacing and removing need the registry. permission, which owners have. legion rental create --registry-credential <id> uses a credential other than the one matched to the image. See Private images.
Account
| Command | What it does |
|---|---|
legion billing balance | Shows your prepaid balance. |
legion billing charges / activity / ledger | Shows charges per rental, usage sessions, and balance changes. |
legion ssh-key list / add / remove | Manages the SSH public keys you rent with. |
legion api-key list / create / revoke | Manages API keys. |
Settings and tools
| Command | What it does |
|---|---|
legion profile list / create / use / delete | Manages named profiles. |
legion config get / set | Reads or changes a setting of the current profile. |
legion completion bash\|zsh\|fish\|powershell | Prints a shell completion script. |
legion version | Prints the version. |
legion help environment / exit-codes | Explains settings and exit codes. |