Reference
Errors
SDK error types, status codes, retries, and cancellation
ProsodyError
class ProsodyError extends Error {
statusCode: number;
responseBody?: unknown;
}| Status | Error type | Description |
|---|---|---|
| 401, 403 | AuthenticationError | Missing, invalid, expired, or unauthorized API key |
| 402 | ProsodyError | Credit balance below the required charge |
| 413 | ProsodyError | Upload exceeds the request limit |
| 422 | ValidationError | Request or audio validation failed |
| 429 | RateLimitError | Request exceeded its rate limit |
| 5xx | ProsodyError | API or upstream failure |
ValidationError
class ValidationError extends ProsodyError {
details?: Record<string, string[]>;
}RateLimitError
class RateLimitError extends ProsodyError {
retryAfterMs: number;
}Transport errors
class TimeoutError extends ProsodyError {}
class ConnectionError extends ProsodyError {}Transport errors use statusCode = 0.
Retries
The default policy retries status 408, 429, 500, 502, 503, and 504 twice with exponential backoff:
const prosody = new ProsodyClient({
apiKey,
retry: {
maxRetries: 4,
initialDelayMs: 500,
maxDelayMs: 10_000,
backoffMultiplier: 2,
},
});Cancellation
Request methods accept an AbortSignal as the final argument:
const controller = new AbortController();
const pending = prosody.transcribe(
'./call.wav',
undefined,
controller.signal,
);
controller.abort();
await pending;