Install
httpx for HTTP transport.
Quick start
- Text session
- Streaming session
Send a message and receive the complete AI response before returning.
Client configuration
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.Request timeout in seconds. Applies to both the session open call and each message call.
Number of automatic retries on
503 PROVIDER_ERROR responses. Uses exponential back-off
starting at 1 second.Override the API base URL. Defaults to
https://api.humain.ai. Useful for testing against
a local proxy or staging environment.Session lifecycle
Theclient.session() context manager opens the session on entry and closes it on exit —
even if an exception is raised.
Error handling
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
Using with FastAPI
Using with FastAPI
Create a single
KioskClient at startup and share it across requests. Each request opens
its own session through the shared client.Running concurrent sessions
Running concurrent sessions
KioskClient is safe to share across coroutines. Each client.session() call opens an
independent session on the server.