Go SDK
Use the Go SDK to manage OpenShell resources from Go applications, operators, and controllers. Its typed subclients follow familiar Kubernetes client patterns. The SDK is developed in ai-openshell/sdk-go, which also has the full SDK documentation.
Install the SDK
The SDK requires Go 1.26 or later. SDK releases follow OpenShell releases,
so SDK vX.Y.Z works with a gateway from OpenShell vX.Y.Z. Add the version
that matches your gateway to your Go module:
Connect to a Gateway
Pass a host:port address to NewClient. For a local gateway that allows
unauthenticated plaintext connections:
For an authenticated TLS gateway, provide the bearer token and TLS settings:
Omit CAFile to use system roots. For renewable OIDC service credentials, use
oidc.NewClientCredentialsAuth from
github.com/ai-openshell/sdk-go/openshell/v1/oidc.
Discover the Active Gateway
gateway.NewClient("") and gateway.LoadConfig("") select the active gateway
from the user active_gateway file first, then fall back to the system
/etc/openshell/active_gateway. gateway.ListGateways marks the selected
gateway as active, including a system default.
Create and Use a Sandbox
Resource methods take an explicit workspace. The following example creates a
sandbox in default, waits for readiness, runs a command, and requests
deletion:
The root client also exposes subclients for providers, services, files, SSH, TCP forwarding, policy, configuration, templates, and workspaces. List methods return lazy pagers so callers choose when to fetch the next page.
Migrate from github.com/NVIDIA/OpenShell/sdk/go
The SDK used to live in this repository as github.com/NVIDIA/OpenShell/sdk/go.
That module is deprecated and gets no further changes, including dependency and
security updates. As of the move, packages and APIs are the same; only the
module path is new. Rewrite the imports, then fetch the SDK version that
matches your gateway:
Existing builds keep working: the old module’s tags stay published, and the
latest one carries the deprecation notice that go get and pkg.go.dev show.
Next Steps
- Review Gateway Authentication before connecting a service to a production gateway.
- Review API Errors for the gateway error model.
- Browse the Go package reference for all exported types and methods.