lightning-sdk 2026.9.18.post1


pip install lightning-sdk

  Latest version

Released: Sep 18, 2026


Meta
Author: Lightning-AI
Requires Python: >=3.11

Classifiers

Programming Language
  • Python :: 3

Lightning SDK for Python

Automate Lightning AI resources from Python scripts, notebooks, and CI.


Quick start • Examples • CLI • Development • Docs

PyPI Python License

Why Lightning SDK?

Lightning SDK turns Lightning AI into a Python API. Use it to create and manage compute, run training or batch jobs, operate persistent studios, deploy containers, inspect logs, and manage sandboxes without leaving your code.

It is designed for automation first: scripts can resolve teamspace scope, start machines, wait for work to finish, collect output, and tear resources down in the same flow.

Build on Lightning AI, the platform for training, deploying, and scaling AI applications with managed compute, collaborative studios, and production endpoints.

Quick start

Install the package:

pip install lightning-sdk

Authenticate once:

lightning login

Or export credentials from Lightning AI account settings:

export LIGHTNING_API_KEY="..."

Run a sandbox command:

from lightning_sdk.sandbox import Sandbox

sandbox = Sandbox.create(name="python-readme", instance_type="cpu-1")
command = sandbox.run_command("python --version")
print(command.output)
sandbox.delete()

Sandbox-only API keys can also be set with LIGHTNING_SANDBOX_API_KEY or passed through Sandbox.configure(...).

Examples

Work with a studio

from lightning_sdk import Machine, Studio

studio = Studio("research", teamspace="owner/teamspace", create_ok=True)
studio.start(Machine.CPU)

print(studio.status)
print(studio.run("python --version"))

studio.stop()

Run a container job

from lightning_sdk import Job, Machine

job = Job.run(
    name="batch-job",
    teamspace="owner/teamspace",
    image="python:3.11-slim",
    machine=Machine.CPU,
    command="python -c 'print(\"hello from a Lightning job\")'",
    interruptible=True,
)

job.wait()
print(job.status)

Deploy a container

from lightning_sdk import Deployment, Machine
from lightning_sdk.api.deployment_api import ApiKeyAuth

deployment = Deployment("nginx-demo", teamspace="owner/teamspace")
deployment.start(
    image="nginx:latest",
    machine=Machine.CPU,
    ports=80,
    replicas=1,
    auth=ApiKeyAuth(),
)

print(deployment.status)

Start sandboxes warm

A warm recipe says what the sandbox should already have done — packages installed, a server listening. Lightning runs it once, snapshots the result, and restores later sandboxes with the same recipe from that snapshot. The recipe is the cache key, so there is no template id to keep in sync.

from lightning_sdk.sandbox import Sandbox, WarmRecipe, wait_for_port

sandbox = Sandbox.create(
    name="warm-notebook",
    instance_type="cpu-2",
    image="docker.io/library/python:3.13",
    ports=[8888],
    warm=WarmRecipe(
        run_cmd=["pip install jupyterlab"],
        start_cmd="jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root",
        ready_cmd=wait_for_port(8888),
    ),
)

print(sandbox.warm.state)  # "restored" | "building" | "cold"

The first create for a recipe is served cold with the recipe run inline, so you always get the sandbox you asked for — it is only slower. Baking happens in the background once a recipe has been asked for more than once. A cold start looks exactly like a warm one from the outside, so read sandbox.warm.state rather than assuming, and see examples/warm_sandbox.py for per-sandbox credentials and warming a Jupyter kernel.

Use persistent sandboxes

from lightning_sdk.sandbox import Sandbox

sandbox = Sandbox.create(
    name="persistent-devbox",
    instance_type="cpu-1",
    persistent=True,
)

sandbox.write_file("/workspace/app.py", "print('hello from a file')\n")
print(sandbox.run_command("python /workspace/app.py").output)

snapshot_id = sandbox.stop()
print(snapshot_id)

CLI

The package installs lightning, lightning-sdk, and sandbox commands. The examples below use lightning, but the SDK-specific entrypoint accepts the same arguments.

lightning deployment create nginx-demo \
  --teamspace owner/teamspace \
  --image nginx:latest \
  --machine CPU \
  --port 80 \
  --replicas 1 \
  --api-key-auth

Inspect and stream logs:

lightning deployment inspect nginx-demo --teamspace owner/teamspace --jobs
lightning deployment logs nginx-demo --teamspace owner/teamspace --follow

Delete when finished:

lightning deployment delete nginx-demo --teamspace owner/teamspace --yes

More examples

Runnable examples live in examples/:

