SDK to develop using Lightning AI Studios
Project description
Lightning SDK for Python
Automate Lightning AI resources from Python scripts, notebooks, and CI.
Quick start • Examples • CLI • Development • Docs
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_USER_ID="..."
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)
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/source python/docs/build -W --keep-going
License
Apache-2.0. See ../LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lightning_sdk-2026.7.3-py3-none-any.whl.
File metadata
- Download URL: lightning_sdk-2026.7.3-py3-none-any.whl
- Upload date:
- Size: 2.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0c07f7b9cd6292114cbfdb73e0af86c6bbfde1295207dcef48dfa1a28a16cb2
|
|
| MD5 |
d94438c5a7745ce1c26a22c2b24b8fc3
|
|
| BLAKE2b-256 |
d360956bdf0beb02ba53b704a190b13d71df8ad664820dd24869b262a2660580
|
Provenance
The following attestation bundles were made for lightning_sdk-2026.7.3-py3-none-any.whl:
Publisher:
release.yaml on Lightning-AI/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lightning_sdk-2026.7.3-py3-none-any.whl -
Subject digest:
b0c07f7b9cd6292114cbfdb73e0af86c6bbfde1295207dcef48dfa1a28a16cb2 - Sigstore transparency entry: 2063718246
- Sigstore integration time:
-
Permalink:
Lightning-AI/sdk@630d7c240c25ebecee993f0a8e06703f8ae17064 -
Branch / Tag:
refs/tags/v2026.07.03 - Owner: https://github.com/Lightning-AI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@630d7c240c25ebecee993f0a8e06703f8ae17064 -
Trigger Event:
release
-
Statement type: