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
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Your ProsodyAI API key |
baseUrl | string | https://api.prosody.ai | API base URL |
timeout | number | 30000 | Request timeout in milliseconds |
retries | number | 3 | Number of retry attempts |
vertical | Vertical | undefined | Default vertical for all requests |
streaming | StreamingOptions | {} | Streaming configuration |
StreamingOptions
| Option | Type | Default | Description |
|---|---|---|---|
reconnect | boolean | true | Auto-reconnect on disconnect |
reconnectDelay | number | 1000 | Delay between reconnect attempts (ms) |
maxReconnectAttempts | number | 5 | Maximum reconnect attempts |
bufferSize | number | 4096 | Audio buffer size in bytes |
sampleRate | number | 16000 | Audio 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:
| Variable | Description |
|---|---|
PROSODY_API_KEY | API key (used if apiKey not provided) |
PROSODY_BASE_URL | Base 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.