Python SDK
The Python SDK (solti-sdk, import solti) is rigorously typed: request
payloads and API responses are pydantic models, and every finite value set
is a Literal string union (WorkloadStatus, VmStatus, CloudProvider,
ConnectionType, KeyRole, MacroRegion).
Installation
The package is published on PyPI — plain install, no extra index URLs or credentials needed:
pip install solti-sdk
# uv
uv add solti-sdk
Quickstart: End-to-End Workflow Execution
from solti import SoltiClient
from solti.exceptions import WorkloadFailedError, TimeoutError
# api_key falls back to the SOLTI_API_KEY environment variable.
# Project selection uses the X-Solti-Project-Id header (project_id arg or SOLTI_PROJECT_ID env).
client = SoltiClient(api_key="eyJhbGciOi...", project_id="proj-38749")
# 1. Define and submit the workload
job = client.jobs.create(
name="pytorch-train-epoch-50", # or name_prefix="train-epoch-"
image="pytorch/pytorch:2.2.1-cuda12.1-cudnn8-runtime",
command=["python3"],
args=["train.py", "--epochs", "50"],
env={"TORCH_OMP_NUM_THREADS": "8"},
volumes={ # map keyed by volume name
"datasets": {
"bucket": "ml-training-artifacts",
"mountPath": "/mnt/s3",
"connection": "my-aws-s3", # optional
"prefix": "checkpoints", # optional
}
},
resources={"cpu": 8, "memory": "32Gi", "storage": "100Gi", "gpu": "24Gi"}, # gpu shorthand for {"vram": "24Gi"}; storage: boot/root disk size
cloud=["aws", "gcp"], # CloudProvider union — "aws" | "gcp" | "azure"
region="americas", # region or macro-region
max_retries=3,
labels={"environment": "production", "team": "ml"},
tags=["pytorch", "training"],
)
# `job` is a pydantic model: fields are typed and validated (create's
# `job_id` is normalized to `.id`).
print(f"Submitted Job: {job.name} ({job.id}) — {job.status}") # 'queued'
print(f"VM Status: {job.vm_status}") # 'nonassigned'
print(f"Estimated Cost: ${job.estimated_cost}")
try:
# 2. Block and poll progress (default poll interval 10s)
final_job = job.wait_until_complete(timeout_seconds=7200)
print(f"Succeeded! Actual cost: ${final_job.actual_cost}")
except WorkloadFailedError as e:
print(f"Workload failed with exit code {e.exit_code}\n{e.error_summary}")
except TimeoutError:
client.jobs.cancel(job.id)
Typed Request & Response Models
Request keyword arguments validate into exported pydantic models
(CreateJobRequest, VolumeMount, JobResources, GpuRequest,
CreateConnectionRequest + per-provider credential models,
CreateCronjobRequest, PatchCronjobRequest, CreateKeyRequest); responses
are Job, Connection, Cronjob, Key, and CreateKeyResponse models with
snake_case fields and extra="allow" (unknown API fields are preserved).
Invalid values — e.g. status="queued-ish" or role="editor" — raise
pydantic.ValidationError before any request is sent.
Connections, Cronjobs & Keys
client.connections.list()
client.connections.get("my-aws-s3")
client.connections.create(name="new-s3", type="aws", credentials={
"access_key_id": "AKIA...", "secret_access_key": "wJal...", "region": "us-east-1",
}) # credentials validate against the per-provider credential models
client.connections.delete("old-connection")
cron = client.cronjobs.create(
name="nightly-backup",
cron_spec="0 2 * * *", # evaluated strictly in UTC
job_definition={"image": "alpine:latest", "command": ["echo", "backup complete"]},
) # job_definition must not contain a fixed `name` field
cron_detail = client.cronjobs.get(cron.id) # or client.cronjobs.get("nightly-backup")
client.cronjobs.patch("nightly-backup", is_active=False) # `.update` is an alias
client.cronjobs.delete("nightly-backup")
# Keys (admin only): role is the KeyRole union — "admin" | "developer" | "viewer".
key = client.keys.create(name="internal-ci-key", role="developer")
print(key.api_key) # clear-text PAT, shown only once
client.keys.delete(key.name)
Scheduled Start & Workflows (DAG Runs)
# Hold a job in `queued` (no VM, no cost) until a future instant — change 090.
# `run_after` takes a datetime or RFC 3339 string WITH timezone (naive → 422);
# past/now = start immediately; immutable after submission.
from datetime import datetime, timezone
job = client.jobs.create(
image="python:3.13-slim",
command=["python", "-c", "print('later')"],
run_after=datetime(2026, 12, 1, 2, 0, tzinfo=timezone.utc),
)
# Workflows — submit a DAG of standard jobs (change 086). Each template is a
# node name + job definition + optional `dependencies`; ≤ 50 node jobs.
wf = client.workflows.create(
templates=[
{"name": "extract", "job": {"image": "python:3.13-slim", "command": ["python", "extract.py"]}},
{"name": "load", "job": {"image": "python:3.13-slim", "command": ["python", "load.py"]},
"dependencies": ["extract"]},
],
name_prefix="etl", # or name="etl-run-1" (409 on duplicate)
)
print(wf.status) # 'running'
wf = client.workflows.get(wf.id)
runs = client.workflows.list(status="failed", limit=20)
history = client.workflows.list_for_cronjob("nightly-etl") # run history of a workflow-cronjob (change 092)
client.workflows.cancel(wf.id) # only while `running` (409 otherwise)
Resource Discovery
# Discover cloud resources across the project's active connections (api spec
# §3.5) — storages, container repositories, VM compute scopes. A failing
# connection is skipped without failing the request (partial-failure).
storages = client.resources.list_storages() # S3 / GCS / Azure Blob / R2 buckets
repos = client.resources.list_repositories(connection_id="my-aws-conn") # ECR / AR / CR / GHCR
pools = client.resources.list_vm_pools() # per-connection scopes + Solti platform pools
for s in storages:
print(s.id, s.name, s.platform, s.metadata) # typed rows: type/id/name/connection_id/
# connection_type/platform/metadata (+ extras)
Rows are pydantic models typed by the endpoint (StorageResource,
RepositoryResource, VMPoolResource), discriminated by the type wire
value; provider-specific extras (e.g. provider_scope) are preserved
verbatim. On older API revisions whose rows omit the uniform fields, missing
fields stay None and the endpoint's own kind fills type.
Error Handling
The SDK maps HTTP errors to typed exceptions — AuthenticationError
(401), PermissionDeniedError
(403), ValidationError (422),
RateLimitError (429, auto-retries idempotent reads honoring Retry-After),
WorkloadFailedError (non-zero exit / OOM, exposes exit_code,
error_summary, oom), and TimeoutError.