Skip to content

Go SDK

Install the Go SDK, authenticate it, and list projects.

Use the Go SDK to call the hlix API with typed requests and responses. The client is generated from the OpenAPI contract and published as github.com/hlix-ai/hlix-go.

  • Go 1.23 or later
  • An hlix API key and workspace ID

Create a Go module for your application, then add the SDK:

Terminal window
mkdir hlix-example
cd hlix-example
go mod init example.com/hlix-example
go get github.com/hlix-ai/hlix-go

Create main.go:

package main
import (
"context"
"fmt"
"log"
"os"
hlix "github.com/hlix-ai/hlix-go"
)
func main() {
workspaceID := os.Getenv("HLIX_WORKSPACE_ID")
apiKey := os.Getenv("HLIX_API_KEY")
if workspaceID == "" || apiKey == "" {
log.Fatal("HLIX_WORKSPACE_ID and HLIX_API_KEY are required")
}
ctx := context.WithValue(
context.Background(),
hlix.ContextAPIKeys,
map[string]hlix.APIKey{"apiKey": {Key: apiKey}},
)
configuration := hlix.NewConfiguration()
client := hlix.NewAPIClient(configuration)
projects, _, err := client.ProjectsAPI.
ListProjects(ctx).
XOrganizationId(workspaceID).
Execute()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v\n", projects)
}

Run it:

Terminal window
HLIX_API_KEY='…' \
HLIX_WORKSPACE_ID='<workspace-id>' \
go run .

Expected result: the selected workspace’s project collection is printed.

Set HLIX_BASE_URL to the API origin for your Workspace and environment, then pass it to the client:

configuration := hlix.NewConfiguration()
configuration.Servers = hlix.ServerConfigurations{{URL: os.Getenv("HLIX_BASE_URL")}}
client := hlix.NewAPIClient(configuration)

Use credentials for the selected environment.

Store the API key in ContextAPIKeys under apiKey and pass XOrganizationId on Workspace-scoped requests. Handle the returned response and error in your application. For a write with an uncertain outcome, inspect the resource before submitting it again.

  • no required module provides package …: run go get github.com/hlix-ai/hlix-go inside your application module and check the import path.
  • missing go.sum entry: run go mod tidy with network access for the generated client’s dependencies.
  • 401: confirm the API key is present in ContextAPIKeys under apiKey.
  • 403: confirm the user can access the explicit workspace ID.
  • 404: the resource is absent or not visible to this caller.
  • If you generate a custom client, pin your generator version and re-download the contract when regenerating — its info.version identifies the contract version.