Skip to content

CompositeVoiceConfig<TProviders>

Main configuration type for the CompositeVoice SDK.

Defined in: src/core/types/config.ts:614

Main configuration type for the CompositeVoice SDK.

Remarks

This is the top-level configuration object passed to the CompositeVoice constructor. It accepts a flat providers array containing all pipeline providers, plus optional settings for queue buffering, reconnection, logging, turn-taking, conversation history, eager LLM, error recovery, and custom extensions.

The providers array replaces the old { stt, llm, tts } pattern, enabling multi-role providers (e.g., NativeSTT covering both 'input' and 'stt' roles) and explicit audio I/O providers (e.g., MicrophoneInput, BrowserAudioOutput).

All optional fields have sensible defaults that are applied automatically by the SDK.

Examples

import { CompositeVoice, NativeSTT, AnthropicLLM, NativeTTS } from 'composite-voice';

const agent = new CompositeVoice({
  providers: [
    new NativeSTT(),
    new AnthropicLLM({ proxyUrl: '/api/proxy/anthropic', model: 'claude-haiku-4-5' }),
    new NativeTTS(),
  ],
  conversationHistory: { enabled: true, maxTurns: 10 },
  logging: { enabled: true, level: 'debug' },
});
import {
  CompositeVoice,
  MicrophoneInput,
  DeepgramSTT,
  AnthropicLLM,
  DeepgramTTS,
  BrowserAudioOutput,
} from 'composite-voice';

const agent = new CompositeVoice({
  providers: [
    new MicrophoneInput({ sampleRate: 16000 }),
    new DeepgramSTT({ proxyUrl: '/api/proxy/deepgram' }),
    new AnthropicLLM({ proxyUrl: '/api/proxy/anthropic', model: 'claude-haiku-4-5' }),
    new DeepgramTTS({ proxyUrl: '/api/proxy/deepgram' }),
    new BrowserAudioOutput(),
  ],
  queue: {
    input: { maxSize: 2000 },
    output: { maxSize: 500 },
  },
});

See

Type Parameters

Type ParameterDefault type
TProviders extends readonly BaseProvider[]BaseProvider[]

Properties

