@soniox/node
v2.0.3
Published
Official Soniox SDK for Node
Readme
@soniox/node
Official Soniox SDK for Node
Installation
npm install @soniox/nodeGetting Started
import { SonioxNodeClient } from '@soniox/node';
const client = new SonioxNodeClient({
api_key: 'your-api-key', // or set SONIOX_API_KEY env var
});Environment variables
SonioxNodeClient reads the following environment variables when the
corresponding constructor option is not provided:
| Variable | Maps to option | Notes |
| --------------------- | ---------------------- | ------------------------------------------------------------ |
| SONIOX_API_KEY | api_key | Required if api_key is not passed explicitly. |
| SONIOX_REGION | region | Only 'eu' and 'jp' are defined; US is the default. |
| SONIOX_BASE_DOMAIN | base_domain | Overrides region and forms the default hosts. |
| SONIOX_API_BASE_URL | base_url | Overrides the REST API host (e.g. https://api.soniox.com). |
| SONIOX_WS_URL | realtime.ws_base_url | Overrides the STT realtime WebSocket URL. |
| SONIOX_TTS_API_URL | tts_api_url | Overrides the REST TTS host. |
| SONIOX_TTS_WS_URL | realtime.tts_ws_url | Overrides the TTS realtime WebSocket URL. |
Resolution precedence for every setting is:
- Explicit option passed to
new SonioxNodeClient({ ... }). - Environment variable from the table above.
- Value derived from
region/base_domain. - Root default (United States).
Error handling
REST calls (including REST TTS) throw SonioxHttpError on non-2xx
responses, network failures, and aborted requests.
import { SonioxNodeClient, SonioxHttpError } from '@soniox/node';
try {
const audio = await client.tts.generate({
text: 'Hello',
voice: 'Adrian',
language: 'en',
});
} catch (err) {
if (err instanceof SonioxHttpError) {
console.error(err.code, err.statusCode, err.bodyText);
}
}For the full documentation please go to our docs: Full Node SDK Documentation
