> ## Documentation Index
> Fetch the complete documentation index at: https://humain.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Session modes

> Choose the right interaction mode for your channel: text for WebSocket messaging, voice for real-time WebRTC audio, voip for telephony.

The `mode` field in `POST /v1/sessions` determines which interaction patterns are available for the
life of that session. You cannot change mode mid-session — open a new session if you need to switch.

> [tab] text
>
> ## Text mode
>
> The default mode. Suitable for chat interfaces, kiosk touchscreens, and any channel where you
> exchange typed messages.
>
> **Available endpoint:**
>
> * `GET {agent_url}/v1/sessions/{sid}/ws` — WebSocket: send input, receive the AI's response.
>   This is the only way to exchange conversation turns in text mode — there is no REST
>   message endpoint. See [WebSocket streaming](https://humain.mintlify.site/connections/websocket-streaming.md).
>
> **When to use:**
>
> * Chat widgets embedded in websites or apps.
> * Kiosk touchscreens where users type or tap.
> * Server-to-server integrations.
> * Any context where audio is unavailable or undesirable.
>
> ```bash theme={null}
> # Open a text session — returns session_id and agent_url
> curl -X POST https://api.humain.ai/v1/sessions \
>   -H "Authorization: Bearer hk_live_your_credential_here" \
>   -H "Content-Type: application/json" \
>   -d '{"mode":"text"}'
> ```
>
> > [!NOTE]
> >
> > Browsers must first call `POST /v1/sessions/{sid}/ws-ticket` and pass the result as
> > `?ticket=` on the WS upgrade — browsers cannot set an `Authorization` header on a
> > WebSocket handshake. Non-browser clients send the Bearer token directly.

> [tab] voice
>
> ## Voice mode
>
> Real-time audio over WebRTC. The AI speaks and listens using Opus-encoded audio frames. The
> server uses **Gemini Live** — a single bidirectional audio-in/audio-out connection that handles
> speech recognition, inference, and synthesis natively in one pipeline.
>
> **Available endpoints** (on `agent_url`, returned by `POST /v1/sessions`):
>
> * `POST {agent_url}/v1/sessions/{sid}/webrtc/offer` — exchange SDP offer/answer.
> * `POST {agent_url}/v1/sessions/{sid}/webrtc/ice` — submit ICE candidates.
>
> **Voice pipeline behaviour:**
>
> * **Server-side VAD** — silence is detected server-side after 600 ms. You do not need to
>   send explicit end-of-utterance signals.
> * **Barge-in** — the user can speak while the AI is responding. The AI stops mid-sentence
>   and processes the interruption.
> * **Codec** — Opus, 48 kHz, mono.
>
> **When to use:**
>
> * Drive-through ordering systems.
> * Hotel room assistants where the user never touches a screen.
> * Any hands-free scenario.
>
> ```bash theme={null}
> # Open a voice session (WebRTC negotiation follows)
> curl -X POST https://api.humain.ai/v1/sessions \
>   -H "Authorization: Bearer hk_live_your_credential_here" \
>   -H "Content-Type: application/json" \
>   -d '{"mode":"voice"}'
> ```
>
> > [!WARNING]
> >
> > Voice mode requires a WebRTC-capable runtime. Web browsers support this natively.
> > For server-side or embedded use, integrate [pion/webrtc](https://github.com/pion/webrtc)
> > (Go) or [aiortc](https://github.com/aiortc/aiortc) (Python).

> [tab] voip
>
> ## VoIP mode
>
> Bridges a SIP or PSTN telephone call to the Humain AI. Audio travels over the existing VoIP
> infrastructure — the Humain API handles transcription, inference, and synthesis on the server.
>
> **When to use:**
>
> * Call centre overflow where live agents are unavailable.
> * After-hours phone support.
> * IVR replacement with a natural-language AI front-end.
>
> **Integration paths:**
>
> * **SIP trunk** — configure your PBX (Asterisk, FreeSWITCH, Twilio Elastic SIP) to send calls
>   to the Humain SIP endpoint.
> * **VoIP adapter** — use a hardware ATA (Analog Telephone Adapter) to connect a physical phone
>   line.
>
> ```bash theme={null}
> # Open a voip session
> curl -X POST https://api.humain.ai/v1/sessions \
>   -H "Authorization: Bearer hk_live_your_credential_here" \
>   -H "Content-Type: application/json" \
>   -d '{"mode":"voip"}'
> ```
>
> > [!NOTE]
> >
> > VoIP mode is configured in the admin panel under **Kiosk → Voice settings**. See the
> > [VoIP connection guide](https://humain.mintlify.site/connections/voip-sip.md) for full setup instructions.

## Mode comparison

| Feature | text | voice | voip |
| - | - | - | - |
| WebSocket messaging | ✅ | — | — |
| WebRTC audio | — | ✅ | — |
| SIP / PSTN | — | — | ✅ |
| Server-side VAD | — | ✅ | ✅ |
| Barge-in support | — | ✅ | ✅ |
| Requires browser / WebRTC runtime | No | Yes | No |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.