# Change settings mid-session

Last updated: 2026-11-19

**The problem.** A live session's settings are given once, at `POST /v2/live`. But a conversation changes as it
goes: the caller answers in French after the menu in English, the agent learns the customer's name and the product
they call about, the caller is about to read out their card number. Closing the session and opening another one
loses the audio in between, the speaker labels and the session's result in one piece.

**The fix.** Allow it when you create the session, then send the settings to change on the WebSocket, as a part
of the init body:

```json
{ "type": "session_config", "data": { "language_config": { "languages": ["fr"] } } }
```

The session goes on, and transcribes with the new settings from its last final: the utterance in progress is
transcribed again with them, and every final from then on follows them. A `session_config` message answers the
request.

## At a glance

| | |
|---|---|
| Live API | `session_config` |
| Pre-recorded (batch) | Live only |
| Live models | `solaria-3`, `trantoria-1` (every live model) |
| Languages | Every language of the model ([supported languages](/languages/supported-languages/)) |

## Allow it at the init

Changes are **off unless the init asks for them**: whoever holds the session's WebSocket URL (a browser or a phone
you handed it to) is not you, who holds the API key and chose the settings, PII redaction and paid add-ons
included. Set `session_config` in the init body (`POST /v2/live`):

```json
{ "encoding": "wav/pcm", "sample_rate": 16000, "bit_depth": 16, "channels": 1, "session_config": {} }
```

`{}` allows every setting that may change. `allowed` narrows it to the ones you list, so a client can switch
languages but never turn PII redaction off:

```json
{ "encoding": "wav/pcm", "sample_rate": 16000, "bit_depth": 16, "channels": 1, "pii": true, "session_config": { "allowed": ["language_config", "realtime_processing"] } }
```

Without it, every `session_config` message is refused (`settings changes are not enabled for this session`); a
setting outside `allowed` is refused by name.

## What can change

Every setting of the init body, with the same names and values, except these, which stay those of the init:

| kept for the whole session | why |
|---|---|
| `encoding`, `bit_depth`, `sample_rate`, `channels` | the audio already sent and recorded is in this format |
| `model` | the session runs on this model's servers, and is counted as such |
| `callback`, `callback_config`, `messages_config` | where and what the server sends was checked and set up at the init |
| `custom_metadata`, `finalization` | they describe the session as a whole |
| `speaker_identification`, `speaker_identification_config` | turned off with its own message, `speaker_identification_config` |

So: languages and code switching, custom vocabulary, `keyterms_prompt` and `context`, translation, named entities,
PII redaction, sentiment, numerals, emails and addresses, diarization, punctuation, endpointing, end of turn, the
latency profile and the other add-ons.

Some common changes:

```json
{ "type": "session_config", "data": { "realtime_processing": { "custom_vocabulary": true, "custom_vocabulary_config": { "vocabulary": ["Gladia", "Solaria"] } } } }
```

```json
{ "type": "session_config", "data": { "realtime_processing": { "context": "The caller is Jeanne Martin, about her order 4021." } } }
```

```json
{ "type": "session_config", "data": { "pii": true } }
```

```json
{ "type": "session_config", "data": { "realtime_processing": { "translation": true, "translation_config": { "target_languages": ["en"] } } } }
```

## How the change merges

`data` is merged over the settings in force, not put in their place:

- **An object is merged key by key.** `{"realtime_processing": {"context": "..."}}` changes the context and keeps the
  custom vocabulary, translation and the rest of `realtime_processing` as they were.
- **A list, a string, a number or a boolean replaces** the value in force. `"languages": ["fr"]` is the whole new
  list.
- **`null` unsets a setting**: it gets its default again, as if the init had not set it.
  `{"pii": null}` turns PII redaction off. `profile` cannot be unset (it would lose your workspace's default
  profile): name the profile to use.

The merged settings are then checked exactly like an init body: a wrong type, an unknown name or a value out of range
refuses the whole request, and nothing changes.

## The answer

```json
{
  "type": "session_config",
  "session_id": "0199d7a2-5c3e-7b41-9f0a-3c2d1e4f5a6b",
  "created_at": "2026-11-02T09:00:12.400Z",
  "acknowledged": true,
  "error": null,
  "data": { "effective": { "language_config": { "languages": ["fr"] } }, "effective_at": 42.18, "version": 1 }
}
```

- `effective`: the settings the request named, down to the fields it set, as now in force. Only those: the others,
  which you set at the init (a context prompt, a vocabulary beside the field changed), are never sent back to the
  WebSocket.
- `effective_at`: the second of the session from which the new settings apply, the end of the last final.
- `version`: how many changes the session has had.

