Reference

Models

Reference for the models config and the helpers for OpenAI, Anthropic, Google, Deepgram, Cartesia, ElevenLabs and AssemblyAI.

The models config picks the language model, speech to text and text to speech. Each slot takes a helper such as deepgram.stt({ model }), or a provider/model string. A helper returns a reference, never a client, and a key never goes in code: add the provider key under Connections in the dashboard.

Import from @voicelayer/sdk.

ModelsConfig

interface · @voicelayer/sdk

interface ModelsConfig

Which models the agent uses. Each slot takes a helper such as deepgram.stt({ model }), a provider/model string, or for llm a descriptor.

Fields

NameTypeRequiredDescription
llmstring | ModelConfig | ModelDescriptornoThe language model: openai.llm({ model }) and its siblings, a provider/model string, or a descriptor such as { provider, id }.
sttstring | SttConfignoSpeech to text: deepgram.stt({ model }) and its siblings, or a provider/model string.
ttsstring | VoiceConfignoText to speech: deepgram.tts({ model }) and its siblings, or a provider/model string.
realtimeRealtimeConfignoA speech-to-speech model (openai.realtime, google.realtime) that replaces the stt, llm and tts chain.
turnDetection'vad' | 'model'noHow the end of the caller's turn is found. model uses a turn-detection model chosen by language; vad listens for silence.
languagestringnoThe agent's main language as a BCP 47 tag such as en or gu-IN: the greeting, and the fallback when nothing is detected.
additionalLanguagesreadonly string[]noThe other languages the agent serves. Callers may mix them; the agent follows them as languageSwitching says.
languageSwitching'listed' | 'any' | 'off'noWhat happens when the caller speaks another language: listed (default) follows them among the listed languages, any follows them into any language the transcriber hears, off always answers in the main language.
languageOverridesReadonly<Record<string, { readonly voice?: VoiceConfig; readonly stt?: SttConfig; readonly firstMessage?: string }>>noPer listed language: voice, a different stt (used for the call's starting language) and the firstMessage greeting. Anything left out uses the agent's own.
speechFallback'platform' | 'none'noWhether another speech provider takes over when the agent's own fails: platform or none. Left out, it depends on whose key the agent runs on.
lineOverridesReadonly<Record<string, Readonly<Record<string, string>>>>noThe lines the platform speaks by itself, in your own words: language, then line id, then text. They win over the platform's own.
decisionstring | DecisionConfignoThe model that makes the flow's routing decisions: a VoiceLayer decision-model id such as 'openai/gpt-6-luna-decisions', or { model }. Leave it out for the platform default. It always runs on VoiceLayer's keys and is free; declaring it here makes the dashboard's "Routing decisions" setting read-only. An id VoiceLayer does not offer is refused at upload.

ModelDescriptor

interface · @voicelayer/sdk

interface ModelDescriptor

Names a model the way the AI SDK does, in a form that can be saved: { provider: 'anthropic', id: 'claude-haiku-4-5' }. An AI SDK model such as anthropic('claude-…') is accepted in its place; only its provider and model id are read. The provider key stays in the workspace's Connections vault, so a descriptor carries none.

Fields

NameTypeRequiredDescription
provider'openai' | 'anthropic' | 'google' | 'gemini' | (string & {})yesThe model provider, for example openai, anthropic or google.
idstringnoThe provider's model id.
modelIdstringnoThe model id under the name the AI SDK uses; id and modelId mean the same.
optionsobjectnoSampling settings for the model.
options.temperaturenumbernoSampling temperature.
options.maxOutputTokensnumbernoThe most tokens the model may produce in one reply.
options.topPnumbernoNucleus sampling cutoff.

openai

namespace · @voicelayer/sdk

const openai

OpenAI models, for the llm, tts and realtime slots of models.

llm

openai.llm(options?: { model?, temperature?, maxOutputTokens?, topP? }): { provider: string; model: string; temperature?: number | undefined; maxOutputTokens?: number | undefined; topP?: number | undefined; }

A language model from OpenAI.

Parameters
NameTypeRequiredDefaultDescription
optionsobjectnomodel and sampling settings.
options.modelstringno'gpt-4o-mini'The model id.
options.temperaturenumbernoSampling temperature. Lower is more predictable.
options.maxOutputTokensnumbernoThe most tokens the model may produce in one reply.
options.topPnumbernoNucleus sampling cutoff.
Returns

{ provider: string; model: string; temperature?: number | undefined; maxOutputTokens?: number | undefined; topP?: number | undefined; }: A language-model reference for models.llm.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { llm: openai.llm({ model: 'gpt-4o-mini', temperature: 0.3 }) }

tts

openai.tts(options?: { model?, voice? }): { provider: string; voiceId: string; model?: string | undefined; connectionId?: string | undefined; rate?: number | undefined; }

Text to speech with OpenAI.

Parameters
NameTypeRequiredDefaultDescription
optionsobjectnomodel and voice.
options.modelstringno'tts-1'The OpenAI speech model.
options.voicestringno'alloy'The voice name.
Returns

{ provider: string; voiceId: string; model?: string | undefined; connectionId?: string | undefined; rate?: number | undefined; }: A text-to-speech reference for models.tts.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { tts: openai.tts({ voice: 'alloy' }) }

realtime

openai.realtime(options?: { model?, voice? }): { provider: string; model: string; temperature?: number | undefined; voice?: string | undefined; }

A speech-to-speech model from OpenAI, which replaces the separate stt, llm and tts chain.

Parameters
NameTypeRequiredDefaultDescription
optionsobjectnomodel and voice.
options.modelstringno'gpt-4o-realtime-preview'The realtime model id.
options.voicestringnoThe voice name.
Returns

{ provider: string; model: string; temperature?: number | undefined; voice?: string | undefined; }: A realtime reference for models.realtime.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { realtime: openai.realtime({ voice: 'alloy' }) }

anthropic

namespace · @voicelayer/sdk

const anthropic

Anthropic models, for the llm slot of models.

llm

anthropic.llm(options?: { model?, temperature?, maxOutputTokens?, topP? }): { provider: string; model: string; temperature?: number | undefined; maxOutputTokens?: number | undefined; topP?: number | undefined; }

A language model from Anthropic.

Parameters
NameTypeRequiredDefaultDescription
optionsobjectnomodel and sampling settings.
options.modelstringno'claude-sonnet-5-5'The model id.
options.temperaturenumbernoSampling temperature. Lower is more predictable.
options.maxOutputTokensnumbernoThe most tokens the model may produce in one reply.
options.topPnumbernoNucleus sampling cutoff.
Returns

{ provider: string; model: string; temperature?: number | undefined; maxOutputTokens?: number | undefined; topP?: number | undefined; }: A language-model reference for models.llm.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { llm: anthropic.llm({ model: 'claude-sonnet-5-5' }) }

google

namespace · @voicelayer/sdk

const google

Google models, for the llm and realtime slots of models.

llm

google.llm(options?: { model?, temperature?, maxOutputTokens?, topP? }): { provider: string; model: string; temperature?: number | undefined; maxOutputTokens?: number | undefined; topP?: number | undefined; }

A language model from Google (Gemini).

Parameters
NameTypeRequiredDefaultDescription
optionsobjectnomodel and sampling settings.
options.modelstringno'gemini-3.8-flash'The model id.
options.temperaturenumbernoSampling temperature. Lower is more predictable.
options.maxOutputTokensnumbernoThe most tokens the model may produce in one reply.
options.topPnumbernoNucleus sampling cutoff.
Returns

{ provider: string; model: string; temperature?: number | undefined; maxOutputTokens?: number | undefined; topP?: number | undefined; }: A language-model reference for models.llm.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { llm: google.llm({ model: 'gemini-3.8-flash' }) }

realtime

google.realtime(options?: { model?, voice? }): { provider: string; model: string; temperature?: number | undefined; voice?: string | undefined; }

A speech-to-speech model from Google, which replaces the separate stt, llm and tts chain.

Parameters
NameTypeRequiredDefaultDescription
optionsobjectnomodel and voice.
options.modelstringno'gemini-3.1-flash-live-preview'The realtime model id.
options.voicestringnoThe voice name.
Returns

{ provider: string; model: string; temperature?: number | undefined; voice?: string | undefined; }: A realtime reference for models.realtime.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { realtime: google.realtime() }

deepgram

namespace · @voicelayer/sdk

const deepgram

Deepgram speech models, for the stt and tts slots of models.

stt

deepgram.stt(options?: { model?, language? }): { provider: string; model?: string | undefined; language?: string | undefined; endOfTurnConfidence?: number | undefined; endOfTurnTimeoutMs?: number | undefined; keywords?: string[] | undefined; connectionId?: string | undefined; }

Speech to text with Deepgram.

Parameters
NameTypeRequiredDefaultDescription
optionsobjectnomodel and language.
options.modelstringno'nova-3'The Deepgram model id.
options.languagestringnoThe spoken language as a BCP 47 code, such as en or es.
Returns

{ provider: string; model?: string | undefined; language?: string | undefined; endOfTurnConfidence?: number | undefined; endOfTurnTimeoutMs?: number | undefined; keywords?: string[] | undefined; connectionId?: string | undefined; }: A speech-to-text reference for models.stt.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { stt: deepgram.stt({ model: 'nova-3', language: 'en' }) }

tts

deepgram.tts(options?: { model? }): { provider: string; voiceId: string; model?: string | undefined; connectionId?: string | undefined; rate?: number | undefined; }

Text to speech with Deepgram. The voice is part of the model id, such as aura-2-harmonia-en.

Parameters
NameTypeRequiredDefaultDescription
optionsobjectnomodel, the Deepgram voice model id.
options.modelstringno'aura-2-harmonia-en'The Deepgram voice model id.
Returns

{ provider: string; voiceId: string; model?: string | undefined; connectionId?: string | undefined; rate?: number | undefined; }: A text-to-speech reference for models.tts.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { tts: deepgram.tts({ model: 'aura-2-harmonia-en' }) }

cartesia

namespace · @voicelayer/sdk

const cartesia

Cartesia models, for the tts and stt slots of models.

tts

cartesia.tts(options?: { voice?, model? }): { provider: string; voiceId: string; model?: string | undefined; connectionId?: string | undefined; rate?: number | undefined; }

Text to speech with Cartesia.

Parameters
NameTypeRequiredDescription
optionsobjectnovoice, which is required, and model.
options.voicestringnoThe Cartesia voice id. Required.
options.modelstringnoThe Cartesia model id.
Returns

{ provider: string; voiceId: string; model?: string | undefined; connectionId?: string | undefined; rate?: number | undefined; }: A text-to-speech reference for models.tts.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
  • TypeError when voice is missing.
Example
models: { tts: cartesia.tts({ voice: 'your-voice-id' }) }

stt

cartesia.stt(options?: { model?, language? }): { provider: string; model?: string | undefined; language?: string | undefined; endOfTurnConfidence?: number | undefined; endOfTurnTimeoutMs?: number | undefined; keywords?: string[] | undefined; connectionId?: string | undefined; }

Speech to text with Cartesia.

Parameters
NameTypeRequiredDescription
optionsobjectnomodel and language.
options.modelstringnoThe Cartesia model id.
options.languagestringnoThe spoken language as a BCP 47 code.
Returns

{ provider: string; model?: string | undefined; language?: string | undefined; endOfTurnConfidence?: number | undefined; endOfTurnTimeoutMs?: number | undefined; keywords?: string[] | undefined; connectionId?: string | undefined; }: A speech-to-text reference for models.stt.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { stt: cartesia.stt({ language: 'en' }) }

elevenlabs

namespace · @voicelayer/sdk

const elevenlabs

ElevenLabs models, for the tts slot of models.

tts

elevenlabs.tts(options?: { voice?, model? }): { provider: string; voiceId: string; model?: string | undefined; connectionId?: string | undefined; rate?: number | undefined; }

Text to speech with ElevenLabs.

Parameters
NameTypeRequiredDescription
optionsobjectnovoice, which is required, and model.
options.voicestringnoThe ElevenLabs voice id. Required.
options.modelstringnoThe ElevenLabs model id.
Returns

{ provider: string; voiceId: string; model?: string | undefined; connectionId?: string | undefined; rate?: number | undefined; }: A text-to-speech reference for models.tts.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
  • TypeError when voice is missing.
Example
models: { tts: elevenlabs.tts({ voice: 'your-voice-id' }) }

assemblyai

namespace · @voicelayer/sdk

const assemblyai

AssemblyAI models, for the stt slot of models.

stt

assemblyai.stt(options?: { language? }): { provider: string; model?: string | undefined; language?: string | undefined; endOfTurnConfidence?: number | undefined; endOfTurnTimeoutMs?: number | undefined; keywords?: string[] | undefined; connectionId?: string | undefined; }

Speech to text with AssemblyAI.

Parameters
NameTypeRequiredDescription
optionsobjectnolanguage.
options.languagestringnoThe spoken language as a BCP 47 code.
Returns

{ provider: string; model?: string | undefined; language?: string | undefined; endOfTurnConfidence?: number | undefined; endOfTurnTimeoutMs?: number | undefined; keywords?: string[] | undefined; connectionId?: string | undefined; }: A speech-to-text reference for models.stt.

Throws
  • TypeError when apiKey or baseURL is passed: a key never travels in the agent's definition, so add the provider key under Connections in the dashboard.
Example
models: { stt: assemblyai.stt({ language: 'en' }) }