Quickstart

Install @prosodyai/sdk, analyze a recording, and handle speakers, prosody, and billing errors in five minutes.

Install the SDK

npm install @prosodyai/sdk

Requires Node.js 18 or newer. Zero runtime dependencies.

Create an API key

Open API keys in the dashboard and create an organization key. Copy it immediately; the full secret is displayed once.

export PROSODY_API_KEY="psk_..."

Initialize the client

ProsodyClient reads PROSODY_API_KEY (or PROSODYAI_API_KEY) automatically, or accepts an explicit key.

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

const prosody = new ProsodyClient();

Analyze a recording

Pass a local path (.wav, .mp3, .m4a, .flac, .ogg), a Buffer, a Uint8Array, a Blob, or a public https:// URL.

const result = await prosody.transcribe('./call.wav');

console.log(result.text);

for (const turn of result.turns) {
  console.log({
    speaker: turn.speaker.label,
    startMs: turn.startMs,
    text: turn.text,
    pitchHz: turn.prosody?.state.intonation.pitch,
    loudnessDb: turn.prosody?.state.stress.loudness,
    loudnessShiftDb: turn.prosody?.change?.stress.loudness,
  });
}

Diarization and vocal measurements default on. Pass { prosody: false } to omit turn.prosody.

Read speaker baselines and handle balance errors

Every speaker in result.speakers holds the baseline that change values were measured against:

for (const speaker of result.speakers) {
  console.log(
    speaker.label,
    `${(speaker.talkShare * 100).toFixed(1)}%`,
    speaker.state.intonation.pitch?.median,
  );
}

Catch typed SDK errors in production code, especially InsufficientCreditsError (402) when a workspace balance drops below a request's cost:

import { InsufficientCreditsError, RateLimitError } from '@prosodyai/sdk';

try {
  await prosody.transcribe('./call.wav');
} catch (err) {
  if (err instanceof InsufficientCreditsError) {
    console.error('Balance too low:', err.balanceCents, 'need:', err.requiredCents);
  } else if (err instanceof RateLimitError) {
    console.error('Retry after ms:', err.retryAfterMs);
  }
}

Keep live traffic uninterrupted with auto-reload

Enable auto-reload under Billing in the dashboard. Whenever a balance drops below your threshold or cannot cover an incoming request, ProsodyAI triggers an off-session top-up against your saved payment method. See Credits and usage.

Next steps

On this page