Reference

ProsodyClient

Constructor and method reference

Constructor

import { ProsodyClient } from '@prosodyai/sdk';

const prosody = new ProsodyClient({
  apiKey: process.env.PROSODY_API_KEY!,
});
new ProsodyClient(config: ProsodyClientConfig | string)
OptionTypeDefault
apiKeystringrequired
baseUrlstringhttps://api.prosodyai.app
timeoutMsnumber30000
retryPartial<RetryConfig>2 retries, 500 ms initial delay
headersRecord<string, string>{}
debugbooleanfalse
onRequest(url, init) => voidNone
onResponse(url, response) => voidNone

A string config is shorthand for the API key:

const prosody = new ProsodyClient(process.env.PROSODY_API_KEY!);

transcribe

transcribe(
  audio: string | Buffer,
  options?: TranscribeOptions,
  signal?: AbortSignal,
): Promise<Transcription>

audio accepts a local path, an http(s) URL the API can fetch from a public address, or a Node.js Buffer.

OptionTypeDefault
languagestringen
sessionIdstringgenerated
diarizebooleantrue
prosodybooleantrue
const result = await prosody.transcribe('./call.wav');

stream.session

stream.session(options?: LiveSessionStartOptions & {
  onUpdate?, onError?, onClose?, onEvent?, WebSocketImpl?
}): LiveSession

Creates a stateful live session over WS /v1/stream/realtime that owns the WebSocket and maintains a Conversation.

const session = prosody.stream.session({
  encoding: 'pcm16',
  sampleRate: 16_000,
  onUpdate: (current) => render(current.snapshot()),
});

stream.connect

stream.connect(
  handlers?: ProsodyRealtimeHandlers,
  options?: {
    sessionId?, encoding?, sampleRate?, container?, analysisMode?, source?,
    sourceOffsetMs?, chunkSeconds?, capabilities?, WebSocketImpl?
  },
): ProsodyRealtimeStream

Creates the low-level live transport. Handlers receive parsed wire events and VoiceFrame objects (onVoiceFrame).

speakers

speakers.list(
  limit?: number,
  signal?: AbortSignal,
): Promise<SpeakerDirectoryResult>

speakers.previewEnrollment(
  audio: string | Buffer,
  signal?: AbortSignal,
): Promise<VoiceEnrollmentPreview>

speakers.confirmEnrollment(
  audio: string | Buffer,
  previewSha256: string,
  mappings: VoiceEnrollmentMapping[],
  signal?: AbortSignal,
): Promise<VoiceEnrollmentResult>

previewEnrollment returns diarized lanes without writing identity. confirmEnrollment persists the supplied lane-to-speaker mappings.

memory.recall

memory.recall.post(
  personId: string,
  topK?: number,
  signal?: AbortSignal,
): Promise<RecallResult>

Returns a saved person's top-K significant moments, recency-ranked, each with the measured facts that selected it.

Measurement helpers

import { measurementSeries, voiceFrames } from '@prosodyai/sdk';

voiceFrames(result: AnalysisResult): ProsodyTimelinePoint[]
measurementSeries(result: AnalysisResult, path: MeasurementPath): {
  start_ms: number; end_ms: number; speaker_id?: string; value: number;
}[]

voiceFrames returns the measured frames of a raw prosody.analyze() result. measurementSeries reads one quantity across the call by its family path, such as 'intonation.pitch' or 'stress.loudness', skipping frames where it was not measurable.

feedback

submitCorrection(
  options: FeedbackCorrectionOptions,
  signal?: AbortSignal,
): Promise<{ status: string }>

submitSessionOutcome(
  options: SessionOutcomeOptions,
  signal?: AbortSignal,
): Promise<{ status: string }>

On this page