Skip to main content

Go SDK

The Go SDK (github.com/trysolti/solti-sdk-go, package solti) is a hand-written, idiomatic Go client: context.Context on every call, functional options, typed errors compatible with errors.Is / errors.As, and zero external dependencies (stdlib net/http only).

Installation​

Distributed via the Go module proxy — a go get is all it takes:

go get github.com/trysolti/solti-sdk-go

Requires Go 1.24+.

Client Setup​

import "github.com/trysolti/solti-sdk-go/solti"

client, err := solti.NewClient(
solti.WithAPIKey("sk_live_..."), // or set SOLTI_API_KEY
solti.WithProjectID("proj-38749-db30"), // or set SOLTI_PROJECT_ID
// solti.WithBaseURL(...) // optional; default https://api.solti.run/1
)

Configuration precedence: options > SOLTI_API_KEY / SOLTI_API_URL / SOLTI_PROJECT_ID environment variables > defaults. Project selection goes out as the X-Solti-Project-Id header — per-project wildcard hosts are not deployed; never resolve <project>.api.solti.run.

Quickstart: End-to-End Workload Execution​

job, err := client.Jobs.Create(ctx, &solti.JobCreateInput{
NamePrefix: "train-epoch-",
Image: "pytorch/pytorch:2.2.1-cuda12.1-cudnn8-runtime",
Command: []string{"python3"},
Args: []string{"train.py", "--epochs", "50"},
Env: map[string]string{"MODEL_EXPORT_DIR": "/mnt/s3/models"},
Volumes: map[string]solti.VolumeMount{
"datasets": {Bucket: "ml-training-artifacts", MountPath: "/mnt/s3", Prefix: "checkpoints"},
},
Resources: &solti.JobResources{
CPU: 8,
Memory: "32Gi",
Storage: solti.GiB(100),
GPU: &solti.GPURequest{VRAM: "24Gi"},
},
Cloud: []string{"aws", "gcp"},
MaxRetries: 3,
Labels: map[string]string{"environment": "production", "team": "ml"},
Tags: []string{"pytorch", "training"},
})
if err != nil { log.Fatal(err) }
fmt.Printf("submitted %s (%s)\n", job.Name, job.ID)

final, err := job.WaitUntilComplete(ctx, &solti.WaitOptions{
Timeout: 2 * time.Hour,
PollInterval: 10 * time.Second, // default
OnProgress: func(j *solti.Job) { fmt.Printf("status: %s\n", j.Status) },
})
if err != nil {
var failed *solti.WorkloadFailedError
if errors.As(err, &failed) {
log.Fatalf("workload failed: exit %v, oom=%v, summary=%s",
failed.ExitCode, failed.OOM, failed.ErrorSummary)
}
log.Fatal(err)
}
fmt.Printf("done — actual cost $%.4f\n", *final.ActualCost)

WaitUntilComplete polls every 10 seconds by default and returns *solti.WorkloadFailedError when the job fails (exit code, error summary, OOM flag) or *solti.TimeoutError when Timeout elapses (pass CancelOnTimeout: true to cancel the job on timeout).

Cronjobs, Connections, Workflows, Keys​

// Cronjobs — UTC schedules; every lookup accepts UUID or name.
cron, err := client.Cronjobs.Create(ctx, &solti.CronjobCreateInput{
Name: "nightly-backup",
CronSpec: "0 2 * * *",
JobDefinition: &solti.JobDefinition{
Image: "alpine:latest", Command: []string{"sh"}, Args: []string{"-c", "backup.sh"},
},
})
inactive := false
cron, err = client.Cronjobs.Patch(ctx, "nightly-backup", &solti.CronjobPatchInput{IsActive: &inactive})
err = client.Cronjobs.Delete(ctx, cron.ID)

// Connections — credential fields merge flat into the payload (CLI wire format).
conn, err := client.Connections.Create(ctx, &solti.ConnectionCreateInput{
Name: "new-s3", Type: solti.ConnectionAWS,
Credentials: &solti.AWSCredentials{
AccessKeyID: "AKIA...", SecretAccessKey: "...", Region: "us-east-1",
},
})

// Workflows — DAG of job templates with static fan-out.
wf, err := client.Workflows.Create(ctx, &solti.WorkflowCreateInput{
Templates: []solti.WorkflowTemplate{
{Name: "extract", Job: solti.JobDefinition{Image: "python:3.13-slim", Command: []string{"python"}, Args: []string{"extract.py"}}},
{Name: "load", Job: solti.JobDefinition{Image: "python:3.13-slim", Command: []string{"python"}, Args: []string{"load.py", "--shard", "{{item}}"}},
Dependencies: []string{"extract"}, WithItems: []any{1, 2, 3}},
},
})
runs, err := client.Workflows.ListForCronjob(ctx, "nightly-etl", nil)
_, err = client.Workflows.Cancel(ctx, wf.ID)

// Keys — admin only; the clear-text token is shown exactly once.
key, err := client.Keys.Create(ctx, &solti.KeyCreateInput{Name: "ci-deploy-key", Role: solti.RoleDeveloper})
fmt.Println(key.Token) // store it now — never retrievable again

// Resources — discover storages/repositories/VM pools across connections.
storages, err := client.Resources.ListStorages(ctx, "") // "" = all connections

Error Handling​

API failures return *solti.Error; classify with errors.Is against the sentinels ErrAuthentication (401), ErrPermissionDenied (403), ErrNotFound (404), ErrConflict (409), ErrValidation (422), and ErrRateLimit (429):

var apiErr *solti.Error
if errors.As(err, &apiErr) && errors.Is(err, solti.ErrRateLimit) {
fmt.Println("retry after", apiErr.RetryAfter, apiErr.RateLimit)
}

Idempotent GETs auto-retry on 429 (≤ 2 attempts, Retry-After honored, capped at 30s); mutations surface the rate-limit error to the caller. All errors carry Status, Message, the raw Payload, and the response Header.