@soniox/node 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -811,12 +811,29 @@ type GenerateSpeechOptions = {
811
811
  /** Optional AbortSignal for cancellation. */
812
812
  signal?: AbortSignal | undefined;
813
813
  };
814
+ /**
815
+ * A language supported by a Text-to-Speech model.
816
+ */
817
+ type TtsLanguage = {
818
+ /** ISO language code. */
819
+ code: string;
820
+ /** Human-readable language name. */
821
+ name: string;
822
+ };
823
+ /**
824
+ * Voice gender metadata returned by the TTS models API.
825
+ */
826
+ type TtsVoiceGender = 'male' | 'female' | 'neutral';
814
827
  /**
815
828
  * A Text-to-Speech voice.
816
829
  */
817
830
  type TtsVoice = {
818
831
  /** Unique identifier of the voice. */
819
832
  id: string;
833
+ /** Human-readable voice description. */
834
+ description: string;
835
+ /** Voice gender metadata. */
836
+ gender: TtsVoiceGender;
820
837
  };
821
838
  /**
822
839
  * A Text-to-Speech model.
@@ -828,6 +845,8 @@ type TtsModel = {
828
845
  aliased_model_id?: string | null;
829
846
  /** Name of the model. */
830
847
  name: string;
848
+ /** Languages supported by this model. */
849
+ languages: TtsLanguage[];
831
850
  /** Voices supported by this model. */
832
851
  voices: TtsVoice[];
833
852
  };
@@ -1597,6 +1616,61 @@ type RealtimeClientOptions = {
1597
1616
  default_session_options?: SttSessionOptions | undefined;
1598
1617
  };
1599
1618
  //#endregion
1619
+ //#region src/types/public/concurrency-limits.d.ts
1620
+ /**
1621
+ * Live concurrency counts.
1622
+ */
1623
+ type ConcurrencyCurrentValues = {
1624
+ /**
1625
+ * Current number of concurrent transcription sessions.
1626
+ */
1627
+ transcribe_concurrent: number;
1628
+ /**
1629
+ * Current number of concurrent TTS sessions.
1630
+ */
1631
+ tts_concurrent: number;
1632
+ };
1633
+ /**
1634
+ * Configured concurrency limits.
1635
+ */
1636
+ type ConcurrencyLimitValues = {
1637
+ /**
1638
+ * Configured transcription concurrency limit. Null means no configured limit.
1639
+ */
1640
+ transcribe_concurrent: number | null;
1641
+ /**
1642
+ * Configured TTS concurrency limit. Null means no configured limit.
1643
+ */
1644
+ tts_concurrent: number | null;
1645
+ };
1646
+ /**
1647
+ * Current counts and configured limits for a concurrency scope.
1648
+ */
1649
+ type ConcurrencyScopeValues = {
1650
+ /**
1651
+ * Current live concurrency counts.
1652
+ */
1653
+ current: ConcurrencyCurrentValues;
1654
+ /**
1655
+ * Configured concurrency limits.
1656
+ */
1657
+ limits: ConcurrencyLimitValues;
1658
+ };
1659
+ /**
1660
+ * Current concurrent counts plus configured concurrency limits for the project
1661
+ * and its organization. Values are region-scoped.
1662
+ */
1663
+ type ConcurrencyLimitsResponse = {
1664
+ /**
1665
+ * Project-level concurrency counts and limits.
1666
+ */
1667
+ project: ConcurrencyScopeValues;
1668
+ /**
1669
+ * Organization-level concurrency counts and limits.
1670
+ */
1671
+ organization: ConcurrencyScopeValues;
1672
+ };
1673
+ //#endregion
1600
1674
  //#region src/types/public/files.d.ts
1601
1675
  /**
1602
1676
  * Raw file metadata from the API.
@@ -1659,6 +1733,23 @@ type ListFilesResponse<T> = {
1659
1733
  */
1660
1734
  next_page_cursor: string | null;
1661
1735
  };
1736
+ /**
1737
+ * Total number of files, split by source.
1738
+ */
1739
+ type FilesCountResponse = {
1740
+ /**
1741
+ * Number of files uploaded via the Playground.
1742
+ */
1743
+ playground: number;
1744
+ /**
1745
+ * Number of files uploaded via Public API.
1746
+ */
1747
+ public_api: number;
1748
+ /**
1749
+ * Total number of files across all sources.
1750
+ */
1751
+ total: number;
1752
+ };
1662
1753
  /**
1663
1754
  * File identifier - either a string ID or an object with an id property.
1664
1755
  */
@@ -2148,6 +2239,23 @@ type ListTranscriptionsResponse<T> = {
2148
2239
  */
2149
2240
  next_page_cursor: string | null;
2150
2241
  };
2242
+ /**
2243
+ * Total number of transcriptions, split by request scope.
2244
+ */
2245
+ type TranscriptionsCountResponse = {
2246
+ /**
2247
+ * Number of transcriptions created via the Playground.
2248
+ */
2249
+ playground: number;
2250
+ /**
2251
+ * Number of transcriptions created via Public API.
2252
+ */
2253
+ public_api: number;
2254
+ /**
2255
+ * Total number of transcriptions across all scopes.
2256
+ */
2257
+ total: number;
2258
+ };
2151
2259
  /**
2152
2260
  * Transcription identifier - either a string ID or an object with an id property.
2153
2261
  */
@@ -2164,12 +2272,20 @@ type TranscriptToken = {
2164
2272
  text: string;
2165
2273
  /**
2166
2274
  * Start time of the token in milliseconds.
2275
+ *
2276
+ * Present on original tokens (`translation_status` of `'original'` or
2277
+ * `'none'`) and absent on translation tokens (`translation_status: 'translation'`),
2278
+ * which do not carry timing.
2167
2279
  */
2168
- start_ms: number;
2280
+ start_ms?: number;
2169
2281
  /**
2170
2282
  * End time of the token in milliseconds.
2283
+ *
2284
+ * Present on original tokens (`translation_status` of `'original'` or
2285
+ * `'none'`) and absent on translation tokens (`translation_status: 'translation'`),
2286
+ * which do not carry timing.
2171
2287
  */
2172
- end_ms: number;
2288
+ end_ms?: number;
2173
2289
  /**
2174
2290
  * Confidence score for this token (0.0 to 1.0).
2175
2291
  */
@@ -2179,9 +2295,23 @@ type TranscriptToken = {
2179
2295
  */
2180
2296
  speaker?: string | null | undefined;
2181
2297
  /**
2182
- * Detected language code (if language identification was enabled).
2298
+ * Language code for this token.
2299
+ *
2300
+ * For original tokens (`translation_status` of `'original'` or `'none'`)
2301
+ * this is the spoken language. For translation tokens
2302
+ * (`translation_status: 'translation'`) this is the target language.
2303
+ *
2304
+ * Present on every token whenever language identification or translation
2305
+ * is configured.
2183
2306
  */
2184
2307
  language?: string | null | undefined;
2308
+ /**
2309
+ * Source language for translation tokens (`translation_status: 'translation'`).
2310
+ *
2311
+ * Identifies the language being translated from. Not set on original or
2312
+ * `'none'` tokens; their language is in {@link TranscriptToken.language}.
2313
+ */
2314
+ source_language?: string | null | undefined;
2185
2315
  /**
2186
2316
  * Translation status for this token.
2187
2317
  */
@@ -2229,12 +2359,18 @@ type TranscriptSegment = {
2229
2359
  text: string;
2230
2360
  /**
2231
2361
  * Start time of the segment in milliseconds (from first token).
2362
+ *
2363
+ * Absent for translation-only segments where the underlying tokens carry
2364
+ * no timestamps.
2232
2365
  */
2233
- start_ms: number;
2366
+ start_ms?: number;
2234
2367
  /**
2235
2368
  * End time of the segment in milliseconds (from last token).
2369
+ *
2370
+ * Absent for translation-only segments where the underlying tokens carry
2371
+ * no timestamps.
2236
2372
  */
2237
- end_ms: number;
2373
+ end_ms?: number;
2238
2374
  /**
2239
2375
  * Speaker identifier (if speaker diarization was enabled).
2240
2376
  */
@@ -2308,6 +2444,452 @@ interface ISonioxTranscription {
2308
2444
  wait(options?: WaitOptions): Promise<ISonioxTranscription>;
2309
2445
  }
2310
2446
  //#endregion
2447
+ //#region src/types/public/translation.d.ts
2448
+ /**
2449
+ * Shorthand specification of the translation direction(s) for
2450
+ * {@link SonioxSttApi.translate}.
2451
+ *
2452
+ * Three mutually exclusive shapes:
2453
+ *
2454
+ * - `{ to }` — one-way translation into `to`. Source language(s) are
2455
+ * detected automatically.
2456
+ * - `{ to, from }` — one-way translation from `from` to `to`. The source
2457
+ * language is hinted to the model.
2458
+ * - `{ between: [a, b] }` — two-way translation between `a` and `b`.
2459
+ * Each side is translated into the other; speech in any third language
2460
+ * is passed through as-is.
2461
+ */
2462
+ type TranslateMode = {
2463
+ to: string;
2464
+ from?: never;
2465
+ between?: never;
2466
+ } | {
2467
+ to: string;
2468
+ from: string;
2469
+ between?: never;
2470
+ } | {
2471
+ between: [string, string];
2472
+ to?: never;
2473
+ from?: never;
2474
+ };
2475
+ /**
2476
+ * Audio source for {@link SonioxSttApi.translate}. Exactly one of
2477
+ * `file`, `file_id`, or `audio_url` must be provided.
2478
+ */
2479
+ type TranslateAudioSource = {
2480
+ /**
2481
+ * File data to upload and translate.
2482
+ */
2483
+ file: UploadFileInput;
2484
+ filename?: string | undefined;
2485
+ file_id?: never;
2486
+ audio_url?: never;
2487
+ } | {
2488
+ /**
2489
+ * ID of a previously uploaded file.
2490
+ * @format uuid
2491
+ */
2492
+ file_id: string;
2493
+ file?: never;
2494
+ filename?: never;
2495
+ audio_url?: never;
2496
+ } | {
2497
+ /**
2498
+ * URL of a publicly accessible audio file.
2499
+ * @maxLength 4096
2500
+ */
2501
+ audio_url: string;
2502
+ file?: never;
2503
+ filename?: never;
2504
+ file_id?: never;
2505
+ };
2506
+ /**
2507
+ * Common (non-mode, non-source) options shared by every translate call.
2508
+ */
2509
+ type TranslateBaseOptions = {
2510
+ /**
2511
+ * Speech-to-text model to use.
2512
+ * @default 'stt-async-v4'
2513
+ * @maxLength 32
2514
+ */
2515
+ model?: string | undefined;
2516
+ /**
2517
+ * Enable speaker diarization to identify different speakers.
2518
+ */
2519
+ enable_speaker_diarization?: boolean | undefined;
2520
+ /**
2521
+ * Additional context to improve transcription and translation accuracy.
2522
+ */
2523
+ context?: TranscriptionContext | undefined;
2524
+ /**
2525
+ * URL to receive webhook notifications when translation is completed or fails.
2526
+ * @maxLength 256
2527
+ */
2528
+ webhook_url?: string | undefined;
2529
+ /**
2530
+ * Name of the authentication header sent with webhook notifications.
2531
+ * @maxLength 256
2532
+ */
2533
+ webhook_auth_header_name?: string | undefined;
2534
+ /**
2535
+ * Authentication header value sent with webhook notifications.
2536
+ * @maxLength 256
2537
+ */
2538
+ webhook_auth_header_value?: string | undefined;
2539
+ /**
2540
+ * Query parameters to append to the webhook URL.
2541
+ */
2542
+ webhook_query?: string | URLSearchParams | Record<string, string> | undefined;
2543
+ /**
2544
+ * Optional tracking identifier.
2545
+ * @maxLength 256
2546
+ */
2547
+ client_reference_id?: string | undefined;
2548
+ /**
2549
+ * Resources to clean up after translation completes or on error/timeout.
2550
+ */
2551
+ cleanup?: CleanupTarget[] | undefined;
2552
+ /**
2553
+ * When true, waits for translation to complete before returning.
2554
+ * @default false
2555
+ */
2556
+ wait?: boolean | undefined;
2557
+ /**
2558
+ * Options for waiting on completion.
2559
+ */
2560
+ wait_options?: WaitOptions | undefined;
2561
+ /**
2562
+ * When true (default), fetches and reshapes the translation result when
2563
+ * `wait=true` and the job completes successfully.
2564
+ * @default true
2565
+ */
2566
+ fetch_translation?: boolean | undefined;
2567
+ /**
2568
+ * AbortSignal to cancel the operation.
2569
+ */
2570
+ signal?: AbortSignal | undefined;
2571
+ /**
2572
+ * Timeout in milliseconds.
2573
+ */
2574
+ timeout_ms?: number | undefined;
2575
+ };
2576
+ /**
2577
+ * Options for {@link SonioxSttApi.translate}.
2578
+ *
2579
+ * Combines a {@link TranslateMode} (the translation direction shorthand),
2580
+ * a {@link TranslateAudioSource} (file, file_id, or audio_url), and
2581
+ * {@link TranslateBaseOptions}.
2582
+ */
2583
+ type TranslateOptions = TranslateMode & TranslateAudioSource & TranslateBaseOptions;
2584
+ /**
2585
+ * A grouped pair of original speech and (optionally) its translation,
2586
+ * derived from the underlying transcript tokens.
2587
+ *
2588
+ * In one-way mode every segment that originated from speech in the source
2589
+ * language carries both `original_*` and `translation_*` fields. In two-way
2590
+ * mode the same is true for the two configured languages; speech in a third
2591
+ * language flows through with `translation_status: 'none'` and the
2592
+ * translation fields are omitted.
2593
+ */
2594
+ type TranslationSegment = {
2595
+ /**
2596
+ * Start time of the segment in milliseconds, taken from the first
2597
+ * original token. Absent when the segment has no original tokens.
2598
+ */
2599
+ start_ms?: number;
2600
+ /**
2601
+ * End time of the segment in milliseconds, taken from the last
2602
+ * original token. Absent when the segment has no original tokens.
2603
+ */
2604
+ end_ms?: number;
2605
+ /**
2606
+ * Speaker identifier (when speaker diarization is enabled).
2607
+ */
2608
+ speaker?: string;
2609
+ /**
2610
+ * Source language code.
2611
+ *
2612
+ * Derived from `original_tokens[0].language` when originals are present,
2613
+ * otherwise from `translation_tokens[0].source_language`.
2614
+ */
2615
+ from: string;
2616
+ /**
2617
+ * Concatenated text of `original_tokens`.
2618
+ */
2619
+ original_text: string;
2620
+ /**
2621
+ * Original tokens (`translation_status` of `'original'` or `'none'`)
2622
+ * for this segment, in order.
2623
+ */
2624
+ original_tokens: TranscriptToken[];
2625
+ /**
2626
+ * Target language code. Omitted when there are no translation tokens
2627
+ * (e.g. third-language pass-through under `between`).
2628
+ */
2629
+ to?: string;
2630
+ /**
2631
+ * Concatenated text of `translation_tokens`. Omitted when there are no
2632
+ * translation tokens.
2633
+ */
2634
+ translation_text?: string;
2635
+ /**
2636
+ * Translation tokens (`translation_status: 'translation'`) for this
2637
+ * segment, in order. Omitted when there are no translation tokens.
2638
+ */
2639
+ translation_tokens?: TranscriptToken[];
2640
+ };
2641
+ /**
2642
+ * Result of a one-way translation (`{ to }` or `{ to, from }` mode).
2643
+ *
2644
+ * `original_text` and `translation_text` flatten the per-segment content
2645
+ * across the whole audio, which is useful when the caller just wants two
2646
+ * parallel strings.
2647
+ */
2648
+ type OneWayTranslation = {
2649
+ mode: 'one_way';
2650
+ /**
2651
+ * Source language hint that was supplied via `from`. Undefined when only
2652
+ * `to` was provided and the source language was auto-detected.
2653
+ */
2654
+ from?: string;
2655
+ /**
2656
+ * Target language code (the `to` value passed in).
2657
+ */
2658
+ to: string;
2659
+ /**
2660
+ * Total audio duration in milliseconds. Equals the largest `end_ms`
2661
+ * across all original tokens, or `0` when there are no original tokens.
2662
+ */
2663
+ duration_ms: number;
2664
+ /**
2665
+ * Per-utterance segments in audio order.
2666
+ */
2667
+ segments: TranslationSegment[];
2668
+ /**
2669
+ * Concatenated text of every original token across all segments.
2670
+ */
2671
+ original_text: string;
2672
+ /**
2673
+ * Concatenated text of every translation token across all segments.
2674
+ */
2675
+ translation_text: string;
2676
+ };
2677
+ /**
2678
+ * Result of a two-way translation (`{ between }` mode).
2679
+ *
2680
+ * No flat `original_text` / `translation_text` strings are exposed because
2681
+ * which side is "original" depends on the segment. Read `segments` and
2682
+ * filter / format per `from` / `to` as needed.
2683
+ */
2684
+ type TwoWayTranslation = {
2685
+ mode: 'two_way';
2686
+ /**
2687
+ * First configured language (the `between[0]` value).
2688
+ */
2689
+ language_a: string;
2690
+ /**
2691
+ * Second configured language (the `between[1]` value).
2692
+ */
2693
+ language_b: string;
2694
+ /**
2695
+ * Total audio duration in milliseconds. Equals the largest `end_ms`
2696
+ * across all original tokens, or `0` when there are no original tokens.
2697
+ */
2698
+ duration_ms: number;
2699
+ /**
2700
+ * Per-utterance segments in audio order.
2701
+ */
2702
+ segments: TranslationSegment[];
2703
+ };
2704
+ /**
2705
+ * Discriminated translation result returned by
2706
+ * {@link SonioxTranslationJob.getTranslation},
2707
+ * {@link SonioxTranslationJob.fetchTranslation}, and
2708
+ * {@link translateFromTranscript}.
2709
+ */
2710
+ type SonioxTranslation = OneWayTranslation | TwoWayTranslation;
2711
+ /**
2712
+ * Mode parameter accepted by {@link translateFromTranscript}.
2713
+ *
2714
+ * The async `translate()` method stores this internally on the returned job;
2715
+ * webhook handlers (and other callers that already have a transcript in hand)
2716
+ * supply it directly.
2717
+ */
2718
+ type TranslateFromTranscriptMode = {
2719
+ type: 'one_way';
2720
+ to: string;
2721
+ from?: string;
2722
+ } | {
2723
+ type: 'two_way';
2724
+ language_a: string;
2725
+ language_b: string;
2726
+ };
2727
+ /**
2728
+ * Type contract for SonioxTranslationJob class.
2729
+ */
2730
+ interface ISonioxTranslationJob extends ISonioxTranscription {
2731
+ readonly transcript: ISonioxTranscript | null | undefined;
2732
+ readonly translation: SonioxTranslation | null | undefined;
2733
+ toJSON(): ReturnType<ISonioxTranscription['toJSON']>;
2734
+ getTranslation(options?: {
2735
+ force?: boolean;
2736
+ signal?: AbortSignal;
2737
+ }): Promise<SonioxTranslation | null>;
2738
+ fetchTranslation(options?: {
2739
+ force?: boolean;
2740
+ signal?: AbortSignal;
2741
+ }): Promise<SonioxTranslation | null>;
2742
+ refresh(signal?: AbortSignal): Promise<ISonioxTranslationJob>;
2743
+ wait(options?: WaitOptions): Promise<ISonioxTranslationJob>;
2744
+ }
2745
+ //#endregion
2746
+ //#region src/types/public/usage-logs.d.ts
2747
+ /**
2748
+ * Sort order for usage logs.
2749
+ */
2750
+ type UsageLogsSort = 'end_time_asc' | 'end_time_desc';
2751
+ /**
2752
+ * Options for listing usage logs.
2753
+ */
2754
+ type ListUsageLogsOptions = {
2755
+ /**
2756
+ * Start of the time window (inclusive), filtering by request end time.
2757
+ * Must be an ISO 8601 timestamp in UTC.
2758
+ *
2759
+ * @example '2026-04-28T09:00:00Z'
2760
+ */
2761
+ start_time: string;
2762
+ /**
2763
+ * End of the time window (exclusive), filtering by request end time.
2764
+ * Must be an ISO 8601 timestamp in UTC.
2765
+ *
2766
+ * @example '2026-04-29T09:00:00Z'
2767
+ */
2768
+ end_time: string;
2769
+ /**
2770
+ * Maximum number of usage log entries to return.
2771
+ *
2772
+ * @default 1000
2773
+ * @minimum 1
2774
+ * @maximum 1000
2775
+ */
2776
+ limit?: number | undefined;
2777
+ /**
2778
+ * Sort order by end_time.
2779
+ *
2780
+ * @default 'end_time_asc'
2781
+ */
2782
+ sort?: UsageLogsSort | undefined;
2783
+ /**
2784
+ * Pagination cursor for the next page of results.
2785
+ */
2786
+ cursor?: string | undefined;
2787
+ /**
2788
+ * AbortSignal for cancelling the request.
2789
+ */
2790
+ signal?: AbortSignal | undefined;
2791
+ };
2792
+ /**
2793
+ * Per-request usage log entry.
2794
+ */
2795
+ type SonioxUsageLog = {
2796
+ /**
2797
+ * Unique identifier of the request.
2798
+ *
2799
+ * @format uuid
2800
+ */
2801
+ uuid: string;
2802
+ /**
2803
+ * Request scope.
2804
+ */
2805
+ request_scope: string;
2806
+ /**
2807
+ * Optional tracking identifier provided by the caller.
2808
+ */
2809
+ client_reference_id?: string | null | undefined;
2810
+ /**
2811
+ * Model used for the request.
2812
+ */
2813
+ model: string;
2814
+ /**
2815
+ * UTC timestamp indicating when the request started.
2816
+ *
2817
+ * @format date-time
2818
+ */
2819
+ start_time: string;
2820
+ /**
2821
+ * UTC timestamp indicating when the request ended.
2822
+ *
2823
+ * @format date-time
2824
+ */
2825
+ end_time: string;
2826
+ /**
2827
+ * Number of input text tokens.
2828
+ */
2829
+ input_text_tokens: number;
2830
+ /**
2831
+ * Number of input audio tokens.
2832
+ */
2833
+ input_audio_tokens: number;
2834
+ /**
2835
+ * Input audio duration in milliseconds.
2836
+ */
2837
+ input_audio_duration_ms: number;
2838
+ /**
2839
+ * Number of output text tokens.
2840
+ */
2841
+ output_text_tokens: number;
2842
+ /**
2843
+ * Number of output audio tokens.
2844
+ */
2845
+ output_audio_tokens: number;
2846
+ /**
2847
+ * Output audio duration in milliseconds.
2848
+ */
2849
+ output_audio_duration_ms: number;
2850
+ /**
2851
+ * Total request cost in USD, represented as a decimal string.
2852
+ */
2853
+ cost_usd: string;
2854
+ /**
2855
+ * Input cost in USD, represented as a decimal string.
2856
+ */
2857
+ input_cost_usd: string;
2858
+ /**
2859
+ * Input text cost in USD, represented as a decimal string.
2860
+ */
2861
+ input_text_cost_usd: string;
2862
+ /**
2863
+ * Input audio cost in USD, represented as a decimal string.
2864
+ */
2865
+ input_audio_cost_usd: string;
2866
+ /**
2867
+ * Output cost in USD, represented as a decimal string.
2868
+ */
2869
+ output_cost_usd: string;
2870
+ /**
2871
+ * Output text cost in USD, represented as a decimal string.
2872
+ */
2873
+ output_text_cost_usd: string;
2874
+ /**
2875
+ * Output audio cost in USD, represented as a decimal string.
2876
+ */
2877
+ output_audio_cost_usd: string;
2878
+ };
2879
+ /**
2880
+ * Response from listing usage logs.
2881
+ */
2882
+ type ListUsageLogsResponse = {
2883
+ /**
2884
+ * Per-request usage log entries ordered by end_time and UUID.
2885
+ */
2886
+ usage_logs: SonioxUsageLog[];
2887
+ /**
2888
+ * Pagination cursor for the next page of results. Null if no more pages.
2889
+ */
2890
+ next_page_cursor: string | null;
2891
+ };
2892
+ //#endregion
2311
2893
  //#region src/types/public/webhooks.d.ts
2312
2894
  /**
2313
2895
  * Webhook event status values
@@ -2645,6 +3227,30 @@ declare class SonioxAuthAPI {
2645
3227
  createTemporaryKey(request: TemporaryApiKeyRequest, signal?: AbortSignal): Promise<TemporaryApiKeyResponse>;
2646
3228
  }
2647
3229
  //#endregion
3230
+ //#region src/async/concurrency-limits.d.ts
3231
+ declare class SonioxConcurrencyLimitsAPI {
3232
+ private http;
3233
+ constructor(http: HttpClient);
3234
+ /**
3235
+ * Retrieves current concurrency counts and configured limits.
3236
+ *
3237
+ * Values are region-scoped according to the client's configured REST API
3238
+ * endpoint.
3239
+ *
3240
+ * @param signal - Optional AbortSignal for cancellation.
3241
+ * @returns Current counts and configured limits for project and organization scopes.
3242
+ * @throws {@link SonioxHttpError} On API errors.
3243
+ *
3244
+ * @example
3245
+ * ```typescript
3246
+ * const limits = await client.concurrencyLimits.get();
3247
+ * console.log(limits.project.current.transcribe_concurrent);
3248
+ * console.log(limits.project.limits.transcribe_concurrent);
3249
+ * ```
3250
+ */
3251
+ get(signal?: AbortSignal): Promise<ConcurrencyLimitsResponse>;
3252
+ }
3253
+ //#endregion
2648
3254
  //#region src/async/files.d.ts
2649
3255
  /**
2650
3256
  * Uploaded file
@@ -2794,6 +3400,22 @@ declare class SonioxFilesAPI {
2794
3400
  * ```
2795
3401
  */
2796
3402
  list(options?: ListFilesOptions): Promise<FileListResult>;
3403
+ /**
3404
+ * Returns the total number of files, split by source.
3405
+ *
3406
+ * @param options - Optional cancellation parameters.
3407
+ * @returns Total file counts for Playground, Public API, and all sources.
3408
+ * @throws {@link SonioxHttpError} On API errors.
3409
+ *
3410
+ * @example
3411
+ * ```typescript
3412
+ * const counts = await client.files.count();
3413
+ * console.log(counts.total);
3414
+ * ```
3415
+ */
3416
+ count(options?: {
3417
+ signal?: AbortSignal;
3418
+ }): Promise<FilesCountResponse>;
2797
3419
  /**
2798
3420
  * Retrieve metadata for an uploaded file.
2799
3421
  *
@@ -2946,7 +3568,7 @@ declare class SonioxTranscript implements ISonioxTranscript {
2946
3568
  * A Transcription instance
2947
3569
  */
2948
3570
  declare class SonioxTranscription implements ISonioxTranscription {
2949
- private readonly _http;
3571
+ protected readonly _http: HttpClient;
2950
3572
  /**
2951
3573
  * Unique identifier of the transcription.
2952
3574
  */
@@ -3138,6 +3760,48 @@ declare class SonioxTranscription implements ISonioxTranscription {
3138
3760
  */
3139
3761
  wait(options?: WaitOptions): Promise<SonioxTranscription>;
3140
3762
  }
3763
+ /**
3764
+ * A translation job.
3765
+ *
3766
+ * Mirrors {@link SonioxTranscription}, with an additional translation mode and
3767
+ * helpers that reshape the completed transcript into a {@link SonioxTranslation}.
3768
+ */
3769
+ declare class SonioxTranslationJob extends SonioxTranscription implements ISonioxTranslationJob {
3770
+ private readonly _mode;
3771
+ /**
3772
+ * Pre-fetched translation result. Only available when using `translate()`
3773
+ * with `wait: true`, `fetch_translation !== false`, and the job completed
3774
+ * successfully.
3775
+ */
3776
+ readonly translation: SonioxTranslation | null | undefined;
3777
+ constructor(data: SonioxTranscriptionData, http: HttpClient, _mode: TranslateFromTranscriptMode, transcript?: SonioxTranscript | null, translation?: SonioxTranslation | null);
3778
+ /**
3779
+ * Retrieves and reshapes the completed transcript into a structured
3780
+ * translation result.
3781
+ *
3782
+ * Returns cached translation if available. Use `force: true` to bypass the
3783
+ * cached translation and fetch a fresh transcript from the API.
3784
+ */
3785
+ getTranslation(options?: {
3786
+ force?: boolean;
3787
+ signal?: AbortSignal;
3788
+ }): Promise<SonioxTranslation | null>;
3789
+ /**
3790
+ * Alias for {@link SonioxTranslationJob.getTranslation}.
3791
+ */
3792
+ fetchTranslation(options?: {
3793
+ force?: boolean;
3794
+ signal?: AbortSignal;
3795
+ }): Promise<SonioxTranslation | null>;
3796
+ /**
3797
+ * Re-fetches this translation job to get the latest status.
3798
+ */
3799
+ refresh(signal?: AbortSignal): Promise<SonioxTranslationJob>;
3800
+ /**
3801
+ * Waits for the translation job to complete or fail.
3802
+ */
3803
+ wait(options?: WaitOptions): Promise<SonioxTranslationJob>;
3804
+ }
3141
3805
  /**
3142
3806
  * Result set for transcription listing.
3143
3807
  */
@@ -3233,6 +3897,20 @@ declare class SonioxSttApi {
3233
3897
  * ```
3234
3898
  */
3235
3899
  list(options?: ListTranscriptionsOptions, signal?: AbortSignal): Promise<TranscriptionListResult>;
3900
+ /**
3901
+ * Returns the total number of transcriptions, split by request scope.
3902
+ *
3903
+ * @param signal - Optional AbortSignal for request cancellation.
3904
+ * @returns Total transcription counts for Playground, Public API, and all scopes.
3905
+ * @throws {@link SonioxHttpError} On API errors.
3906
+ *
3907
+ * @example
3908
+ * ```typescript
3909
+ * const counts = await client.stt.count();
3910
+ * console.log(counts.total);
3911
+ * ```
3912
+ */
3913
+ count(signal?: AbortSignal): Promise<TranscriptionsCountResponse>;
3236
3914
  /**
3237
3915
  * Retrieves a transcription by ID
3238
3916
  *
@@ -3416,6 +4094,67 @@ declare class SonioxSttApi {
3416
4094
  * ```
3417
4095
  */
3418
4096
  transcribe(options: TranscribeOptions): Promise<SonioxTranscription>;
4097
+ /**
4098
+ * Starts a translation job.
4099
+ *
4100
+ * Sugar around {@link SonioxSttApi.transcribe}: configures translation from
4101
+ * the supplied {@link TranslateMode} (`{ to }`, `{ to, from }`, or
4102
+ * `{ between }`) and returns a {@link SonioxTranslationJob}. With
4103
+ * `wait: true`, waits for completion before returning, mirroring
4104
+ * {@link SonioxSttApi.transcribe}.
4105
+ *
4106
+ * Method-owned fields (cannot be set by the caller):
4107
+ * - `translation` — derived from `to` / `between`.
4108
+ * - `language_hints` + `language_hints_strict: true` — derived from
4109
+ * `from` / `between`.
4110
+ * - `enable_language_identification: true` — always. The reshape step
4111
+ * relies on every token carrying a `language` field to group originals
4112
+ * with their translations.
4113
+ * - `fetch_transcript` — derived from `fetch_translation` when `wait=true`.
4114
+ *
4115
+ * @param options - Mode, audio source, and pass-through options.
4116
+ * @returns The translation job.
4117
+ * @throws {@link SonioxHttpError} On API errors.
4118
+ * @throws `Error` On validation errors or wait timeout.
4119
+ *
4120
+ * @example
4121
+ * ```typescript
4122
+ * // One-way: detect any source language, translate to Spanish.
4123
+ * const job = await client.stt.translate({
4124
+ * audio_url: 'https://soniox.com/media/examples/coffee_shop.mp3',
4125
+ * to: 'es',
4126
+ * });
4127
+ *
4128
+ * const completed = await job.wait();
4129
+ * const result = await completed.getTranslation();
4130
+ * console.log(result?.translation_text);
4131
+ *
4132
+ * // One-way with explicit source language.
4133
+ * const explicitJob = await client.stt.translate({
4134
+ * file: buffer,
4135
+ * filename: 'meeting.mp3',
4136
+ * from: 'en',
4137
+ * to: 'es',
4138
+ * wait: true,
4139
+ * });
4140
+ * console.log(explicitJob.translation?.translation_text);
4141
+ *
4142
+ * // Two-way: bidirectional translation between two languages.
4143
+ * const twoWayJob = await client.stt.translate({
4144
+ * audio_url: 'https://soniox.com/media/examples/coffee_shop.mp3',
4145
+ * between: ['en', 'es'],
4146
+ * enable_speaker_diarization: true,
4147
+ * wait: true,
4148
+ * });
4149
+ * for (const seg of twoWayJob.translation?.segments ?? []) {
4150
+ * console.log(`[${seg.from}] ${seg.original_text}`);
4151
+ * if (seg.translation_text) {
4152
+ * console.log(` → [${seg.to}] ${seg.translation_text}`);
4153
+ * }
4154
+ * }
4155
+ * ```
4156
+ */
4157
+ translate(options: TranslateOptions): Promise<SonioxTranslationJob>;
3419
4158
  /**
3420
4159
  * Permanently deletes all transcriptions.
3421
4160
  * Iterates through all pages of transcriptions and deletes each one.
@@ -3513,6 +4252,65 @@ declare class SonioxTtsApi extends TtsRestClient {
3513
4252
  listModels(signal?: AbortSignal): Promise<TtsModel[]>;
3514
4253
  }
3515
4254
  //#endregion
4255
+ //#region src/async/usage-logs.d.ts
4256
+ /**
4257
+ * Result set for usage log listing.
4258
+ */
4259
+ declare class UsageLogListResult implements AsyncIterable<SonioxUsageLog> {
4260
+ private readonly _http;
4261
+ private readonly _options;
4262
+ /**
4263
+ * Usage logs from the first page of results.
4264
+ */
4265
+ readonly usage_logs: SonioxUsageLog[];
4266
+ /**
4267
+ * Pagination cursor for the next page. Null if no more pages.
4268
+ */
4269
+ readonly next_page_cursor: string | null;
4270
+ constructor(initialResponse: ListUsageLogsResponse, _http: HttpClient, _options: ListUsageLogsOptions);
4271
+ /**
4272
+ * Returns the raw data for this list result.
4273
+ */
4274
+ toJSON(): ListUsageLogsResponse;
4275
+ /**
4276
+ * Returns true if there are more pages of results beyond the first page.
4277
+ */
4278
+ isPaged(): boolean;
4279
+ /**
4280
+ * Async iterator that automatically fetches all pages.
4281
+ * Use with `for await...of` to iterate through all usage logs.
4282
+ */
4283
+ [Symbol.asyncIterator](): AsyncIterator<SonioxUsageLog>;
4284
+ }
4285
+ declare class SonioxUsageLogsAPI {
4286
+ private http;
4287
+ constructor(http: HttpClient);
4288
+ /**
4289
+ * Retrieves per-request usage log entries for the project.
4290
+ *
4291
+ * The returned result is async iterable. Use `for await...of` to iterate
4292
+ * through all pages.
4293
+ *
4294
+ * @param options - Required time window plus optional pagination, sorting, and cancellation.
4295
+ * @returns UsageLogListResult with async iteration support.
4296
+ * @throws {@link SonioxHttpError} On API errors.
4297
+ *
4298
+ * @example
4299
+ * ```typescript
4300
+ * const result = await client.usageLogs.list({
4301
+ * start_time: '2026-04-28T09:00:00Z',
4302
+ * end_time: '2026-04-29T09:00:00Z',
4303
+ * sort: 'end_time_desc',
4304
+ * });
4305
+ *
4306
+ * for await (const log of result) {
4307
+ * console.log(log.model, log.cost_usd);
4308
+ * }
4309
+ * ```
4310
+ */
4311
+ list(options: ListUsageLogsOptions): Promise<UsageLogListResult>;
4312
+ }
4313
+ //#endregion
3516
4314
  //#region src/async/webhooks.d.ts
3517
4315
  /**
3518
4316
  * Webhook utilities API accessible via client.webhooks
@@ -3722,6 +4520,8 @@ declare class SonioxNodeClient {
3722
4520
  readonly models: SonioxModelsAPI;
3723
4521
  readonly webhooks: SonioxWebhooksAPI;
3724
4522
  readonly auth: SonioxAuthAPI;
4523
+ readonly concurrencyLimits: SonioxConcurrencyLimitsAPI;
4524
+ readonly usageLogs: SonioxUsageLogsAPI;
3725
4525
  readonly realtime: SonioxRealtimeApi;
3726
4526
  constructor(options?: SonioxNodeClientOptions);
3727
4527
  }
@@ -3824,5 +4624,38 @@ declare function normalizeHeaders(headers: Headers): Record<string, string>;
3824
4624
  */
3825
4625
  declare function mergeHeaders(...headerObjects: (Record<string, string> | undefined)[]): Record<string, string>;
3826
4626
  //#endregion
3827
- export { AbortError, type AudioData, type AudioFormat, AuthError, BadRequestError, type CleanupTarget, ConnectionError, type ContextGeneralEntry, type ContextTranslationTerm, type CreateTranscriptionOptions, type DeleteAllFilesOptions, type DeleteAllTranscriptionsOptions, type ExpressLikeRequest, type FastifyLikeRequest, FetchHttpClient, type FileIdentifier, FileListResult, type GenerateSpeechOptions, type HandleWebhookOptions, type HonoLikeContext, type HttpClient, type HttpClientOptions, type HttpErrorCode, type HttpErrorDetails, type HttpMethod, type HttpObservabilityHooks, type HttpRequest, type HttpRequestBody, type HttpRequestMeta, type HttpResponse, type HttpResponseMeta, type HttpResponseType, type ISonioxTranscript, type ISonioxTranscription, type ListFilesOptions, type ListFilesResponse, type ListTranscriptionsOptions, type ListTranscriptionsResponse, type NestJSLikeRequest, NetworkError, type OneWayTranslationConfig, type QueryParams, QuotaError, type RealtimeClientOptions, RealtimeError, type RealtimeErrorCode, type RealtimeEvent, RealtimeOptions, type RealtimeResult, type RealtimeSegment, RealtimeSegmentBuffer, type RealtimeSegmentBufferOptions, type RealtimeSegmentOptions, RealtimeSttSession, type RealtimeToken, RealtimeTtsConnection, RealtimeTtsStream, type RealtimeUtterance, RealtimeUtteranceBuffer, type RealtimeUtteranceBufferOptions, type ResolvedConnectionConfig, SONIOX_API_BASE_URL, SONIOX_API_WEBHOOK_HEADER_ENV, SONIOX_API_WEBHOOK_SECRET_ENV, SONIOX_API_WS_URL, SONIOX_TMP_API_KEY_DURATION_MAX, SONIOX_TMP_API_KEY_DURATION_MIN, SONIOX_TMP_API_KEY_USAGE_TYPE, SONIOX_TTS_API_BASE_URL, SONIOX_TTS_WS_URL, type SegmentGroupKey, type SegmentTranscriptOptions, type SendStreamOptions, type SonioxConnectionConfig, SonioxError, type SonioxErrorCode, SonioxFile, type SonioxFileData, SonioxHttpError, type SonioxLanguage, type SonioxModel, SonioxNodeClient, SonioxNodeClientOptions, SonioxRealtimeApi, type SonioxRegion, SonioxTranscript, SonioxTranscription, type SonioxTranscriptionData, type SonioxTranscriptionMode, type SonioxTranslationTarget, SonioxTtsApi, StateError, type SttSessionConfig, type SttSessionEvents, type SttSessionOptions, type SttSessionState, TemporaryApiKeyRequest, TemporaryApiKeyResponse, TemporaryApiKeyUsageType, type TranscribeBaseOptions, type TranscribeFromFile, type TranscribeFromFileId, type TranscribeFromFileIdOptions, type TranscribeFromFileOptions, type TranscribeFromUrl, type TranscribeFromUrlOptions, type TranscribeOptions, type TranscriptResponse, type TranscriptSegment, type TranscriptToken, type TranscriptionContext, type TranscriptionIdentifier, TranscriptionListResult, type TranscriptionStatus, type TranslationConfig, type TtsAudioFormat, type TtsConnectionEvents, type TtsConnectionOptions, type TtsEvent, type TtsModel, type TtsStreamConfig, type TtsStreamEvents, type TtsStreamInput, type TtsStreamState, type TtsVoice, type TwoWayTranslationConfig, type UploadFileInput, type UploadFileOptions, type WaitOptions, type WebhookAuthConfig, type WebhookEvent, type WebhookEventStatus, type WebhookHandlerResult, type WebhookHandlerResultWithFetch, type WebhookHeaders, buildUrl, createAbortError, createHttpError, createNetworkError, createParseError, createTimeoutError, isAbortError, isSonioxError, isSonioxHttpError, mergeHeaders, normalizeHeaders, resolveConnectionConfig, segmentRealtimeTokens, segmentTranscript };
4627
+ //#region src/async/translation.d.ts
4628
+ /**
4629
+ * A tokens-bearing transcript-shaped object accepted by
4630
+ * {@link translateFromTranscript}.
4631
+ */
4632
+ type TranscriptLike = ISonioxTranscript | TranscriptResponse | {
4633
+ tokens: TranscriptToken[];
4634
+ };
4635
+ /**
4636
+ * Reshape a transcript produced by a translation-enabled transcription into a
4637
+ * structured {@link SonioxTranslation} result.
4638
+ *
4639
+ * This is the same logic `SonioxTranslationJob.getTranslation()` applies.
4640
+ * Use it directly in webhook handlers or anywhere else you already have a
4641
+ * transcript in hand.
4642
+ *
4643
+ * @param transcript - Transcript (or any object with a `tokens` array) emitted
4644
+ * for a translation-enabled transcription.
4645
+ * @param mode - Whether to reshape as one-way or two-way; the discriminator
4646
+ * tells the helper which result shape to produce.
4647
+ * @returns A {@link SonioxTranslation} keyed on `mode`.
4648
+ *
4649
+ * @example
4650
+ * ```typescript
4651
+ * import { translateFromTranscript } from '@soniox/node';
4652
+ *
4653
+ * // From a webhook handler that just received the transcript
4654
+ * const result = translateFromTranscript(transcript, { type: 'one_way', to: 'es' });
4655
+ * console.log(result.translation_text);
4656
+ * ```
4657
+ */
4658
+ declare function translateFromTranscript(transcript: TranscriptLike, mode: TranslateFromTranscriptMode): SonioxTranslation;
4659
+ //#endregion
4660
+ export { AbortError, type AudioData, type AudioFormat, AuthError, BadRequestError, type CleanupTarget, type ConcurrencyCurrentValues, type ConcurrencyLimitValues, type ConcurrencyLimitsResponse, type ConcurrencyScopeValues, ConnectionError, type ContextGeneralEntry, type ContextTranslationTerm, type CreateTranscriptionOptions, type DeleteAllFilesOptions, type DeleteAllTranscriptionsOptions, type ExpressLikeRequest, type FastifyLikeRequest, FetchHttpClient, type FileIdentifier, FileListResult, type FilesCountResponse, type GenerateSpeechOptions, type HandleWebhookOptions, type HonoLikeContext, type HttpClient, type HttpClientOptions, type HttpErrorCode, type HttpErrorDetails, type HttpMethod, type HttpObservabilityHooks, type HttpRequest, type HttpRequestBody, type HttpRequestMeta, type HttpResponse, type HttpResponseMeta, type HttpResponseType, type ISonioxTranscript, type ISonioxTranscription, type ISonioxTranslationJob, type ListFilesOptions, type ListFilesResponse, type ListTranscriptionsOptions, type ListTranscriptionsResponse, type ListUsageLogsOptions, type ListUsageLogsResponse, type NestJSLikeRequest, NetworkError, type OneWayTranslation, type OneWayTranslationConfig, type QueryParams, QuotaError, type RealtimeClientOptions, RealtimeError, type RealtimeErrorCode, type RealtimeEvent, RealtimeOptions, type RealtimeResult, type RealtimeSegment, RealtimeSegmentBuffer, type RealtimeSegmentBufferOptions, type RealtimeSegmentOptions, RealtimeSttSession, type RealtimeToken, RealtimeTtsConnection, RealtimeTtsStream, type RealtimeUtterance, RealtimeUtteranceBuffer, type RealtimeUtteranceBufferOptions, type ResolvedConnectionConfig, SONIOX_API_BASE_URL, SONIOX_API_WEBHOOK_HEADER_ENV, SONIOX_API_WEBHOOK_SECRET_ENV, SONIOX_API_WS_URL, SONIOX_TMP_API_KEY_DURATION_MAX, SONIOX_TMP_API_KEY_DURATION_MIN, SONIOX_TMP_API_KEY_USAGE_TYPE, SONIOX_TTS_API_BASE_URL, SONIOX_TTS_WS_URL, type SegmentGroupKey, type SegmentTranscriptOptions, type SendStreamOptions, SonioxConcurrencyLimitsAPI, type SonioxConnectionConfig, SonioxError, type SonioxErrorCode, SonioxFile, type SonioxFileData, SonioxHttpError, type SonioxLanguage, type SonioxModel, SonioxNodeClient, SonioxNodeClientOptions, SonioxRealtimeApi, type SonioxRegion, SonioxTranscript, SonioxTranscription, type SonioxTranscriptionData, type SonioxTranscriptionMode, type SonioxTranslation, SonioxTranslationJob, type SonioxTranslationTarget, SonioxTtsApi, type SonioxUsageLog, SonioxUsageLogsAPI, StateError, type SttSessionConfig, type SttSessionEvents, type SttSessionOptions, type SttSessionState, TemporaryApiKeyRequest, TemporaryApiKeyResponse, TemporaryApiKeyUsageType, type TranscribeBaseOptions, type TranscribeFromFile, type TranscribeFromFileId, type TranscribeFromFileIdOptions, type TranscribeFromFileOptions, type TranscribeFromUrl, type TranscribeFromUrlOptions, type TranscribeOptions, type TranscriptResponse, type TranscriptSegment, type TranscriptToken, type TranscriptionContext, type TranscriptionIdentifier, TranscriptionListResult, type TranscriptionStatus, type TranscriptionsCountResponse, type TranslateAudioSource, type TranslateBaseOptions, type TranslateFromTranscriptMode, type TranslateMode, type TranslateOptions, type TranslationConfig, type TranslationSegment, type TtsAudioFormat, type TtsConnectionEvents, type TtsConnectionOptions, type TtsEvent, type TtsLanguage, type TtsModel, type TtsStreamConfig, type TtsStreamEvents, type TtsStreamInput, type TtsStreamState, type TtsVoice, type TtsVoiceGender, type TwoWayTranslation, type TwoWayTranslationConfig, type UploadFileInput, type UploadFileOptions, UsageLogListResult, type UsageLogsSort, type WaitOptions, type WebhookAuthConfig, type WebhookEvent, type WebhookEventStatus, type WebhookHandlerResult, type WebhookHandlerResultWithFetch, type WebhookHeaders, buildUrl, createAbortError, createHttpError, createNetworkError, createParseError, createTimeoutError, isAbortError, isSonioxError, isSonioxHttpError, mergeHeaders, normalizeHeaders, resolveConnectionConfig, segmentRealtimeTokens, segmentTranscript, translateFromTranscript };
3828
4661
  //# sourceMappingURL=index.d.mts.map