@ai-sdk/google 4.0.53 → 4.0.54

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.53",
3
+ "version": "4.0.54",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -10,6 +10,7 @@ import type {
10
10
  Experimental_RealtimeFactoryV4GetTokenOptions as RealtimeFactoryV4GetTokenOptions,
11
11
  SpeechModelV4,
12
12
  Experimental_SpeechTranslationModelV4 as SpeechTranslationModelV4,
13
+ TranscriptionModelV4,
13
14
  } from '@ai-sdk/provider';
14
15
  import {
15
16
  generateId,
@@ -43,6 +44,8 @@ import {
43
44
  import type { GoogleInteractionsModelId } from './interactions/google-interactions-language-model-options';
44
45
  import type { GoogleInteractionsAgentName } from './interactions/google-interactions-agent';
45
46
  import { GoogleRealtimeModel } from './realtime/google-realtime-model';
47
+ import { GoogleTranscriptionModel } from './transcription/google-transcription-model';
48
+ import type { GoogleTranscriptionModelId } from './transcription/google-transcription-model-options';
46
49
  import { GoogleSpeechTranslationModel } from './speech-translation/google-speech-translation-model';
47
50
  import type { GoogleSpeechTranslationModelId } from './speech-translation/google-speech-translation-model-options';
48
51
 
@@ -120,6 +123,19 @@ export interface GoogleProvider extends ProviderV4 {
120
123
  */
121
124
  speechModel(modelId: GoogleSpeechModelId): SpeechModelV4;
122
125
 
126
+ /**
127
+ * Creates a model for transcription (speech-to-text). Unary models
128
+ * (e.g. `gemini-3.5-transcribe`) transcribe audio files; live models
129
+ * (e.g. `gemini-3.5-transcribe-live`) stream transcription over the
130
+ * Gemini Live API WebSocket via `experimental_streamTranscribe`.
131
+ */
132
+ transcription(modelId: GoogleTranscriptionModelId): TranscriptionModelV4;
133
+
134
+ /**
135
+ * Creates a model for transcription (speech-to-text).
136
+ */
137
+ transcriptionModel(modelId: GoogleTranscriptionModelId): TranscriptionModelV4;
138
+
123
139
  files(): FilesV4;
124
140
 
125
141
  /**
@@ -331,6 +347,15 @@ export function createGoogle(
331
347
  fetch: options.fetch,
332
348
  });
333
349
 
350
+ const createTranscriptionModel = (modelId: GoogleTranscriptionModelId) =>
351
+ new GoogleTranscriptionModel(modelId, {
352
+ provider: `${providerName}.transcription`,
353
+ baseURL,
354
+ headers: getHeaders,
355
+ fetch: options.fetch,
356
+ webSocket: options.webSocket,
357
+ });
358
+
334
359
  const experimentalRealtimeFactory = Object.assign(
335
360
  (modelId: string) => createRealtimeModel(modelId),
336
361
  {
@@ -393,6 +418,8 @@ export function createGoogle(
393
418
  provider.files = createFiles;
394
419
  provider.speech = createSpeechModel;
395
420
  provider.speechModel = createSpeechModel;
421
+ provider.transcription = createTranscriptionModel;
422
+ provider.transcriptionModel = createTranscriptionModel;
396
423
  provider.translation = createSpeechTranslationModel;
397
424
  provider.speechTranslationModel = createSpeechTranslationModel;
398
425
  provider.interactions = createInteractionsModel;
package/src/index.ts CHANGED
@@ -60,6 +60,11 @@ export type {
60
60
  GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId,
61
61
  GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions,
62
62
  } from './realtime/google-realtime-model-options';
63
+ export { GoogleTranscriptionModel } from './transcription/google-transcription-model';
64
+ export type {
65
+ GoogleTranscriptionModelId,
66
+ GoogleTranscriptionModelOptions,
67
+ } from './transcription/google-transcription-model-options';
63
68
  export {
64
69
  GoogleSpeechTranslationModel as Experimental_GoogleSpeechTranslationModel,
65
70
  /** @deprecated Use `Experimental_GoogleSpeechTranslationModel` instead. */
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod/v4';
2
+
3
+ export type GoogleTranscriptionModelId =
4
+ | 'gemini-3.5-transcribe'
5
+ | 'gemini-3.5-transcribe-live'
6
+ | (string & {});
7
+
8
+ /**
9
+ * Speech recognition options shared by unary (`gemini-3.5-transcribe`) and
10
+ * live (`gemini-3.5-transcribe-live`) transcription. Maps onto Google's
11
+ * `AudioTranscriptionConfig`.
12
+ */
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(),
19
+
20
+ /**
21
+ * Custom vocabulary phrases, which bias the speech recognition model
22
+ * toward recognizing specific terms.
23
+ */
24
+ customVocabulary: z.array(z.string()).optional(),
25
+
26
+ /**
27
+ * Enables word-level timestamp generation.
28
+ */
29
+ wordTimestamp: z.boolean().optional(),
30
+
31
+ /**
32
+ * Enables speaker diarization.
33
+ */
34
+ diarization: z.boolean().optional(),
35
+
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
+ });
47
+
48
+ export type GoogleTranscriptionModelOptions = z.infer<
49
+ typeof googleTranscriptionModelOptions
50
+ >;