PropertyTypeDescriptionDefined in
autoRecover?booleanWhether to enable automatic error recovery. Remarks When true, the SDK attempts to recover from provider errors automatically (e.g., reinitializing a crashed provider) instead of propagating the error immediately.src/core/types/config.ts:795
conversationHistory?ConversationHistoryConfigConversation history configuration. Remarks When enabled, previous turns are sent to the LLM as context for multi-turn conversations. See ConversationHistoryConfigsrc/core/types/config.ts:692
eagerLLM?EagerLLMConfigEager LLM configuration. Remarks When enabled, the LLM starts speculatively on STT preflight events, reducing speech-to-first-token latency. See EagerLLMConfigsrc/core/types/config.ts:728
extra?Record<string, unknown>Additional custom configuration for provider-specific or application-specific needs. Remarks This catch-all record allows you to pass arbitrary data through the configuration without extending the type. Providers can read from this via the config object.src/core/types/config.ts:834
guardrails?GuardrailsConfigGuardrails applied to LLM output before it reaches the TTS provider. Remarks A chain of pluggable async filters — moderation, PII redaction, pronunciation fixes — that can rewrite or suppress text on its way to speech: [LLM] → [Guardrails] → [TTS] → OutputQueue → [OutputProvider] Guardrails change only what is spoken. llm.chunk and llm.complete still carry the raw model output, so chat transcripts are unaffected; subscribe to guardrail.applied / guardrail.blocked to reflect the filtered text in a UI. Omit this field (or supply an empty filters array) and the guardrail code path is skipped entirely. See - GuardrailsConfig - Guardrailsrc/core/types/config.ts:785
ioContext?{ enabled?: boolean; format?: "frontmatter" | "prose"; includeFormatGuidance?: boolean; }I/O context configuration. Remarks Controls the system message prepended to every LLM request that tells the model about the current input/output modality (voice vs text). - enabled (default: true) — include the I/O context message - format ('frontmatter''prose', default: 'frontmatter') — how the context is formatted in the system message - includeFormatGuidance (default: true) — include instructions about response format (no markdown for voice, etc.) The frontmatter format uses YAML-style --- delimiters so the context is structured and easy to inspect in conversation history.
ioContext.enabled?booleanWhether to include I/O context in LLM requests.src/core/types/config.ts:712
ioContext.format?"frontmatter" | "prose"Format for the context message.src/core/types/config.ts:714
ioContext.includeFormatGuidance?booleanInclude response format guidance (no markdown, etc.).src/core/types/config.ts:716
logging?LoggingConfigLogging configuration. Remarks Defaults to DEFAULT_LOGGING_CONFIG when not specified. See LoggingConfigsrc/core/types/config.ts:671
pipeline?{ maxPendingChunks?: number; }Pipeline tuning options. Remarks Controls flow between pipeline stages. Currently supports backpressure between LLM and Live TTS providers.src/core/types/config.ts:748
pipeline.maxPendingChunks?numberMaximum text chunks buffered between LLM and TTS before pausing LLM generation. Remarks Only applies to Live (WebSocket) TTS providers. REST TTS receives the full response at once and is unaffected. When not set, no backpressure is applied (default behavior).src/core/types/config.ts:759
providersTProvidersArray of provider instances for the voice pipeline. Remarks Each provider declares its roles property indicating which pipeline slots it covers. The SDK resolves the 5-role pipeline (input, stt, llm, tts, output) from this array: - Multi-role providers (e.g., NativeSTT with roles: ['input', 'stt']) cover multiple slots with a single instance. - Single-role providers (e.g., MicrophoneInput with roles: ['input']) cover exactly one slot. - The llm role is always required. - When input+stt are uncovered, defaults to NativeSTT(). - When tts+output are uncovered, defaults to NativeTTS(). See BaseProvider for the interface all providers implementsrc/core/types/config.ts:633
queue?{ input?: Partial<AudioBufferQueueConfig>; output?: Partial<AudioBufferQueueConfig>; }Queue configuration for input and output audio buffer queues. Remarks When separate input and STT providers are used (e.g., MicrophoneInput + DeepgramSTT), an AudioBufferQueue buffers audio between them to prevent frame loss during STT connection. Similarly for TTS + output. This config lets you tune queue sizes and overflow behavior. See AudioBufferQueueConfigsrc/core/types/config.ts:646
queue.input?Partial<AudioBufferQueueConfig>Configuration overrides for the input→STT buffer queue.src/core/types/config.ts:648
queue.output?Partial<AudioBufferQueueConfig>Configuration overrides for the TTS→output buffer queue.src/core/types/config.ts:650
reconnection?ReconnectionConfigWebSocket reconnection configuration. Remarks Defaults to DEFAULT_RECONNECTION_CONFIG when not specified. See ReconnectionConfigsrc/core/types/config.ts:661
recovery?RecoveryStrategyRecovery strategy configuration for automatic error recovery. Remarks Only applies when autoRecover is true. Controls the backoff behavior when the SDK attempts to recover from provider errors. See RecoveryStrategysrc/core/types/config.ts:824
tools?{ definitions: LLMToolDefinition[]; onToolCall: (toolCall) => Promise<LLMToolResult>; }Tool use configuration for LLM function calling. Remarks When provided, the LLM can invoke tools during generation. Text output is streamed to TTS as usual, while tool calls are handled via the onToolCall callback. After tool execution, the LLM is called again with the tool result to generate a natural language follow-up. Requires the LLM provider to implement ToolAwareLLMProvider.src/core/types/config.ts:808
tools.definitionsLLMToolDefinition[]-src/core/types/config.ts:809
tools.onToolCall(toolCall) => Promise<LLMToolResult>-src/core/types/config.ts:810
turnTaking?TurnTakingConfigTurn-taking behavior configuration. Remarks Defaults to DEFAULT_TURN_TAKING_CONFIG when not specified. See TurnTakingConfigsrc/core/types/config.ts:681
vad?VADConfigLocal voice-activity-detection configuration. Remarks When provided (and not explicitly disabled), a local VAD model scores the input audio for provider-independent barge-in and speech events. See VADConfigsrc/core/types/config.ts:739

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency