Types
Soniox Node SDK — Types Reference
AudioData
Audio data types accepted by sendAudio. In Node.js, Buffer is also accepted since Buffer extends Uint8Array.
AudioFormat
Supported audio formats for real-time transcription.
CleanupTarget
Resource types that can be cleaned up after transcription completes.
'file'- The uploaded file'transcription'- The transcription record
ContextGeneralEntry
Key-value pair for general context information.
Properties
| Property | Type | Description |
|---|---|---|
key | string | The key describing the context type (e.g., "domain", "topic", "doctor"). |
value | string | The value for the context key. |
ContextTranslationTerm
Custom translation term mapping.
Properties
| Property | Type | Description |
|---|---|---|
source | string | The source term to translate. |
target | string | The target translation for the term. |
CreateTranscriptionOptions
Options for creating a transcription.
Properties
| Property | Type | Description |
|---|---|---|
audio_url? | string | URL of a publicly accessible audio file. Max Length 4096 |
client_reference_id? | string | Optional tracking identifier. Max Length 256 |
context? | TranscriptionContext | Additional context to improve transcription accuracy and formatting of specialized terms. |
enable_language_identification? | boolean | Enable automatic language identification. |
enable_speaker_diarization? | boolean | Enable speaker diarization to identify different speakers. |
file_id? | string | ID of a previously uploaded file. Format uuid |
language_hints? | string[] | Array of expected ISO language codes to bias recognition. |
language_hints_strict? | boolean | When true, model relies more heavily on language hints. |
model | string | Speech-to-text model to use. Max Length 32 |
translation? | TranslationConfig | Translation configuration. |
webhook_auth_header_name? | string | Name of the authentication header sent with webhook notifications. Max Length 256 |
webhook_auth_header_value? | string | Authentication header value sent with webhook notifications. Max Length 256 |
webhook_url? | string | URL to receive webhook notifications when transcription is completed or fails. Max Length 256 |
DeleteAllFilesOptions
Options for purging all files.
Properties
| Property | Type | Description |
|---|---|---|
signal? | AbortSignal | AbortSignal for cancelling the delete_all operation. |
DeleteAllTranscriptionsOptions
Options for deleting all transcriptions.
Properties
| Property | Type | Description |
|---|---|---|
on_progress? | (transcription, index) => void | Callback invoked before each transcription is deleted. Receives the transcription data and its 0-based index. |
signal? | AbortSignal | AbortSignal for cancelling the delete_all operation. |
ExpressLikeRequest
Express/Connect-style request object
Properties
| Property | Type |
|---|---|
body? | unknown |
headers | Record<string, string | string[] | undefined> |
method | string |
FastifyLikeRequest
Fastify-style request object
Properties
| Property | Type |
|---|---|
body? | unknown |
headers | Record<string, string | string[] | undefined> |
method | string |
FileIdentifier
File identifier - either a string ID or an object with an id property.
HandleWebhookOptions
Options for the handleWebhook function
Properties
| Property | Type | Description |
|---|---|---|
auth? | WebhookAuthConfig | Optional authentication configuration |
body | unknown | Request body (parsed JSON or raw string) |
headers | WebhookHeaders | Request headers |
method | string | HTTP method of the request |
HonoLikeContext
Hono context object
Properties
| Property | Type |
|---|---|
req | { method: string; header: string | undefined; json: Promise<unknown>; } |
req.method | string |
req.header | string | undefined |
req.json | Promise<unknown> |
HttpErrorCode
Error codes for HTTP client errors
HttpMethod
HTTP methods supported by the client
HttpRequestBody
Request body types
HttpResponseType
Response types
ListFilesOptions
Options for listing files.
Properties
| Property | Type | Description |
|---|---|---|
cursor? | string | Pagination cursor for the next page of results. |
limit? | number | Maximum number of files to return. Default 1000 Minimum 1 Maximum 1000 |
signal? | AbortSignal | AbortSignal for cancelling the request |
ListFilesResponse<T>
Response from listing files.
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Type | Description |
|---|---|---|
files | T[] | List of uploaded files. |
next_page_cursor | string | null | A pagination token that references the next page of results. When null, no additional results are available. |
ListTranscriptionsOptions
Options for listing transcriptions
Properties
| Property | Type | Description |
|---|---|---|
cursor? | string | Pagination cursor for the next page of results |
limit? | number | Maximum number of transcriptions to return. Default 1000 Minimum 1 Maximum 1000 |
ListTranscriptionsResponse<T>
Response from listing transcriptions.
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Type | Description |
|---|---|---|
next_page_cursor | string | null | A pagination token that references the next page of results. When null, no additional results are available. TODO: potentially can be undefined? |
transcriptions | T[] | List of transcriptions. |
NestJSLikeRequest
NestJS-style request object (uses Express under the hood by default)
Properties
| Property | Type |
|---|---|
body? | unknown |
headers | Record<string, string | string[] | undefined> |
method | string |
OneWayTranslationConfig
One-way translation configuration. Translates all spoken languages into a single target language.
Properties
| Property | Type | Description |
|---|---|---|
target_language | string | Target language code for translation (e.g., "fr", "es", "de"). |
type | "one_way" | Translation type. |
QueryParams
Query parameters
RealtimeClientOptions
Real-time API configuration options for the client.
Properties
| Property | Type | Description |
|---|---|---|
api_key | string | API key for real-time sessions. |
default_session_options? | SttSessionOptions | Default session options applied to all real-time sessions. Can be overridden per-session. |
ws_base_url | string | WebSocket base URL for real-time connections. Default 'wss://stt-rt.soniox.com/transcribe-websocket' |
RealtimeErrorCode
Error codes for Real-time (WebSocket) API errors
RealtimeEvent
Typed event for async iterator consumption.
RealtimeOptions
Real-time configuration options for the main client.
Properties
| Property | Type | Description |
|---|---|---|
default_session_options? | SttSessionOptions | Default session options applied to all real-time sessions. Can be overridden per-session. |
ws_base_url? | string | WebSocket base URL for real-time connections. Falls back to SONIOX_WS_URL environment variable, then to 'wss://stt-rt.soniox.com/transcribe-websocket'. |
RealtimeResult
A result message from the real-time WebSocket.
Properties
| Property | Type | Description |
|---|---|---|
final_audio_proc_ms | number | Milliseconds of audio that have been finalized. |
finished? | boolean | Whether this is the final result (session ending). |
tokens | RealtimeToken[] | Tokens in this result. |
total_audio_proc_ms | number | Total milliseconds of audio processed. |
RealtimeSegment
A segment of contiguous real-time tokens grouped by speaker/language.
Properties
| Property | Type | Description |
|---|---|---|
end_ms? | number | End time of the segment in milliseconds (from last token). |
language? | string | Detected language code (if language identification enabled). |
speaker? | string | Speaker identifier (if diarization enabled). |
start_ms? | number | Start time of the segment in milliseconds (from first token). |
text | string | Concatenated text of all tokens in this segment. |
tokens | RealtimeToken[] | Original tokens in this segment. |
RealtimeSegmentBufferOptions
Options for rolling real-time segmentation buffers.
Properties
| Property | Type | Description |
|---|---|---|
final_only? | boolean | When true, only tokens marked as final are buffered. Default true |
group_by? | SegmentGroupKey[] | Fields to group by. A new segment starts when any of these fields changes Default ['speaker', 'language'] |
max_ms? | number | Maximum time window to keep in milliseconds (requires token timings). |
max_tokens? | number | Maximum number of tokens to keep in the buffer. Default 2000 |
RealtimeSegmentOptions
Options for segmenting real-time tokens.
Properties
| Property | Type | Description |
|---|---|---|
final_only? | boolean | When true, only tokens marked as final are included. Default false |
group_by? | SegmentGroupKey[] | Fields to group by. A new segment starts when any of these fields changes Default ['speaker', 'language'] |
RealtimeToken
A single token from the real-time transcription.
Properties
| Property | Type | Description |
|---|---|---|
confidence | number | Confidence score (0.0 to 1.0). |
end_ms? | number | End time in milliseconds relative to audio start. |
is_final | boolean | Whether this is a finalized token. |
language? | string | Detected language code (if language identification enabled). |
source_language? | string | Source language for translated tokens. |
speaker? | string | Speaker identifier (if diarization enabled). |
start_ms? | number | Start time in milliseconds relative to audio start. |
text | string | The transcribed text. |
translation_status? | "none" | "original" | "translation" | Translation status of this token. |
RealtimeUtterance
A single utterance built from real-time segments.
Properties
| Property | Type | Description |
|---|---|---|
end_ms? | number | End time of the utterance in milliseconds (from last segment). |
final_audio_proc_ms? | number | Milliseconds of audio that have been finalized at flush time. |
language? | string | Detected language code when consistent across segments. |
segments | RealtimeSegment[] | Segments included in this utterance. |
speaker? | string | Speaker identifier when consistent across segments. |
start_ms? | number | Start time of the utterance in milliseconds (from first segment). |
text | string | Concatenated text of all segments in this utterance. |
tokens | RealtimeToken[] | Tokens included in this utterance. |
total_audio_proc_ms? | number | Total milliseconds of audio processed at flush time. |
RealtimeUtteranceBufferOptions
Options for buffering real-time utterances.
Properties
| Property | Type | Description |
|---|---|---|
final_only? | boolean | When true, only tokens marked as final are buffered. Default true |
group_by? | SegmentGroupKey[] | Fields to group by. A new segment starts when any of these fields changes Default ['speaker', 'language'] |
max_ms? | number | Maximum time window to keep in milliseconds (requires token timings). |
max_tokens? | number | Maximum number of tokens to keep in the buffer. Default 2000 |
SegmentGroupKey
Fields that can be used to group tokens into segments
SegmentTranscriptOptions
Options for segmenting a transcript
Properties
| Property | Type | Description |
|---|---|---|
group_by? | SegmentGroupKey[] | Fields to group by. A new segment starts when any of these fields changes Default ['speaker', 'language'] |
SendStreamOptions
Options for streaming audio from an async iterable source.
Properties
| Property | Type | Description |
|---|---|---|
finish? | boolean | When true, calls finish() automatically after the stream ends. Default false |
pace_ms? | number | Delay in milliseconds between sending chunks. Useful for simulating real-time pace when streaming pre-recorded files. Not needed for live audio sources. |
SonioxErrorCode
All possible SDK error codes (core real-time + HTTP-specific codes)
SonioxFileData
Raw file metadata from the API.
Properties
| Property | Type | Description |
|---|---|---|
client_reference_id? | string | null | Optional tracking identifier string. |
created_at | string | UTC timestamp indicating when the file was uploaded. Format date-time |
filename | string | Name of the file. |
id | string | Unique identifier of the file. Format uuid |
size | number | Size of the file in bytes. |
SonioxLanguage
Properties
| Property | Type | Description |
|---|---|---|
code | string | 2-letter language code. |
name | string | Language name. |
SonioxModel
Properties
| Property | Type | Description |
|---|---|---|
aliased_model_id | string | null | If this is an alias, the id of the aliased model. Null for non-alias models. |
context_version | number | null | Version of context supported. |
id | string | Unique identifier of the model. |
languages | SonioxLanguage[] | List of languages supported by the model. |
name | string | Name of the model. |
one_way_translation | string | null | When contains string 'all_languages', any laguage from languages can be used |
supports_language_hints_strict | boolean | TODO: Add documentation |
supports_max_endpoint_delay | boolean | - |
transcription_mode | SonioxTranscriptionMode | Transcription mode of the model. |
translation_targets | SonioxTranslationTarget[] | List of supported one-way translation targets. If list is empty, check for one_way_translation field |
two_way_translation | string | null | When contains string 'all_languages',' any laguage pair from languages can be used |
two_way_translation_pairs | string[] | List of supported two-way translation pairs. If list is empty, check for two_way_translation field |
SonioxNodeClientOptions
Properties
| Property | Type | Description |
|---|---|---|
api_key? | string | API key for authentication. Falls back to SONIOX_API_KEY environment variable if not provided. |
base_url? | string | Base URL for the REST API. Falls back to SONIOX_API_BASE_URL environment variable, then to 'https://api.soniox.com'. |
http_client? | HttpClient | Custom HTTP client implementation. |
realtime? | RealtimeOptions | Real-time API configuration options. |
SonioxTranscriptionData
Raw transcription metadata from the API.
Properties
| Property | Type | Description |
|---|---|---|
audio_duration_ms? | number | null | Duration of the audio in milliseconds. Only available after processing begins. |
audio_url? | string | null | URL of the audio file being transcribed. |
client_reference_id? | string | null | Optional tracking identifier. Max Length 256 |
context? | TranscriptionContext | null | Additional context provided for the transcription. |
created_at | string | UTC timestamp when the transcription was created. Format date-time |
enable_language_identification | boolean | When true, language is detected for each part of the transcription. |
enable_speaker_diarization | boolean | When true, speakers are identified and separated in the transcription output. |
error_message? | string | null | Error message if transcription failed. Null for successful or in-progress transcriptions. |
error_type? | string | null | Error type if transcription failed. Null for successful or in-progress transcriptions. |
file_id? | string | null | ID of the uploaded file being transcribed. Format uuid |
filename | string | Name of the file being transcribed. |
id | string | Unique identifier of the transcription. Format uuid |
language_hints? | string[] | null | Expected languages in the audio. If not specified, languages are automatically detected. |
model | string | Speech-to-text model used. |
status | TranscriptionStatus | Current status of the transcription. |
webhook_auth_header_name? | string | null | Name of the authentication header sent with webhook notifications. |
webhook_auth_header_value? | string | null | Authentication header value. Always returned masked. |
webhook_status_code? | number | null | HTTP status code received from your server when webhook was delivered. Null if not yet sent. |
webhook_url? | string | null | URL to receive webhook notifications when transcription is completed or fails. |
SonioxTranscriptionMode
Transcription mode of the model.
SonioxTranslationTarget
Properties
| Property | Type |
|---|---|
exclude_source_languages | string[] |
source_languages | string[] |
target_language | string |
SttSessionConfig
Configuration sent to the Soniox WebSocket API when starting a session.
Properties
| Property | Type | Description |
|---|---|---|
audio_format? | "auto" | AudioFormat | Audio format. Use 'auto' for automatic detection of container formats. For raw PCM formats, also set sample_rate and num_channels. Default 'auto' |
client_reference_id? | string | Optional tracking identifier (max 256 chars). |
context? | TranscriptionContext | Additional context to improve transcription accuracy. |
enable_endpoint_detection? | boolean | Enable endpoint detection for utterance boundaries. Useful for voice AI agents. |
enable_language_identification? | boolean | Enable automatic language detection. |
enable_speaker_diarization? | boolean | Enable speaker identification. |
language_hints? | string[] | Expected languages in the audio (ISO language codes). |
language_hints_strict? | boolean | When true, recognition is strongly biased toward language hints. Best-effort only, not a hard guarantee. |
model | string | Speech-to-text model to use. |
num_channels? | number | Number of audio channels (required for raw audio formats). |
sample_rate? | number | Sample rate in Hz (required for PCM formats). |
translation? | TranslationConfig | Translation configuration. |
SttSessionEvents
Event handlers for the STT session.
Properties
| Property | Type | Description |
|---|---|---|
connected | () => void | Session connected and ready. |
disconnected | (reason?) => void | Session disconnected. |
endpoint | () => void | Endpoint detected (<end> token). |
error | (error) => void | Error occurred. |
finalized | () => void | Finalization complete (<fin> token). |
finished | () => void | Session finished (server signaled end of stream). |
result | (result) => void | Parsed result received. |
state_change | (update) => void | Session state transition. |
token | (token) => void | Individual token received. |
SttSessionOptions
SDK-level session options (not sent to the server).
Properties
| Property | Type | Description |
|---|---|---|
keepalive_interval_ms? | number | Interval for sending keepalive messages while paused (milliseconds). Default 5000 |
signal? | AbortSignal | AbortSignal for cancellation. |
SttSessionState
Session lifecycle states.
TemporaryApiKeyRequest
Properties
| Property | Type | Description |
|---|---|---|
client_reference_id? | string | Optional tracking identifier string. Does not need to be unique Max Length 256 |
expires_in_seconds | number | Duration in seconds until the temporary API key expires Minimum 1 Maximum 3600 |
usage_type | TemporaryApiKeyUsageType | Intended usage of the temporary API key. |
TemporaryApiKeyResponse
Properties
| Property | Type | Description |
|---|---|---|
api_key | string | Created temporary API key. |
expires_at | string | UTC timestamp indicating when generated temporary API key will expire Format date-time |
TemporaryApiKeyUsageType
TranscribeBaseOptions
Base options shared by all audio source variants.
Properties
| Property | Type | Description |
|---|---|---|
cleanup? | CleanupTarget[] | Resources to clean up after transcription completes or on error/timeout. Only applies when wait: true. Cleanup runs in all cases when wait: true: - After successful completion - After transcription errors (status: 'error') - On timeout or abort This ensures no orphaned resources are left behind. Example // Delete only the uploaded file cleanup: ['file'] // Delete only the transcription record cleanup: ['transcription'] // Delete both file and transcription cleanup: ['file', 'transcription'] |
client_reference_id? | string | Optional tracking identifier. Max Length 256 |
context? | TranscriptionContext | Additional context to improve transcription accuracy and formatting of specialized terms. |
enable_language_identification? | boolean | Enable automatic language identification. |
enable_speaker_diarization? | boolean | Enable speaker diarization to identify different speakers. |
fetch_transcript? | boolean | When true (default), fetches the transcript and attaches it to the result when wait=true and the transcription completes successfully. Set to false to skip fetching the full transcript payload. Default true |
language_hints? | string[] | Array of expected ISO language codes to bias recognition. |
language_hints_strict? | boolean | When true, model relies more heavily on language hints. |
model | string | Speech-to-text model to use. Max Length 32 |
signal? | AbortSignal | AbortSignal to cancel the operation |
timeout_ms? | number | Timeout in milliseconds |
translation? | TranslationConfig | Translation configuration. |
wait? | boolean | When true, waits for transcription to complete before returning. Default false |
wait_options? | WaitOptions | Options for waiting (only used when wait=true). |
webhook_auth_header_name? | string | Name of the authentication header sent with webhook notifications. Max Length 256 |
webhook_auth_header_value? | string | Authentication header value sent with webhook notifications. Max Length 256 |
webhook_query? | string | URLSearchParams | Record<string, string> | Query parameters to append to the webhook URL. Useful for encoding metadata like transcription ID in the webhook callback. Can be a string, URLSearchParams, or Record<string, string>. |
webhook_url? | string | URL to receive webhook notifications when transcription is completed or fails. Max Length 256 |
TranscribeFromFile
Transcribe from a direct file upload (Buffer, Uint8Array, Blob, or ReadableStream)
Type Declaration
| Name | Type | Description |
|---|---|---|
audio_url? | never | - |
file | UploadFileInput | File data to upload and transcribe. |
file_id? | never | - |
filename? | string | - |
TranscribeFromFileId
Transcribe from a previously uploaded file
Type Declaration
| Name | Type | Description |
|---|---|---|
audio_url? | never | - |
file? | never | - |
file_id | string | ID of a previously uploaded file. Format uuid |
filename? | never | - |
TranscribeFromFileIdOptions
Options for transcribing from an uploaded file ID via transcribeFromFileId.
TranscribeFromFileOptions
Options for transcribing from a file via transcribeFromFile.
TranscribeFromUrl
Transcribe from a publicly accessible audio URL
Type Declaration
| Name | Type | Description |
|---|---|---|
audio_url | string | URL of a publicly accessible audio file. Max Length 4096 |
file? | never | - |
file_id? | never | - |
filename? | never | - |
TranscribeFromUrlOptions
Options for transcribing from a URL via transcribeFromUrl.
TranscribeOptions
Options for the unified transcribe method
Exactly one audio source must be provided: file, file_id, or audio_url
TranscriptResponse
Response from getting a transcription transcript.
Properties
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier of the transcription this transcript belongs to. Format uuid |
text | string | Complete transcribed text content. |
tokens | TranscriptToken[] | List of detailed token information with timestamps and metadata. |
TranscriptSegment
A segment of contiguous tokens grouped by speaker and language
Properties
| Property | Type | Description |
|---|---|---|
end_ms | number | End time of the segment in milliseconds (from last token). |
language? | string | Detected language code (if language identification was enabled). |
speaker? | string | Speaker identifier (if speaker diarization was enabled). |
start_ms | number | Start time of the segment in milliseconds (from first token). |
text | string | Concatenated text of all tokens in this segment. |
tokens | TranscriptToken[] | Original tokens in this segment. |
TranscriptToken
A single token from the transcript with timing and confidence information.
Properties
| Property | Type | Description |
|---|---|---|
confidence | number | Confidence score for this token (0.0 to 1.0). |
end_ms | number | End time of the token in milliseconds. |
is_audio_event? | boolean | null | Whether this token represents an audio event. |
language? | string | null | Detected language code (if language identification was enabled). |
speaker? | string | null | Speaker identifier (if speaker diarization was enabled). |
start_ms | number | Start time of the token in milliseconds. |
text | string | The text content of this token. |
translation_status? | "none" | "original" | "translation" | null | Translation status for this token. |
TranscriptionContext
Additional context to improve transcription and translation accuracy. All sections are optional - include only what's relevant for your use case.
Properties
| Property | Type | Description |
|---|---|---|
general? | ContextGeneralEntry[] | Structured key-value pairs describing domain, topic, intent, participant names, etc. |
terms? | string[] | Domain-specific or uncommon words to recognize. |
text? | string | Longer free-form background text, prior interaction history, reference documents, or meeting notes. |
translation_terms? | ContextTranslationTerm[] | Custom translations for ambiguous terms. |
TranscriptionIdentifier
Transcription identifier - either a string ID or an object with an id property.
TranscriptionStatus
Status of a transcription request.
TranslationConfig
Translation configuration.
TwoWayTranslationConfig
Two-way translation configuration. Translates between two specified languages.
Properties
| Property | Type | Description |
|---|---|---|
language_a | string | First language code. |
language_b | string | Second language code. |
type | "two_way" | Translation type. |
UploadFileInput
Supported input types for file upload
UploadFileOptions
Options for uploading a file
Properties
| Property | Type | Description |
|---|---|---|
client_reference_id? | string | Optional tracking identifier string. Does not need to be unique Max Length 256 |
filename? | string | Custom filename for the uploaded file |
signal? | AbortSignal | AbortSignal for cancelling the upload |
timeout_ms? | number | Request timeout in milliseconds |
WaitOptions
Options for polling/waiting for transcription completion.
Properties
| Property | Type | Description |
|---|---|---|
interval_ms? | number | Polling interval in milliseconds. Default 1000 Minimum 1000 |
on_status_change? | (status, transcription) => void | Callback invoked when status changes. |
signal? | AbortSignal | AbortSignal to cancel waiting. |
timeout_ms? | number | Maximum time to wait in milliseconds. Default 300000 (5 minutes) |
WebhookAuthConfig
Authentication configuration for webhook verification
Properties
| Property | Type | Description |
|---|---|---|
name | string | Expected header name (case-insensitive comparison) |
value | string | Expected header value (exact match) |
WebhookEvent
Webhook event payload sent by Soniox when a transcription completes or fails.
Properties
| Property | Type | Description |
|---|---|---|
id | string | Transcription ID Format uuid |
status | WebhookEventStatus | Transcription result status |
WebhookEventStatus
Webhook event status values
WebhookHandlerResult
Result of webhook handling
Properties
| Property | Type | Description |
|---|---|---|
error? | string | Error message (only present when ok=false) |
event? | WebhookEvent | Parsed webhook event (only present when ok=true) |
ok | boolean | Whether the webhook was handled successfully |
status | number | HTTP status code to return |
WebhookHandlerResultWithFetch
Result of webhook handling with lazy fetch capabilities.
When using client.webhooks.handleExpress() (or other framework handlers),
the result includes helper methods to fetch the transcript or transcription.
Type Declaration
| Name | Type | Description |
|---|---|---|
fetchTranscript | | () => Promise<ISonioxTranscript | null> | undefined | Fetch the transcript for a completed transcription. Only available when ok=true and event.status='completed'. Example const result = soniox.webhooks.handleExpress(req); if (result.ok && result.event.status === 'completed') { const transcript = await result.fetchTranscript(); console.log(transcript?.text); } |
fetchTranscription | | () => Promise<ISonioxTranscription | null> | undefined | Fetch the full transcription object. Useful for both completed (metadata) and error (error details) statuses. Example const result = soniox.webhooks.handleExpress(req); if (result.ok && result.event.status === 'error') { const transcription = await result.fetchTranscription(); console.log(transcription?.error_message); } |
WebhookHeaders
Headers object type - supports both standard headers and record types
HttpClient
Pluggable HTTP client interface
Methods
request()
Perform an HTTP request
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
request | HttpRequest | Request configuration |
Returns
Promise<HttpResponse<T>>
Promise resolving to the response
Throws
SonioxHttpError On network errors, timeouts, HTTP errors, or parse errors
HttpErrorDetails
Error details for SonioxHttpError
Properties
| Property | Type | Description |
|---|---|---|
bodyText? | string | Response body text (capped at 4KB) |
cause? | unknown | - |
code | HttpErrorCode | - |
headers? | Record<string, string> | - |
message | string | - |
method | HttpMethod | - |
statusCode? | number | - |
url | string | - |
HttpRequest
HTTP request configuration
Properties
| Property | Type | Description |
|---|---|---|
body? | HttpRequestBody | Request body |
headers? | Record<string, string> | Request headers |
method | HttpMethod | HTTP method |
path | string | URL path (relative to baseUrl) or absolute URL |
query? | QueryParams | Query parameters (will be URL-encoded) |
responseType? | HttpResponseType | Expected response type Default 'json' |
signal? | AbortSignal | Optional AbortSignal for request cancellation If provided along with timeoutMs, both will be respected |
timeoutMs? | number | Request timeout in milliseconds If not specified, uses the client's default timeout |
HttpResponse<T>
HTTP response from the client
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Type | Description |
|---|---|---|
data | T | Parsed response data |
headers | Record<string, string> | Response headers (normalized to lowercase keys) |
status | number | HTTP status code |
ISonioxTranscript
Type contract for SonioxTranscript class.
See
SonioxTranscript for full documentation.
Methods
segments()
Parameters
| Parameter | Type |
|---|---|
options? | SegmentTranscriptOptions |
Returns
Properties
| Property | Type |
|---|---|
id | string |
text | string |
tokens | TranscriptToken[] |
ISonioxTranscription
Type contract for SonioxTranscription class.
See
SonioxTranscription for full documentation.
Methods
delete()
Returns
Promise<void>
destroy()
Returns
Promise<void>
getTranscript()
Parameters
| Parameter | Type |
|---|---|
options? | { force?: boolean; signal?: AbortSignal; } |
options.force? | boolean |
options.signal? | AbortSignal |
Returns
Promise<ISonioxTranscript | null>
refresh()
Parameters
| Parameter | Type |
|---|---|
signal? | AbortSignal |
Returns
Promise<ISonioxTranscription>
toJSON()
Returns
wait()
Parameters
| Parameter | Type |
|---|---|
options? | WaitOptions |
Returns
Promise<ISonioxTranscription>
Properties
| Property | Type |
|---|---|
audio_duration_ms | number | null | undefined |
audio_url | string | null | undefined |
client_reference_id | string | null | undefined |
context | | TranscriptionContext | null | undefined |
created_at | string |
enable_language_identification | boolean |
enable_speaker_diarization | boolean |
error_message | string | null | undefined |
error_type | string | null | undefined |
file_id | string | null | undefined |
filename | string |
id | string |
language_hints | string[] | undefined |
model | string |
status | TranscriptionStatus |
transcript | ISonioxTranscript | null | undefined |
webhook_auth_header_name | string | null | undefined |
webhook_auth_header_value | string | null | undefined |
webhook_status_code | number | null | undefined |
webhook_url | string | null | undefined |