Skip to main content

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().
Updates are best-effort. Where possible they take effect immediately; in some cases they are applied at the start of the next user turn.

Method Signature

sendDataMessage(message: string): void

Basic Usage

Send a persona_config message containing only the fields you want to change:
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 code:
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 for the full list.
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 for all options and ranges.
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 event:
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

Voice Configuration

See every voice generation option and its valid range per provider

Voice Detection

See every turn-taking and silence option

Event Types

Listen for SERVER_WARNING and other session events

User Messages

Send messages and context programmatically
Last modified on June 17, 2026