`acknowledged: false` means nothing changed: `error` says why, and `effective` is `null` (the settings are those of
the last acknowledged change, or of the init). The
answer comes once the session runs on the new settings, usually in a few hundred milliseconds; the audio you keep
sending meanwhile is transcribed, nothing is lost.

Each program below opens a session in English, streams a WAV file like a microphone, and switches the session to
French halfway. Put your API key in the `GLADIA_API_KEY` environment variable, then run
`python switch_language.py call.wav` (or `node switch_language.mjs call.wav`).

**Python**

```python title="switch_language.py"
# pip install requests websockets
import asyncio
import json
import os
import sys
import wave

import requests
import websockets

API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")

async def main(path: str) -> None:
    with wave.open(path) as wav:  # a 16-bit PCM WAV file
        rate, channels = wav.getframerate(), wav.getnchannels()
        audio = wav.readframes(wav.getnframes())
    created = requests.post(
        f"{API_URL}/v2/live",
        headers={"x-gladia-key": os.environ["GLADIA_API_KEY"]},
        json={
            "encoding": "wav/pcm",
            "sample_rate": rate,
            "bit_depth": 16,
            "channels": channels,
            "language_config": {"languages": ["en"]},
            "messages_config": {"receive_acknowledgments": True},
            "session_config": {"allowed": ["language_config"]},  # the client may switch languages
        },
        timeout=10,
    )
    created.raise_for_status()

    async with websockets.connect(created.json()["url"]) as ws:
        step = rate * channels * 2 // 10  # 100 ms of audio per chunk
        half = len(audio) // 2
        for start in range(0, len(audio), step):
            if start <= half < start + step:  # the caller switched to French
                change = {"language_config": {"languages": ["fr"]}}
                await ws.send(json.dumps({"type": "session_config", "data": change}))
            await ws.send(audio[start : start + step])
        await ws.send(json.dumps({"type": "stop_recording"}))
        async for raw in ws:
            message = json.loads(raw)
            if message["type"] == "session_config":
                if not message["acknowledged"]:
                    raise SystemExit(f"settings not changed: {message['error']}")
                print("settings changed from", message["data"]["effective_at"], "s")
            elif message["type"] == "transcript" and message["data"]["is_final"]:
                utterance = message["data"]["utterance"]
                print(f"[{utterance['language']}] {utterance['text']}")

asyncio.run(main(sys.argv[1]))
```

**JavaScript**

```js title="switch_language.mjs"
// Node.js 22 or later: fetch and WebSocket are built in
import { readFileSync } from "node:fs";

const API_URL = process.env.GLADIA_API_URL ?? "https://eu1.api.gladia.io";
const { sampleRate, channels, pcm } = readWav(process.argv[2]); // a 16-bit PCM WAV file

const created = await fetch(`${API_URL}/v2/live`, {
  method: "POST",
  headers: { "x-gladia-key": process.env.GLADIA_API_KEY, "content-type": "application/json" },
  body: JSON.stringify({
    encoding: "wav/pcm",
    sample_rate: sampleRate,
    bit_depth: 16,
    channels,
    language_config: { languages: ["en"] },
    messages_config: { receive_acknowledgments: true },
    session_config: { allowed: ["language_config"] }, // the client may switch languages
  }),
});
if (!created.ok) throw new Error(`${created.status} ${await created.text()}`);

const ws = new WebSocket((await created.json()).url);
ws.addEventListener("open", () => {
  const step = (sampleRate * channels * 2) / 10; // 100 ms of audio per chunk
  const half = pcm.length / 2;
  for (let start = 0; start < pcm.length; start += step) {
    if (start <= half && half < start + step) {
      // the caller switched to French
      const change = { language_config: { languages: ["fr"] } };
      ws.send(JSON.stringify({ type: "session_config", data: change }));
    }
    ws.send(pcm.subarray(start, start + step));
  }
  ws.send(JSON.stringify({ type: "stop_recording" }));
});
ws.addEventListener("message", ({ data }) => {
  const message = JSON.parse(data);
  if (message.type === "session_config") {
    if (!message.acknowledged) {
      console.error("settings not changed:", message.error);
      process.exitCode = 1;
    } else {
      console.log("settings changed from", message.data.effective_at, "s");
    }
  } else if (message.type === "transcript" && message.data.is_final) {
    const { language, text } = message.data.utterance;
    console.log(`[${language}] ${text}`);
  }
});
ws.addEventListener("error", () => {
  console.error("the WebSocket failed");
  process.exitCode = 1;
});

function readWav(path) {
  const file = readFileSync(path);
  let fmt, pcm;
  for (let pos = 12; pos < file.length; ) {
    const id = file.toString("ascii", pos, pos + 4);
    const size = file.readUInt32LE(pos + 4);
    if (id === "fmt ") fmt = { channels: file.readUInt16LE(pos + 10), sampleRate: file.readUInt32LE(pos + 12) };
    if (id === "data") pcm = file.subarray(pos + 8, pos + 8 + size);
    pos += 8 + size + (size % 2);
  }
  return { ...fmt, pcm };
}
```

**HTTP**

Create the session with `session_config`, stream its audio to the returned `url`
([Live WebSocket](/api-reference/v2/live/websocket/)), and send the `session_config` message on it as a text frame:

```bash
curl -X POST https://eu1.api.gladia.io/v2/live \
  -H "x-gladia-key: $GLADIA_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "encoding": "wav/pcm",
    "sample_rate": 16000,
    "bit_depth": 16,
    "channels": 1,
    "model": "solaria-3",
    "language_config": {
      "languages": [
        "en"
      ]
    },
    "messages_config": {
      "receive_acknowledgments": true
    },
    "session_config": {
      "allowed": [
        "language_config"
      ]
    }
  }'
```

```
[en] Hello, I'm calling about my order.
settings changed from 3.2 s
[fr] Je préfère continuer en français, si possible.
```

## Limits and gotchas

- **From the last final, not from the request.** The new settings apply to the utterance in progress and after: a
  final already sent keeps the settings it was transcribed with. To change the settings at a precise word, send
  [`finalize`](/live/finalize/) first.
- **One change at a time, one per second.** A request while another one is being applied, or within a second of the
  previous one, is refused: merge your changes into one request. A session takes 50 changes at most, and its changes
  may make the server transcribe 120 s of audio again at most (each one transcribes again what is not finalized yet:
  change the settings after a final, not in the middle of a long monologue). Turning speaker
  identification off while a change is being applied refuses the change: send it again.
- **A short pause.** While the server applies the change (usually under a second), no transcript arrives; the
  ones held meanwhile come right after, transcribed with the new settings. Keep streaming audio: nothing is lost.
- **The utterance in progress is transcribed again.** Its partials may restart from its beginning, with the new
  settings.
- **Name the fields you change.** An empty object (`{"realtime_processing": {}}`) is refused: it names nothing.
- **Until `stop_recording`.** A request sent while the session is still connecting waits for it, then applies
  from the start; a request sent after `stop_recording` is refused (one sent just before still applies to the audio
  left).
- **Billed from `effective_at`.** An add-on turned on is billed from the second the new settings apply; turned off,
  it stops being billed from there.
- **The license and the servers decide too.** A setting the license or the session's servers do not offer is refused
  as it would be at the init (for example a language or an add-on the model does not run).
- **Kept across reconnections.** A session that [reconnects](/live/reconnections/) goes on with its changed settings.
- **In the result.** `GET /v2/live/{id}` lists each change in `session_config_history`: its second and the settings
  it changed (`{"at": 42.18, "settings": ["language_config"]}`); its `request_params` show the settings in force.
- **64 KiB per request at most.** A larger `data` (a vocabulary of thousands of terms) is refused: send it at the init.
- **The administrator can turn it off** for the whole cluster (flag `live_reconfigure_enabled`): every request is
  then refused, and sessions go on with their init settings.
- **Not with Gladia's cloud API.** `session_config` is a Gladia Enterprise message: the cloud API ignores it.

## Troubleshooting

| symptom | cause | fix |
|---|---|---|
| `"settings changes are not enabled for this session ..."` | the init has no `session_config` | add `"session_config": {}` (or `allowed`) to the init body |
| `"not allowed for this session: pii ..."` | the setting is not in the init's `session_config.allowed` | add it to `allowed`, if the WebSocket's holder may change it |
| `"cannot change during a session: model"` | a setting that stays the init's | open a new session with it |
| `"unknown settings: language"` | a name that is not one of the init body's | use the init body's names: `language_config.languages` |
| `"a settings change is already in progress"` | two requests sent at once | merge them into one `session_config` |
| `"at most one settings change every 1 s"` | changes sent in a loop | send one request per change of the conversation |
| `"the session is stopping ..."` | sent after `stop_recording` | send it before; for the next session, set it at the init |
| no answer at all | `receive_acknowledgments` is off in `messages_config`, or the message was sent as a binary frame | turn acknowledgments on; send it as a text frame |

## Related pages

- [Force the final transcript at end of speech (live speech-to-text)](/live/finalize/)
- [Code switching](/languages/code-switching/)
- [Custom vocabulary](/features/custom-vocabulary/)
- [Live session reconnections](/live/reconnections/)
