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.
Prerequisites
Section titled “Prerequisites”- Go 1.23 or later
- An hlix API key and workspace ID
Install
Section titled “Install”Create a Go module for your application, then add the SDK:
mkdir hlix-examplecd hlix-examplego mod init example.com/hlix-examplego get github.com/hlix-ai/hlix-goList projects
Section titled “List projects”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:
HLIX_API_KEY='…' \HLIX_WORKSPACE_ID='<workspace-id>' \go run .Expected result: the selected workspace’s project collection is printed.
Use another API origin
Section titled “Use another API origin”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.
Authentication and request handling
Section titled “Authentication and request handling”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.
If the client fails
Section titled “If the client fails”no required module provides package …: rungo get github.com/hlix-ai/hlix-goinside your application module and check the import path.missing go.sum entry: rungo mod tidywith network access for the generated client’s dependencies.401: confirm the API key is present inContextAPIKeysunderapiKey.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.versionidentifies the contract version.