Skip to main content

Install

Requires Go 1.21+. No third-party dependencies beyond the Go standard library.
During development, initialise the client with an hk_test_… sandbox credential instead of hk_live_…. There is no separate sandbox mode or URL — sandbox behavior comes entirely from the credential prefix. No AI credits are consumed and no usage is billed. See Sandbox mode.

Quick start

Open a session, send a message, receive the complete response.

Client configuration

string
required
Your device credential token in hk_live_… format. Issue credentials from the Humain admin panel under Kiosk → Credentials → Issue new credential.
kiosk.Mode
default:"kiosk.ModeLive"
kiosk.ModeSandbox returns instant stub responses without consuming AI credits. Use kiosk.ModeLive for production.
time.Duration
default:"30s"
Context deadline applied to each HTTP request. The caller’s context.Context deadline takes precedence if shorter.
int
default:"2"
Number of automatic retries on 503 PROVIDER_ERROR. Uses exponential back-off starting at 1 second.
string
Override the API base URL. Defaults to https://api.humain.ai.

Session options

kiosk.SessionMode
default:"kiosk.SessionModeText"
Session mode. Only kiosk.SessionModeText is supported by the SDK — voice sessions require raw WebRTC or a VoIP integration.
map[string]string
Arbitrary key-value pairs attached to the session. Available in your kiosk’s action endpoints as session.metadata.

Error handling

The SDK returns typed errors you can check with errors.As:
*kiosk.RateLimitError fields:
time.Duration
Minimum wait before the next request. Derived from the Retry-After response header.
*kiosk.ProviderError fields:
bool
true if the error is transient and safe to retry with exponential back-off.
int
The HTTP status code returned by the API (typically 503).

Concurrent sessions

*kiosk.Client is safe to use from multiple goroutines. Each OpenSession call creates an independent server-side session.
Create the client once at server startup and close sessions in a deferred call or after each HTTP handler completes.

Never hard-code your credential. Read it from an environment variable: