Providers
Accessor: client.Providers()
Register and manage compute providers (AI inference endpoints). Exposes sub-clients for Profiles and Refresh.
Create
Section titled “Create”Register a new provider with the gateway.
provider, err := client.Providers().Create(ctx, "default", &v1.Provider{ Name: "my-openai", Type: "openai", Spec: v1.ProviderSpec{ Credentials: map[string]string{ "api_key": "sk-...", }, Config: map[string]string{ "base_url": "https://api.openai.com/v1", }, },})if err != nil { log.Fatal(err)}fmt.Println("Created provider:", provider.Name)Fetch a provider by name.
provider, err := client.Providers().Get(ctx, "default", "my-openai")if err != nil { log.Fatal(err)}fmt.Println("Provider type:", provider.Type)List returns a lazy pager over registered providers. ListAll follows every
continuation token; PageSize controls each request.
// List all providersproviders, err := client.Providers().ListAll(ctx, "default")if err != nil { log.Fatal(err)}for _, p := range providers { fmt.Println(p.Name, p.Type)}
// With a smaller page sizeproviders, err = client.Providers().ListAll(ctx, "default", v1.ListOptions{ PageSize: 10,})
// Platform Admin only: list across all workspacesallProviders, err := client.Providers().ListAll(ctx, "", v1.ListOptions{ AllWorkspaces: true,})Update
Section titled “Update”Update an existing provider’s configuration or credentials.
provider, err := client.Providers().Get(ctx, "default", "my-openai")if err != nil { log.Fatal(err)}
provider.Spec.Credentials["api_key"] = "sk-new-key"updated, err := client.Providers().Update(ctx, "default", provider)if err != nil { log.Fatal(err)}fmt.Println("Updated provider:", updated.Name)Delete
Section titled “Delete”Remove a provider by name.
deletion, err := client.Providers().Delete(ctx, "default", "my-openai")if err != nil { log.Fatal(err)}Ensure
Section titled “Ensure”Create or update a provider in a single idempotent call. If a provider with the given name exists, it is updated; otherwise a new one is created. This is the recommended way to register providers because it avoids “already exists” errors when re-registering.
provider, err := client.Providers().Ensure(ctx, "default", &v1.Provider{ Name: "my-openai", Type: "openai", Spec: v1.ProviderSpec{ Credentials: map[string]string{ "api_key": "sk-...", }, },})if err != nil { log.Fatal(err)}fmt.Println("Provider ready:", provider.Name)Ensure is an SDK-level convenience. It calls GetProvider first, then either CreateProvider or UpdateProvider depending on whether the provider already exists.
Sub-Clients
Section titled “Sub-Clients”The ProviderInterface exposes two sub-client accessors for related operations. These are pure client-side accessors with no corresponding gRPC call.
Profiles
Section titled “Profiles”client.Providers().Profiles() returns a ProfileInterface for managing provider type profiles. Profiles define templates and defaults for different provider types.
Refresh
Section titled “Refresh”client.Providers().Refresh() returns a RefreshInterface for configuring credential refresh strategies. Use it to set up automatic credential rotation for providers with expiring credentials.
Provider
Section titled “Provider”The Provider type represents a registered compute provider.
| Field | Type | Description |
|---|---|---|
ID |
string | Server-assigned unique identifier |
Name |
string | User-chosen name (unique per gateway) |
Type |
string | Provider type (e.g., "openai", "azure") |
CreatedAt |
time.Time | Timestamp of creation |
Labels |
map[string]string | Key-value metadata labels |
ResourceVersion |
uint64 | Optimistic concurrency version |
Spec |
ProviderSpec | Configuration and credentials |
ProviderSpec
Section titled “ProviderSpec”ProviderSpec holds provider-specific configuration and credentials.
| Field | Type | Description |
|---|---|---|
Credentials |
map[string]string | Authentication credentials (e.g., API keys) |
Config |
map[string]string | Provider-specific configuration values |
CredentialExpiresAt |
map[string]time.Time | Expiration timestamps for credentials |
The curated Go API uses a zero time.Time value to clear an expiration during
an update. Consequently, it cannot represent the protobuf minimum timestamp
(0001-01-01T00:00:00Z) in this map. Use the raw protobuf API if that exact
timestamp is required. Other pointer-based timestamp fields preserve it.
See also: Profiles, Refresh, Error Handling, Testing
We are a Cloud Native Computing Foundation sandbox project.
Copyright OpenShell a Series of LF Projects, LLC
For website terms of use, trademark policy and other project policies please see lfprojects.org/policies/.