# Realtime
Source: https://docs.simpleserve.ai/docs/voice/realtime
Summary: Realtime voice over WebSocket, OpenAI Realtime API shape. Speech in, spoken answer out, one session.
Availability: available
Last reviewed: 2026-08-25

## Connect

```text
wss://api.simpleserve.ai/openai/v1/realtime?model=qwen3.8-27b
```

Auth is one of: the `Authorization: Bearer` header, the browser subprotocol `openai-insecure-api-key.<key>`, or an ephemeral client secret from `POST /openai/v1/realtime/client_secrets`. An invalid client event returns an `error` event and the session stays open.

**Python**

```python
from openai import OpenAI

client = OpenAI(base_url="https://api.simpleserve.ai/openai/v1", api_key="ss_live_your_key")

with client.realtime.connect(model="qwen3.8-27b") as conn:
    conn.session.update(session={"type": "realtime", "instructions": "Answer in one sentence.", "output_modalities": ["audio"]})
    conn.input_audio_buffer.append(audio=pcm16_base64_chunk)
    for event in conn:
        if event.type == "response.output_audio.delta":
            play(event.delta)
        elif event.type == "response.done":
            break
```

**JavaScript**

```ts
const ws = new WebSocket("wss://api.simpleserve.ai/openai/v1/realtime?model=qwen3.8-27b", ["realtime", "openai-insecure-api-key.ss_live_your_key"]);
ws.onopen = () => ws.send(JSON.stringify({ type: "session.update", session: { type: "realtime", instructions: "Answer in one sentence." } }));
ws.onmessage = ({ data }) => {
  const event = JSON.parse(data);
  if (event.type === "response.output_audio.delta") play(event.delta);
};
```

## Session

| Field                        | Value                                                                                                                |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `audio.input.format`         | `audio/pcm` at 24 kHz, 16-bit mono. `pcmu` and `pcma` are rejected.                                                  |
| `audio.output.format`        | `audio/pcm` at 24 kHz.                                                                                               |
| `audio.input.turn_detection` | `server_vad` (default) or `null` for manual turns. `threshold`, `prefix_padding_ms`, `silence_duration_ms` accepted. |
| `reasoning.effort`           | `minimal` by default, which turns the model's thinking off for latency. `low`, `medium`, `high` enable it.           |
| `voice`                      | Any voice id, ElevenLabs premade id, or OpenAI name.                                                                 |
| `instructions`               | System prompt for the model.                                                                                         |

## Expressive speech

Voices built on Chatterbox laugh, chuckle, sigh, and cough where a person would. The model decides when, at most once per reply and never in a serious answer. Transcripts stay clean: `response.output_audio_transcript.delta` and the final transcript carry the words only.

To turn it off for a session, say so in `instructions`, for example `Never add laughter or other sounds.`

## Ephemeral keys for browsers

Mint a short-lived client secret on your server and hand it to the browser. It works only for the Realtime WebSocket.

```bash
curl https://api.simpleserve.ai/openai/v1/realtime/client_secrets \
  -H "Authorization: Bearer $SIMPLESERVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"session": {"type": "realtime", "model": "qwen3.8-27b"}}'
```

```json title="Response"
{ "value": "ek_…", "expires_at": 1787700000, "session": { "type": "realtime", "model": "qwen3.8-27b", "id": "sess_…", "object": "realtime.session" } }
```

## Billing

A turn is billed as audio minutes in, tokens for the answer, and characters spoken, at the [prices](/docs/pricing) for each. Audio starts as soon as the first sentence of the answer is ready.
