Skip to main content
The kiosk-c library is a C99 client for the Humain Kiosk Device API. It requires libcurl >= 7.68.0 and provides both blocking and streaming message APIs. Source and prebuilt binaries: github.com/humain/kiosk-c

Build and install

Link your application against libkiosk and libcurl:
Or in CMake:

Minimal complete example


Streaming example


Error handling


kiosk_config_t fields

const char *
required
Device API credential in the form hk_live_XXXXXXXXXXXXXXXXXX (production) or hk_test_XXXXXXXXXXXXXXXXXX (sandbox — see Sandbox mode). Read from an environment variable — never hard-code in source files.
const char *
default:"https://api.humain.ai"
Override the API base URL. There is no separate sandbox host — sandbox behavior comes from using an hk_test_ credential against this same URL. Leave as NULL unless you’re pointing at a self-hosted deployment.
int
default:"30000"
HTTP request timeout in milliseconds. Set to 0 to use the default (30 000 ms). Streaming requests use this timeout per chunk, not for the entire stream.
int
default:"3"
Maximum number of automatic retries for KIOSK_ERR_NETWORK and KIOSK_ERR_TIMEOUT errors. Retries use exponential back-off with jitter capped at 30 seconds. Set to 0 to disable automatic retries.
int
default:"0"
When non-zero, routes all requests to the sandbox endpoint regardless of base_url. Sandbox responses are instant and consume no AI credits.

Error codes


Voice sessions

Voice session functions are only available when built with -DKIOSK_WITH_VOICE=ON. They are not available on FreeRTOS or Zephyr targets.

kiosk_voice_config_t fields

kiosk_audio_capture_fn
required
Audio capture callback. Called from the library’s internal audio thread at frame_ms intervals. Fill the provided buffer with 16-bit signed PCM (16 kHz, mono) and return the number of frames written.Must be real-time safe — no heap allocation, no blocking mutex calls, no stdio. Any violation causes audio glitches and WebRTC packet loss.
kiosk_audio_playback_fn
required
Audio playback callback. Called with synthesised speech PCM received from the AI. Write the provided samples to your speaker hardware.
kiosk_vad_fn
default:"NULL"
Voice activity detection callback. Called with speaking = 1 on speech onset and speaking = 0 on silence detection. Use for UI feedback — for example, showing a “listening” indicator. Pass NULL to disable.
kiosk_voice_event_fn
default:"NULL"
Lifecycle event callback. Called on transitions between KIOSK_VOICE_CONNECTING, KIOSK_VOICE_LISTENING, KIOSK_VOICE_PROCESSING, KIOSK_VOICE_SPEAKING, and KIOSK_VOICE_ENDED. Pass NULL to disable.
void *
default:"NULL"
Opaque pointer passed unchanged to all four callbacks.
int
default:"16000"
Audio sample rate in Hz. Must match your audio hardware. Gemini Live performs best at 16 000 Hz or 48 000 Hz.
int
default:"20"
Capture frame duration in milliseconds. Determines how often capture_fn is invoked. 20 ms is the standard WebRTC frame size.

ALSA example

Complete voice session using the built-in ALSA helper (-DKIOSK_WITH_ALSA=ON):

Custom audio hardware

For teams not using ALSA — implement capture_fn and playback_fn directly for your platform’s audio driver:
The capture callback runs on an internal real-time audio thread. It must complete within frame_ms (default 20 ms). Violations cause audio glitches and WebRTC packet loss.Requirements:
  • No dynamic memory allocation (malloc, free, new)
  • No blocking mutex calls
  • No stdio (printf, fwrite)
For I2S hardware: use DMA-backed ring buffers. Copy from the DMA ring buffer into the library’s provided buf — the copy should take under 1 ms.For USB audio: use ALSA’s snd_pcm_readi with a pre-allocated buffer. Set the capture thread to SCHED_FIFO priority to avoid scheduler jitter.
The library uses STUN to discover the device’s public address. The default STUN server is Google’s public STUN (stun.l.google.com:19302).No TURN server is required in most network configurations — the Humain Kiosk platform handles the server-side connectivity. If the device is behind a symmetric NAT, contact support@humain.ai to enable TURN relay credentials for your workspace.

Memory model

Client and session handles — the library allocates these internally. kiosk_client_destroy() frees the client; kiosk_session_close() frees the session. Never free these pointers yourself.Response buffers — for kiosk_session_message(), the caller provides a stack- or heap-allocated buffer. The library writes the NUL-terminated response into it and never allocates additional memory for the response. If the response does not fit, KIOSK_ERR_OUT_OF_MEMORY is returned and the buffer contains a partial response.Recommended buffer sizes:Streaming — kiosk_session_stream() allocates only a small internal CURL write buffer. The chunk pointer passed to your callback is valid only for the duration of that callback invocation; copy it if you need to retain the data.kiosk_config_t — the struct is copied by kiosk_client_create(). You may free or reuse the config struct immediately after that call returns. The credential and base_url strings are copied — you do not need to keep them alive.

Thread safety

To handle concurrent conversations, open one session per conversation (not one session per thread). Multiple sessions can be open simultaneously on a single client.kiosk_session_stream() is safe to cancel from another thread by returning a non-zero value from the callback — but the callback itself is always invoked on the thread that called kiosk_session_stream().