Area SDK tutorial CLI tutorial
studios studios.rst studios_cli.rst
jobs jobs.rst jobs_cli.rst
multi-machine training mmts.rst mmts_cli.rst
teamspaces teamspaces.rst teamspaces_cli.rst
sandboxes sandboxes.rst sandboxes_cli.rst

Development

From the repository root:

pip install -e ./python

From this directory:

pip install -e .

Build docs from the repository root:

uv run --group docs sphinx-build -M html python/docs/sdk python/docs/sdk/build -W --keep-going
uv run --group docs sphinx-build -M html python/docs/cli python/docs/cli/build -W --keep-going

License

Apache-2.0. See ../LICENSE.

2026.9.18.post1 Sep 18, 2026
2026.9.18 Sep 18, 2026
2026.9.15 Sep 15, 2026
2026.9.3 Sep 03, 2026
2026.9.2 Sep 02, 2026
2026.8.26 Aug 26, 2026
2026.8.18 Aug 18, 2026
2026.8.14 Aug 14, 2026
2026.8.5 Aug 05, 2026
2026.7.31 Jul 31, 2026
2026.7.22 Jul 22, 2026
2026.7.21.post0 Jul 21, 2026
2026.7.21 Jul 21, 2026
2026.7.9.post0 Jul 09, 2026
2026.7.9 Jul 09, 2026
2026.7.8 Jul 08, 2026
2026.7.7.post1 Jul 07, 2026
2026.7.3 Jul 03, 2026
2026.7.2 Jul 02, 2026
2026.6.30 Jun 30, 2026
2026.6.25.post0 Jun 25, 2026
2026.6.8.post0 Jun 09, 2026
2026.6.8 Jun 08, 2026
2026.6.5 Jun 05, 2026
2026.5.21 May 21, 2026
2026.5.15.post0 May 15, 2026
2026.5.15 May 15, 2026
2026.5.12 May 12, 2026
2026.5.6.post2 May 06, 2026
2026.5.6.post1 May 06, 2026
2026.5.6.post0 May 06, 2026
2026.5.6 May 06, 2026
2026.5.5 May 06, 2026
2026.4.23 Apr 23, 2026
2026.4.16 Apr 16, 2026
2026.4.14 Apr 14, 2026
2026.4.10 Apr 10, 2026
2026.4.9 Apr 09, 2026
2026.3.31 Mar 31, 2026
2026.3.17.post0 Mar 17, 2026
2026.3.17 Mar 17, 2026
2026.3.3 Mar 03, 2026
2026.2.6 Feb 06, 2026
2026.2.4.post0 Feb 04, 2026
2026.2.3 Feb 03, 2026
2026.1.30 Feb 02, 2026
2026.1.27 Jan 27, 2026
2026.1.22 Jan 22, 2026
2025.12.17 Dec 18, 2025
2025.12.16 Dec 16, 2025
2025.12.9 Dec 09, 2025
2025.12.5 Dec 05, 2025
2025.12.2 Dec 02, 2025
2025.12.1 Dec 01, 2025
2025.11.24 Nov 24, 2025
2025.11.21 Nov 24, 2025
2025.11.13.post0 Nov 13, 2025
2025.11.13 Nov 13, 2025
2025.11.5 Nov 05, 2025
2025.10.31 Oct 31, 2025
2025.10.27 Oct 27, 2025
2025.10.23 Oct 23, 2025
2025.10.22 Oct 22, 2025
2025.10.14 Oct 14, 2025
2025.10.8 Oct 08, 2025
2025.9.30 Sep 30, 2025
2025.9.29 Sep 29, 2025
2025.9.23 Sep 23, 2025
2025.9.16 Sep 16, 2025
2025.9.11 Sep 11, 2025
2025.9.10 Sep 10, 2025
2025.9.4 Sep 04, 2025
2025.9.2 Sep 02, 2025
2025.8.28 Aug 28, 2025
2025.8.26 Aug 26, 2025
2025.8.21 Aug 21, 2025
2025.8.19.post0 Aug 19, 2025
2025.8.18.post0 Aug 19, 2025
2025.8.18 Aug 19, 2025
2025.8.14.post0 Aug 14, 2025
2025.8.14 Aug 14, 2025
2025.8.8.post1 Aug 08, 2025
2025.8.8 Aug 08, 2025
2025.8.7 Aug 07, 2025
2025.8.6rc2 Aug 06, 2025
2025.8.6rc1 Aug 06, 2025
2025.8.6rc0 Aug 06, 2025
2025.8.1 Aug 01, 2025
2025.7.31 Jul 31, 2025
2025.7.30rc0 Jul 30, 2025
2025.7.22 Jul 22, 2025
2025.7.17 Jul 17, 2025
2025.7.10 Jul 11, 2025
2025.7.9 Jul 09, 2025
0.2.24rc1 Jul 09, 2025
0.2.24rc0 Jul 03, 2025
0.2.23 Jun 25, 2025
0.2.22 Jun 17, 2025
0.2.21 Jun 17, 2025
0.2.21rc1 Jun 16, 2025
0.2.21rc0 Jun 13, 2025
0.2.20 Jun 06, 2025
0.2.19 Jun 04, 2025
0.2.18 May 28, 2025
0.2.17 May 28, 2025
0.2.16 May 22, 2025
0.2.15 May 13, 2025
0.2.14 May 01, 2025
0.2.13 Apr 30, 2025
0.2.12 Apr 24, 2025
0.2.11 Apr 17, 2025
0.2.10 Apr 17, 2025
0.2.9 Apr 07, 2025
0.2.8 Apr 01, 2025
0.2.7 Mar 28, 2025
0.2.6 Mar 26, 2025
0.2.5 Mar 19, 2025
0.2.4 Mar 10, 2025
0.2.3 Mar 05, 2025
0.2.2 Mar 04, 2025
0.2.1 Mar 04, 2025
0.2.0 Mar 03, 2025
0.1.58 Feb 25, 2025
0.1.57 Feb 12, 2025
0.1.56 Feb 11, 2025
0.1.55 Feb 06, 2025
0.1.54 Feb 05, 2025
0.1.53 Feb 03, 2025
0.1.51 Jan 29, 2025
0.1.50 Jan 23, 2025
0.1.49 Jan 22, 2025
0.1.48 Jan 20, 2025
0.1.47 Jan 16, 2025
0.1.46 Jan 14, 2025
0.1.45 Jan 13, 2025
0.1.44 Jan 09, 2025
0.1.43 Jan 07, 2025
0.1.42 Jan 07, 2025
0.1.41 Dec 17, 2024
0.1.40 Dec 16, 2024
0.1.39 Dec 13, 2024
0.1.38 Dec 10, 2024
0.1.37 Dec 04, 2024
0.1.36 Nov 26, 2024
0.1.35 Nov 25, 2024
0.1.34 Nov 20, 2024
0.1.33 Nov 18, 2024
0.1.32 Nov 15, 2024
0.1.31 Nov 06, 2024
0.1.30 Nov 04, 2024
0.1.29 Nov 02, 2024
0.1.28 Oct 30, 2024
0.1.27 Oct 29, 2024
0.1.26 Oct 28, 2024
0.1.25 Oct 24, 2024
0.1.24 Oct 22, 2024
0.1.23 Oct 21, 2024
0.1.22 Oct 15, 2024
0.1.21 Oct 14, 2024
0.1.20 Oct 04, 2024
0.1.19 Oct 02, 2024
0.1.18 Oct 01, 2024
0.1.17 Sep 10, 2024
0.1.16 Sep 10, 2024
0.1.15 Aug 30, 2024
0.1.14 Aug 21, 2024
0.1.13 Jul 31, 2024
0.1.12 Jul 16, 2024
0.1.11 Jun 03, 2024
0.1.10 May 30, 2024
0.1.9 May 29, 2024
0.1.8 May 14, 2024
0.1.7 Apr 29, 2024
0.1.6 Apr 26, 2024
0.1.5 Apr 22, 2024
0.1.4 Apr 12, 2024
0.1.3 Mar 15, 2024
0.1.2 Mar 05, 2024
0.1.1 Mar 04, 2024
0.1.0 Feb 22, 2024
0.0.19a0.post1 Feb 20, 2024
0.0.19a0.post0 Feb 16, 2024
0.0.19a0 Feb 16, 2024
0.0.18a0 Feb 15, 2024
0.0.17a0 Feb 07, 2024
0.0.16a0 Feb 01, 2024
0.0.15a0 Jan 30, 2024
0.0.14a0 Jan 15, 2024
0.0.13a0 Jan 04, 2024
0.0.12a0 Dec 14, 2023
0.0.11a0 Dec 07, 2023
0.0.10a0 Dec 05, 2023
0.0.9a0 Dec 04, 2023
0.0.8a0 Dec 04, 2023
0.0.7a0 Nov 27, 2023
0.0.6a0.post0 Nov 02, 2023
0.0.0.dev0 Sep 15, 2023

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
backoff
click (>=8.2)
rich-click
docker
fastapi
packaging
pyyaml
requests
rich
six
tqdm
textual (>=2.0)
urllib3 (<=2.5.0)
uvicorn
websocket-client (>=1.6)