Skip to main content

@kithjs/server

Standalone voice microservice. POST text, get streaming audio. Framework agnostic.

Install

bun add @kithjs/server

Or with Docker:

docker run -e ELEVENLABS_API_KEY=sk_... -p 3040:3040 kithjs/server

Quick Start

import { KithServer } from "@kithjs/server";

const server = new KithServer({
port: 3040,
characterDir: "./characters",
});

await server.start();

API

EndpointMethodDescription
/sessionsPOSTCreate session { characterId? }
/sessions/:id/speakPOSTSend text { text }
/sessions/:id/barge-inPOSTStop current TTS
/sessions/:id/eventsGETSSE event stream
/sessions/:idDELETEDestroy session
/ws?sessionId=xxxWSFull duplex WebSocket
/charactersGETList character profiles
/healthGETServer status

Environment Variables

VariableRequiredDefaultDescription
ELEVENLABS_API_KEYYesElevenLabs API key
ELEVENLABS_VOICE_IDNoDefault voice ID
ELEVENLABS_MODEL_IDNoeleven_v3TTS model
PORTNo3040Server port
KITH_CHARACTER_DIRNo./charactersCharacter profiles directory
KITH_DEFAULT_CHARACTERNoDefault character ID
KITH_PIPELINENoelevenlabsTTS pipeline

Character Profiles

Place VoiceCharacter JSON files in the characters directory:

characters/
kaori.json → characterId: "kaori"
apollo.json → characterId: "apollo"

Then create sessions with a character:

curl -X POST http://localhost:3040/sessions \
-H "Content-Type: application/json" \
-d '{"characterId": "kaori"}'