@ai-sdk/google 4.0.101 → 4.0.102

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.
@@ -1,3 +1,8 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
1
6
  import { z } from 'zod/v4';
2
7
 
3
8
  export type GoogleTranscriptionModelId =
@@ -10,41 +15,45 @@ export type GoogleTranscriptionModelId =
10
15
  * live (`gemini-3.5-transcribe-live`) transcription. Maps onto Google's
11
16
  * `AudioTranscriptionConfig`.
12
17
  */
13
- export const googleTranscriptionModelOptions = z.object({
14
- /**
15
- * BCP-47 language codes providing hints about the languages present in the
16
- * audio. If omitted or empty, defaults to automatic language detection.
17
- */
18
- languageCodes: z.array(z.string()).optional(),
18
+ export const googleTranscriptionModelOptions = lazySchema(() =>
19
+ zodSchema(
20
+ z.object({
21
+ /**
22
+ * BCP-47 language codes providing hints about the languages present in the
23
+ * audio. If omitted or empty, defaults to automatic language detection.
24
+ */
25
+ languageCodes: z.array(z.string()).optional(),
19
26
 
20
- /**
21
- * Custom vocabulary phrases, which bias the speech recognition model
22
- * toward recognizing specific terms.
23
- */
24
- customVocabulary: z.array(z.string()).optional(),
27
+ /**
28
+ * Custom vocabulary phrases, which bias the speech recognition model
29
+ * toward recognizing specific terms.
30
+ */
31
+ customVocabulary: z.array(z.string()).optional(),
25
32
 
26
- /**
27
- * Enables word-level timestamp generation.
28
- */
29
- wordTimestamp: z.boolean().optional(),
33
+ /**
34
+ * Enables word-level timestamp generation.
35
+ */
36
+ wordTimestamp: z.boolean().optional(),
30
37
 
31
- /**
32
- * Enables speaker diarization.
33
- */
34
- diarization: z.boolean().optional(),
38
+ /**
39
+ * Enables speaker diarization.
40
+ */
41
+ diarization: z.boolean().optional(),
35
42
 
36
- /**
37
- * Transcription output formatting mode.
38
- *
39
- * - `VERBATIM` (default): exact literal transcript preserving filler
40
- * words, repetitions, and false starts.
41
- * - `SMART`: cleans up and structures the transcript in real time —
42
- * disfluency removal, inline self-corrections, structured formatting
43
- * (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
44
- */
45
- mode: z.enum(['SMART', 'VERBATIM']).optional(),
46
- });
43
+ /**
44
+ * Transcription output formatting mode.
45
+ *
46
+ * - `VERBATIM` (default): exact literal transcript preserving filler
47
+ * words, repetitions, and false starts.
48
+ * - `SMART`: cleans up and structures the transcript in real time —
49
+ * disfluency removal, inline self-corrections, structured formatting
50
+ * (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
51
+ */
52
+ mode: z.enum(['SMART', 'VERBATIM']).optional(),
53
+ }),
54
+ ),
55
+ );
47
56
 
48
- export type GoogleTranscriptionModelOptions = z.infer<
57
+ export type GoogleTranscriptionModelOptions = InferSchema<
49
58
  typeof googleTranscriptionModelOptions
50
59
  >;
@@ -7,6 +7,8 @@ import {
7
7
  type TranscriptionModelV4,
8
8
  } from '@ai-sdk/provider';
9
9
  import {
10
+ lazySchema,
11
+ zodSchema,
10
12
  combineHeaders,
11
13
  connectToWebSocket,
12
14
  convertToBase64,
@@ -684,33 +686,38 @@ function validateLiveInputAudioFormat(
684
686
  }
685
687
  }
686
688
 
687
- const googleInteractionsWordAnnotationSchema = z.object({
688
- type: z.string().nullish(),
689
- text: z.string().nullish(),
690
- speaker: z.string().nullish(),
691
- start_offset: z.string().nullish(),
692
- end_offset: z.string().nullish(),
693
- });
694
-
695
- const googleInteractionsTranscriptionResponseSchema = z.object({
696
- status: z.string().nullish(),
697
- steps: z
698
- .array(
699
- z.object({
700
- type: z.string().nullish(),
701
- content: z
702
- .array(
703
- z.object({
704
- type: z.string().nullish(),
705
- text: z.string().nullish(),
706
- annotations: z
707
- .array(googleInteractionsWordAnnotationSchema)
708
- .nullish(),
709
- }),
710
- )
711
- .nullish(),
712
- }),
713
- )
714
- .nullish(),
715
- usage: z.record(z.string(), z.json()).nullish(),
716
- });
689
+ const googleInteractionsWordAnnotationSchema = () =>
690
+ z.object({
691
+ type: z.string().nullish(),
692
+ text: z.string().nullish(),
693
+ speaker: z.string().nullish(),
694
+ start_offset: z.string().nullish(),
695
+ end_offset: z.string().nullish(),
696
+ });
697
+
698
+ const googleInteractionsTranscriptionResponseSchema = lazySchema(() =>
699
+ zodSchema(
700
+ z.object({
701
+ status: z.string().nullish(),
702
+ steps: z
703
+ .array(
704
+ z.object({
705
+ type: z.string().nullish(),
706
+ content: z
707
+ .array(
708
+ z.object({
709
+ type: z.string().nullish(),
710
+ text: z.string().nullish(),
711
+ annotations: z
712
+ .array(googleInteractionsWordAnnotationSchema())
713
+ .nullish(),
714
+ }),
715
+ )
716
+ .nullish(),
717
+ }),
718
+ )
719
+ .nullish(),
720
+ usage: z.record(z.string(), z.json()).nullish(),
721
+ }),
722
+ ),
723
+ );