Skip to main content

Install

Requires Python 3.10+. The SDK has no mandatory dependencies beyond the standard library and httpx for HTTP transport.
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

Send a message and receive the complete AI response before returning.

Client configuration

string
required
Your device credential token, hk_live_… (production) or hk_test_… (sandbox). Issue credentials from the Humain admin panel under Kiosk → Credentials → Issue new credential. There is no separate client mode or URL for sandbox — it’s determined entirely by which credential you pass. See Sandbox mode.
int
default:"30"
Request timeout in seconds. Applies to both the session open call and each message call.
int
default:"2"
Number of automatic retries on 503 PROVIDER_ERROR responses. Uses exponential back-off starting at 1 second.
str
Override the API base URL. Defaults to https://api.humain.ai. Useful for testing against a local proxy or staging environment.

Session lifecycle

The client.session() context manager opens the session on entry and closes it on exit — even if an exception is raised.
For explicit lifecycle control:

Error handling

Error types:

Multi-turn conversation

Conversation history is managed server-side. You do not pass previous messages with each request — send the next user input directly.
The session maintains the full conversation context server-side. The only state you need to track locally is what to display in your UI.

FastAPI integration

Create a single KioskClient at startup and share it across requests. Each request opens its own session through the shared client.
KioskClient is safe to share across coroutines. Each client.session() call opens an independent session on the server.

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