Automate Lightning AI resources from Go services, CLIs, and CI jobs.
The Go SDK exposes Lightning AI resources as typed handles. Use it when Go code needs to resolve users, organizations, or teamspaces, then create or manage studios, single-machine jobs, and multi-machine training jobs.
The public package is lit. Handles are created with Get*, Create*, and
Run* functions and then operated through methods on the returned resource.
Build on Lightning AI, the platform for training, deploying, and scaling AI applications with managed compute, collaborative studios, and production endpoints.
Add the module:
go get github.com/lightning-ai/sdk/goAuthenticate with the same environment used by other Lightning SDKs:
export LIGHTNING_USER_ID="..."
export LIGHTNING_API_KEY="..."Run a container-backed job:
package main
import (
"fmt"
"log"
lit "github.com/lightning-ai/sdk/go"
)
func main() {
org, err := lit.GetOrganization("my-org")
if err != nil {
log.Fatal(err)
}
teamspace, err := lit.GetTeamspace("my-teamspace", lit.TeamspaceOptions{Owner: org})
if err != nil {
log.Fatal(err)
}
job, err := lit.RunJob(
"go-readme-job",
lit.MachineCPU,
"python -c 'print(\"hello from Lightning\")'",
lit.JobOptions{
Teamspace: teamspace,
Image: "python:3.11-slim",
},
)
if err != nil {
log.Fatal(err)
}
if err := job.Wait(); err != nil {
log.Fatal(err)
}
fmt.Println(job.Status())
}org, err := lit.GetOrganization("my-org")
if err != nil {
log.Fatal(err)
}
teamspace, err := lit.GetTeamspace("my-teamspace", lit.TeamspaceOptions{Owner: org})
if err != nil {
log.Fatal(err)
}
fmt.Println(teamspace.ID())studio, err := lit.CreateStudio("go-dev", lit.StudioOptions{
Teamspace: teamspace,
Machine: lit.MachineCPU,
})
if err != nil {
log.Fatal(err)
}
if err := studio.Start(); err != nil {
log.Fatal(err)
}
fmt.Println(studio.Status())job, err := lit.GetJob("go-readme-job", lit.JobOptions{Teamspace: teamspace})
if err != nil {
log.Fatal(err)
}
fmt.Println(job.Name(), job.Status(), job.Machine())| Area | Entry point |
|---|---|
| users | GetUser(...) |
| organizations | GetOrganization(...) |
| teamspaces | GetTeamspace(...), CreateTeamspace(...) |
| studios | GetStudio(...), CreateStudio(...), studio.Start(...), studio.SwitchMachine(...) |
| jobs | GetJob(...), RunJob(...), job.Wait(...), job.Stop(...), job.Delete(...) |
| multi-machine training jobs | GetMMT(...), RunMMT(...) |
| machines | MachineCPU, MachineL4, MachineA100, and other Machine* constants |
go test ./...The Go module currently lives in go.mod and targets Go 1.22.
Apache-2.0. See ../LICENSE.