Minimal Python CLI + helpers for the Lambda Cloud API (https://cloud.lambda.ai/api/v1).
Using the workspace venv (recommended):
pip install -r requirements.txtpip install -e .
Set your API key:
export LAMBDA_API_KEY=...
Or put it in a .env file in the project directory:
- create
.envcontainingLAMBDA_API_KEY=...
The CLI will automatically load .env if present. You can also pass a specific file:
lambda-api --dotenv /path/to/.env instances list --json
lambda-api instances list --json
List machine images you can reference in your launch JSON:
lambda-api images list --json
To launch using a specific image, set one of the following in your launch JSON:
- By id:
"image": {"id": "<IMAGE_ID>"} - By family:
"image": {"family": "<IMAGE_FAMILY>"}
Best-effort start time inference:
- Prefer an instance tag containing an ISO8601 start time (default tag key:
started-at). - Optionally fallback to scanning audit events (heuristic).
Example:
lambda-api instances long-running --hours 24 --fail-on-findings --fallback-audit-events
Exit codes:
0: ok (or findings but--fail-on-findingsnot set)1: findings present and--fail-on-findingsset2: error talking to API / config error
From a Discord bot, you can shell out and parse JSON:
- run
lambda-api instances long-running --hours 24 --json - if exit code is
1, post an alert with the returnedlong_runninglist
The Instances API responses shown in the public docs do not include a created/started timestamp. If you need rock-solid “age” tracking, the most reliable approach is to ensure instances are launched with a tag like:
- key:
started-at - value:
2025-12-17T12:34:56Z
This tool will use that tag when present.
Launch a new instance using the Lambda Cloud launch endpoint.
This CLI requires a JSON file containing the request body for POST /instance-operations/launch.
Example launch.json:
{
"region_name": "us-west-2",
"instance_type_name": "gpu_1x_a10",
"ssh_key_names": ["my-ssh-key-name"],
"quantity": 1
}Run:
lambda-api instances launch launch.json --json
Notes:
- The CLI automatically injects a
started-attag at launch time (unless you already provided one). - Output is JSON (success envelope) and suitable for bot parsing.
Terminate an instance by its id:
lambda-api instances shutdown <INSTANCE_ID> --json