Runnable Python and CLI examples for Lightning AI automation.
Quick start • SDK tutorials • CLI tutorials • Running examples
Each SDK tutorial has two parts:
- an executable
.pyfile that can be run against a Lightning AI account - a paired
.rstguide that explains the workflow and keeps code snippets close to the runnable source
CLI tutorials use separate *_cli.rst files so shell workflows stay distinct
from Python automation.
Build on Lightning AI, the platform for training, deploying, and scaling AI applications with managed compute, collaborative studios, and production endpoints.
Install the SDK and authenticate:
pip install lightning-sdk
lightning loginMost examples need a Lightning AI teamspace. In docs and code snippets,
owner/teamspace means the owner and teamspace name visible in Lightning AI.
Replace placeholder names such as sdk-tutorial-studio with resources you can
create or access.
Sandbox examples can also use a sandbox-scoped API key:
export LIGHTNING_SANDBOX_API_KEY="..."| Tutorial | Runnable file | What it shows |
|---|---|---|
studios.rst |
studios.py |
Create, start, use, stop, and delete persistent studio workspaces |
jobs.rst |
jobs.py |
Submit container-backed and studio-backed jobs, wait for completion, inspect status |
mmts.rst |
mmts.py |
Run and inspect multi-machine training jobs |
teamspaces.rst |
teamspaces.py |
Resolve account context and inspect teamspace resources |
sandboxes.rst |
sandboxes.py |
Create disposable or persistent sandboxes, run commands, write files, resume, and delete |
| Tutorial | What it shows |
|---|---|
studios_cli.rst |
Create, start, connect to, copy files into, and stop studios from the CLI |
jobs_cli.rst |
Submit, inspect, list, stop, and delete jobs from the CLI |
mmts_cli.rst |
Launch and inspect multi-machine training runs from the CLI |
teamspaces_cli.rst |
Set CLI context and pass explicit teamspace scope to resource commands |
sandboxes_cli.rst |
Create sandboxes, run commands, inspect logs, stop, resume, and delete from the CLI |
api_cli.rst |
Call authenticated Lightning API endpoints directly from shell scripts |
Run SDK examples from this directory after authentication:
python sandboxes.py --teamspace owner/teamspace create
python jobs.py --teamspace my-teamspace --org my-org imageRun CLI examples from any directory:
lightning studio list --teamspace owner/teamspace
lightning deployment list --teamspace owner/teamspaceUse environment variables or CLI flags for secrets. Do not commit API keys, tokens, private keys, or downloaded credentials into example files.