Together AI
Text-to-speech with TogetherTTSService, streaming over Together AI's WebSocket API.
Overview
TogetherTTSService: streams text over a WebSocket to Together's speech endpoint and pushes 24 kHz PCM audio as it arrives.
Upstream page
Pipecat's documentation for the same service.
Source
packages/together/src/tts.ts.
Together AI docs
Voices, models and the WebSocket speech API.
Installation
bun add @pipedog/togetherimport { TogetherTTSService } from "@pipedog/together/tts";Prerequisites
- A Together AI account and an API key from Together AI.
- Pass the key as
apiKey. The examples read it fromTOGETHER_API_KEY.
TogetherTTSService
Connects to wss://api.together.ai/v1/audio/speech/websocket.
Configuration
Prop
Type
Settings
Runtime-updatable settings, passed as settings: new TogetherTTSService.Settings({...})
(TogetherTTSSettings). Any setting you leave out keeps the default below.
| Setting | Type | Default | Description |
|---|---|---|---|
model | string | "hexgrad/Kokoro-82M" | Speech model, sent in the URL. |
voice | string | "af_heart" | Voice, sent in the URL. |
language | Language | null | Language.EN | Language, sent in the URL. |
maxPartialLength | number | null | null | Maximum partial text length for streaming (max_partial_length). |
extraParams | Record<string, unknown> | null | null | Model-specific options sent in the session update, such as pronunciation_dict. |
Usage
import { TTSUpdateSettingsFrame } from "@pipedog/core/frames/frames";
import { TogetherTTSService } from "@pipedog/together/tts";
const tts = new TogetherTTSService({
apiKey: process.env.TOGETHER_API_KEY ?? "",
settings: new TogetherTTSService.Settings({ voice: "af_heart" }),
});Change settings mid-call with an TTSUpdateSettingsFrame:
// Queue it on the worker, or push it from a processor upstream of the service.
const update = new TTSUpdateSettingsFrame({
delta: new TogetherTTSService.Settings({ voice: "af_bella" }),
});Event handlers
| Event | Description |
|---|---|
on_connected | The WebSocket connected. |
on_disconnected | The WebSocket closed. |
Notes
- Together sends 24 kHz audio. Any other
sampleRatelogs a warning. - An interruption clears the text buffer (
input_text_buffer.clear); the end of a turn commits it. - Any settings change reconnects, since the session is configured in the connection URL.
Runtime notes
| Runtime | Works | What it needs |
|---|---|---|
| Bun | ✅ yes | Nothing. |
| Node.js | ✅ yes | Nothing. |
| Deno | ✅ yes | Nothing. |
| Cloudflare Workers | ✅ yes | Nothing. |
Generated from pipecat.runtimes and pipecat.compat in packages/together/package.json: ✅ means the compat smoke test passes on that runtime.
- The WebSocket goes through the core
websocketConnect. It works on Bun, Node, Deno and Cloudflare Workers. - Tested against a local WebSocket fake, not against Together AI itself.
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).