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

# Mid-Session Updates

> Change language, voice, and turn-taking settings while a session is live

## Overview

You can update a persona's language, voice generation settings, and voice detection settings **during a live session** — no reconnect required.

Updates are sent over the data channel using `sendDataMessage()`.

<Note>
  Updates are best-effort. Where possible they take effect immediately; in some
  cases they are applied at the start of the next user turn.
</Note>

## Method Signature

```typescript theme={"system"}
sendDataMessage(message: string): void
```

## Basic Usage

Send a `persona_config` message containing only the fields you want to change:

```javascript theme={"system"}
anamClient.sendDataMessage(
  JSON.stringify({
    message_type: "persona_config",
    data: {
      voiceGenerationOptions: { speed: 1.1 },
    },
  }),
);
```

Include any combination of `languageCode`, `voiceGenerationOptions`, and `voiceDetectionOptions` inside `data`. Only the fields you send are changed — everything else keeps its current value.

## What you can update

### Language

Set `languageCode` to an [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) code:

```javascript theme={"system"}
anamClient.sendDataMessage(
  JSON.stringify({
    message_type: "persona_config",
    data: { languageCode: "fr" },
  }),
);
```

### Voice generation

Adjust speed, volume, emotion, and provider-specific settings. The available fields and their valid ranges depend on your voice provider and model — see [Voice Configuration](/docs/personas/voices/configuration) for the full list.

```javascript theme={"system"}
anamClient.sendDataMessage(
  JSON.stringify({
    message_type: "persona_config",
    data: {
      voiceGenerationOptions: { speed: 1.2, volume: 1.5 },
    },
  }),
);
```

### Voice detection

Adjust turn-taking and silence handling. See [Voice Detection](/docs/personas/session/voice-detection) for all options and ranges.

```javascript theme={"system"}
anamClient.sendDataMessage(
  JSON.stringify({
    message_type: "persona_config",
    data: {
      voiceDetectionOptions: { endOfSpeechSensitivity: 0.7 },
    },
  }),
);
```

## Validation

Updates are validated before they are applied:

* At least one field must be present — an empty `data: {}` is ignored.
* Unknown field names are rejected.
* Values must be within the valid range for your provider and model.
* Sending a voice generation field your provider or model doesn't support is rejected.

If an update is rejected, **the session continues** and the invalid update is dropped. The reason is delivered as a [`SERVER_WARNING`](/docs/javascript-sdk/reference/event-types) event:

```javascript theme={"system"}
import { AnamEvent } from "@anam-ai/js-sdk";

anamClient.addListener(AnamEvent.SERVER_WARNING, (message) => {
  console.warn("Config update rejected:", message);
});
```

## Prerequisites

Before sending an update, you must:

1. Have an active streaming session (call `stream()` or `streamToVideoElement()` first).
2. Have successfully connected to the Anam Engine.

## Next Steps

<CardGroup cols={2}>
  <Card title="Voice Configuration" icon="waveform" href="/docs/personas/voices/configuration">
    See every voice generation option and its valid range per provider
  </Card>

  <Card title="Voice Detection" icon="ear" href="/docs/personas/session/voice-detection">
    See every turn-taking and silence option
  </Card>

  <Card title="Event Types" icon="webhook" href="/docs/javascript-sdk/reference/event-types">
    Listen for `SERVER_WARNING` and other session events
  </Card>

  <Card title="User Messages" icon="message" href="/docs/javascript-sdk/reference/user-messages">
    Send messages and context programmatically
  </Card>
</CardGroup>
