Skip to main content
POST
/
voice_designs
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});

const voiceDesign = await client.voiceDesigns.create({
  prompt: 'Speak in a warm, friendly tone',
  text: 'Hello, welcome to our service.',
});

console.log(voiceDesign.data);
{
  "data": {
    "record_type": "voice_design",
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "friendly-narrator",
    "version": 1,
    "text": "Hello, welcome.",
    "prompt": "Speak in a warm tone",
    "voice_sample_size": 48000,
    "version_created_at": "2024-01-01T00:00:00Z",
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request body for creating a new voice design or adding a version to an existing one. Omit voice_design_id to create a new design; include it to add a new version.

text
string
required

Sample text to synthesize for this voice design.

prompt
string
required

Natural language description of the voice style, e.g. 'Speak in a warm, friendly tone with a slight British accent'.

name
string

Name for the voice design. Required when creating a new design (voice_design_id is not provided); ignored when adding a version. Cannot be a UUID.

Required string length: 1 - 255
voice_design_id
string<uuid>

ID of an existing voice design to add a new version to. When provided, a new version is created instead of a new design.

language
string
default:Auto

Language for synthesis. Supported values: Auto, Chinese, English, Japanese, Korean, German, French, Russian, Portuguese, Spanish, Italian. Defaults to Auto.

temperature
number<float>

Sampling temperature controlling randomness. Higher values produce more varied output. Default: 0.9.

Required range: 0 <= x <= 2
top_k
integer

Top-k sampling parameter — limits the token vocabulary considered at each step. Default: 50.

Required range: 1 <= x <= 1000
top_p
number<float>

Top-p (nucleus) sampling parameter — cumulative probability cutoff for token selection. Default: 1.0.

Required range: 0 <= x <= 1
repetition_penalty
number<float>

Repetition penalty to reduce repeated patterns in generated audio. Default: 1.05.

Required range: 1 <= x <= 2
max_new_tokens
integer

Maximum number of tokens to generate. Default: 2048.

Required range: 100 <= x <= 4096

Response

Voice design created or new version added successfully.

Response envelope for a single voice design with full version detail.

data
object

A voice design object with full version detail.