API Reference
The Lightning SDK is the Python interface for managing Lightning AI resources from scripts, notebooks, services, and CI jobs. Use it when you need the same resource control exposed by the CLI, but want it inside Python code with typed objects, method references, and reusable application logic.
Install
Install or upgrade the package:
pip install lightning-sdk -UAuthenticate
For local development, authenticate once with the CLI:
lightning loginFor automation, configure credentials with environment variables:
export LIGHTNING_API_KEY=your-api-keyCore Resources
Studios are persistent development environments. Start with
Studio when you need to create or control an
interactive workspace, and use Machine when selecting compute.
Jobs run code in managed cloud compute. Use lightning_sdk.Job.run for
single-node work and lightning_sdk.MMT.run for multi-machine training.
Deployments turn model servers and applications into managed services. Use
Deployment with the deployment helper classes in
Deployment for environment variables, secrets, authentication,
health checks, and rollout behavior.
Teamspaces, organizations, and users define the account context for SDK calls.
Use Teamspace, Organization,
and User when you need to resolve or switch the scope
of an operation.
Use Organization to query usage/cost activity for an
organization, or one or more of its teamspaces, and to download or export
that activity as a CSV or JSON report.
Quick Example
from lightning_sdk import Machine, Studio
studio = Studio("my-studio")
studio.start()
job = studio.run("python train.py", machine=Machine.A10G)
job.wait()
studio.stop()Reference Pages
Was this page helpful?
Thanks for the feedback.