# Go SDK preview

**This page previews the Go module hlix will publish.** It is generated from the public OpenAPI contract, and the shapes below are the ones the published module will expose.
**Preview, not a published module:** No module is published and **no module path is claimed**. Do not `go get` or pin a public hlix module path until [Current versions](/releases/availability/) shows a verified release — whatever answers that path today is not hlix's.

## Prerequisites

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

## Generate a client meanwhile

The [OpenAPI contract](/api/openapi/) is public and unauthenticated, so a working Go client is one command away:

```bash
curl --fail --silent --show-error \
  https://server.hlix.ai/v1/api/openapi.json \
  --output hlix-openapi.json

npx @openapitools/openapi-generator-cli generate \
  -i hlix-openapi.json \
  -g go \
  -o ./hlix-client
```

Expected result: a module whose operations match the [API reference](/api/reference/) one for one. hlix pins OpenAPI Generator `7.22.0` for its own previews; pin yours so regeneration is reproducible.

Identifiers in your generated client will differ from the sample below — that is the cost of generating rather than waiting. The requests and responses are identical, because both come from the one contract.

## List projects

Create `main.go`:

```go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	// The module path your generated client uses — hlix has not published one.
	hlix "example.com/hlix-client"
)

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:

```bash
HLIX_API_KEY='…' \
HLIX_WORKSPACE_ID='<workspace-id>' \
go run .
```

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

## Use another API origin

The generated configuration defaults to production. For a self-hosted or staging deployment, replace its server list before creating the client. Keep production credentials out of non-production hosts.

## Preview limitations

- Method names, generic response types, and module packaging may change before a stable tag.
- The preview does not add the TypeScript SDK's opinionated errors, bounded retry, local import scanner, or sync workflow.
- Streaming and bundle upload protocols require application-specific lifecycle handling.
- The generated auth context key must be `apiKey`, and tenant selection remains an explicit `XOrganizationId` call option.

## If the preview client fails

- `no required module provides package …`: you are fetching a module path hlix has not published. Generate a client from the contract instead, and check [Current versions](/releases/availability/).
- `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.
- Regeneration drift: pin your generator version, and re-download the contract — its `info.version` tells you whether the contract itself moved.

## Next steps

[API & OpenAPI](/api/openapi/)
  [TypeScript SDK](/sdk/typescript/)
  [Python SDK preview](/sdk/python/)
  [Current versions](/releases/availability/)