> ## Documentation Index
> Fetch the complete documentation index at: https://www.latitude.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples

### Create a server

```shell theme={null}
lsh servers create --operating_system ubuntu_22_04_x64_lts --project <PROJECT_ID_OR_SLUG> --site <LOCATION> --hostname <HOSTNAME> --plan <PLAN>
```

### Assign the created server to a virtual network

```shell theme={null}
# Create a virtual network in the same location
lsh virtual_networks create --description <DESCRIPTION> --project <PROJECT> --site <LOCATION>

# Find the virtual network if you don't have the id
lsh virtual_networks list --location <LOCATION>

# Find the server if you don't have the id
lsh servers list --hostname <HOSTNAME>

# Assign the server with the server_id and virtual_network_id created
lsh virtual_networks assignments create --virtual_network_id <VIRTUAL_NETWORK_ID> --server_id <SERVER_ID>
```

### List all GPU plans

```shell theme={null}
lsh plans list --gpu true
```

### Check plan availability per location

`lsh plans stock` flattens the `/plans` API response into one row per plan × location, so you can see exactly where each plan has stock right now.

```shell theme={null}
lsh plans stock
```

Show only locations that currently have stock:

```shell theme={null}
lsh plans stock --in_stock
```

Filter by region and export as CSV:

```shell theme={null}
lsh plans stock --region "United States" --in_stock --format csv > us_plans.csv
```

Combine filters and pipe to `jq` (use `--format json` when piping — the default table format requires an interactive terminal):

```shell theme={null}
lsh plans stock --gpu --ram_gte 64 --format json | jq '.[] | {plan: .plan_slug, loc: .location, stock: .stock_level}'
```

**Available filters:** `--region`, `--location` (alias `--site`), `--name`, `--slug`, `--gpu`, `--in_stock` (alias `--available`), `--stock_level` (`Unavailable`, `Low`, `Medium`, `High`, `Unique`), `--ram_eql` / `--ram_gte` / `--ram_lte`, `--disk_eql` / `--disk_gte` / `--disk_lte`. **Output formats:** `--format table|csv|json`.

**How `stock_level` is derived per location**

The `/plans` API reports `stock_level` at the **region** level, plus two location lists:

* `locations.available` — where the plan can be deployed at all
* `locations.in_stock` — where there is inventory right now

Each row emitted by `plans stock` gets its `stock_level` resolved per location:

* if the location is in `in_stock` → it inherits the region's `stock_level`
* otherwise → `unavailable`

For example, if `c3-large-x86` reports `stock_level: high` in **United States** with `available: [DAL, LAX, NYC, CHI, ASH, MIA2, LAX2, SJC2, ASH2]` and `in_stock: [LAX, NYC, CHI, MIA2]`, the CLI outputs `high` for LAX/NYC/CHI/MIA2 and `unavailable` for the other five — so you never assume a location has stock just because the region does.

### Create an on-demand project

```shell theme={null}
lsh projects create --description <DESCRIPTION> --name <NAME> --provisioning_type on_demand
```

### Setting the output as a JSON

It is possible to render JSON if you want to see different fields or even parse the data using a JSON processor like [jq](https://jqlang.github.io/jq/). To format the output to JSON, you must pass `-o json` or `—-json`.

**Example**

```shell theme={null}
lsh servers list -o json

# or

lsh servers list --json

```
