Skip to main content
The @humain/kiosk-js SDK wraps the Humain Device API so you can open sessions, send messages, and stream responses with one import and a handful of method calls — no raw HTTP required.
During development, issue an hk_test_ credential from the admin panel instead of a live hk_live_ one. Sandbox is a property of the credential, not a different base URL — you call the same https://api.humain.ai host either way. Sandbox sessions don’t consume production LLM credits and aren’t billed. See Sandbox mode.
1

Install the package

2

Open a session and send a message

There is no separate sandbox URL or client mode — sandbox behavior comes entirely from using an hk_test_ credential. See Sandbox mode.
3

Add streaming

Replace sendMessage with session.stream() to receive tokens as they are generated. This uses an async iterator — for await works in any modern JavaScript runtime.
The iterator yields objects of these types:
The underlying WebSocket delivers one complete response per turn — see WebSocket streaming for the wire protocol. chunk, tool_call, and tool_result events are a client-side reveal built by the SDK on top of that single response, not genuine incremental delivery from the network.
4

Handle errors

The client throws typed KioskError instances you can inspect:
Never expose live credentials in client-side code. Your hk_live_… token is a long-lived secret. In browser environments, either proxy API calls through your own server or issue an hk_test_… (sandbox) credential instead for public-facing demos. Treat it like a password.

What’s next?

Drop-in widget

Add a floating chat button to any webpage with a single <script> tag — no build step.

React components

<KioskChat> and useKioskSession for React and Next.js applications.

Streaming UI patterns

Cursor animation, layout shift prevention, and abort/retry patterns.