Back to site
ProsodyAI Docs
TypeScript SDK

Client Configuration

Configure the ProsodyAI client

Client Configuration

The Prosody client accepts various configuration options to customize its behavior.

Constructor Options

import { Prosody } from '@prosody/sdk';

const client = new Prosody(options: ProsodyOptions);

ProsodyOptions

OptionTypeDefaultDescription
apiKeystringrequiredYour ProsodyAI API key
baseUrlstringhttps://api.prosody.aiAPI base URL
timeoutnumber30000Request timeout in milliseconds
retriesnumber3Number of retry attempts
verticalVerticalundefinedDefault vertical for all requests
streamingStreamingOptions{}Streaming configuration

StreamingOptions

OptionTypeDefaultDescription
reconnectbooleantrueAuto-reconnect on disconnect
reconnectDelaynumber1000Delay between reconnect attempts (ms)
maxReconnectAttemptsnumber5Maximum reconnect attempts
bufferSizenumber4096Audio buffer size in bytes
sampleRatenumber16000Audio sample rate (Hz)

Examples

Basic Configuration

const client = new Prosody({
  apiKey: process.env.PROSODY_API_KEY,
});

Full Configuration

const client = new Prosody({
  apiKey: process.env.PROSODY_API_KEY,
  baseUrl: 'https://api.prosody.ai',
  timeout: 60000,
  retries: 5,
  vertical: 'contact_center',
  streaming: {
    reconnect: true,
    reconnectDelay: 2000,
    maxReconnectAttempts: 10,
    bufferSize: 8192,
    sampleRate: 16000,
  },
});

Custom Endpoint (Self-Hosted)

const client = new Prosody({
  apiKey: process.env.PROSODY_API_KEY,
  baseUrl: 'https://prosody.your-company.com',
});

Environment Variables

The SDK automatically reads these environment variables:

VariableDescription
PROSODY_API_KEYAPI key (used if apiKey not provided)
PROSODY_BASE_URLBase URL (used if baseUrl not provided)
// Uses PROSODY_API_KEY from environment
const client = new Prosody({});

Methods

analyze(request)

Analyze a single audio segment.

const result = await client.analyze(request: AnalyzeRequest): Promise<AnalyzeResponse>;

stream(options)

Create a streaming session.

const stream = client.stream(options: StreamOptions): ProsodyStream;

createSession(options)

Create a conversation session for multi-turn tracking.

const session = client.createSession(options: SessionOptions): ConversationSession;

webhooks

Webhook management methods.

await client.webhooks.create(config: WebhookConfig): Promise<Webhook>;
await client.webhooks.list(): Promise<Webhook[]>;
await client.webhooks.delete(id: string): Promise<void>;

Always store your API key securely. Never commit it to version control or expose it in client-side code.