@ai-sdk/google 4.0.36 → 4.0.37

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.36",
3
+ "version": "4.0.37",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -42,8 +42,8 @@ import {
42
42
  import type { GoogleInteractionsModelId } from './interactions/google-interactions-language-model-options';
43
43
  import type { GoogleInteractionsAgentName } from './interactions/google-interactions-agent';
44
44
  import { GoogleRealtimeModel } from './realtime/google-realtime-model';
45
- import { GoogleTranslationModel } from './translation/google-translation-model';
46
- import type { GoogleTranslationModelId } from './translation/google-translation-model-options';
45
+ import { GoogleSpeechTranslationModel } from './speech-translation/google-speech-translation-model';
46
+ import type { GoogleSpeechTranslationModelId } from './speech-translation/google-speech-translation-model-options';
47
47
 
48
48
  export interface GoogleProvider extends ProviderV4 {
49
49
  (modelId: GoogleModelId): LanguageModelV4;
@@ -98,13 +98,15 @@ export interface GoogleProvider extends ProviderV4 {
98
98
  /**
99
99
  * Creates an experimental model for streaming speech translation.
100
100
  */
101
- translation(modelId: GoogleTranslationModelId): SpeechTranslationModelV4;
101
+ translation(
102
+ modelId: GoogleSpeechTranslationModelId,
103
+ ): SpeechTranslationModelV4;
102
104
 
103
105
  /**
104
106
  * Creates an experimental model for streaming speech translation.
105
107
  */
106
108
  speechTranslationModel(
107
- modelId: GoogleTranslationModelId,
109
+ modelId: GoogleSpeechTranslationModelId,
108
110
  ): SpeechTranslationModelV4;
109
111
 
110
112
  /**
@@ -310,9 +312,11 @@ export function createGoogle(
310
312
  fetch: options.fetch,
311
313
  });
312
314
 
313
- const createTranslationModel = (modelId: GoogleTranslationModelId) =>
314
- new GoogleTranslationModel(modelId, {
315
- provider: `${providerName}.translation`,
315
+ const createSpeechTranslationModel = (
316
+ modelId: GoogleSpeechTranslationModelId,
317
+ ) =>
318
+ new GoogleSpeechTranslationModel(modelId, {
319
+ provider: `${providerName}.speech-translation`,
316
320
  baseURL,
317
321
  headers: getHeaders,
318
322
  webSocket: options.webSocket,
@@ -388,8 +392,8 @@ export function createGoogle(
388
392
  provider.files = createFiles;
389
393
  provider.speech = createSpeechModel;
390
394
  provider.speechModel = createSpeechModel;
391
- provider.translation = createTranslationModel;
392
- provider.speechTranslationModel = createTranslationModel;
395
+ provider.translation = createSpeechTranslationModel;
396
+ provider.speechTranslationModel = createSpeechTranslationModel;
393
397
  provider.interactions = createInteractionsModel;
394
398
  provider.tools = googleTools;
395
399
 
package/src/index.ts CHANGED
@@ -60,11 +60,23 @@ export type {
60
60
  GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId,
61
61
  GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions,
62
62
  } from './realtime/google-realtime-model-options';
63
- export { GoogleTranslationModel as Experimental_GoogleTranslationModel } from './translation/google-translation-model';
64
- export type { GoogleTranslationModelConfig as Experimental_GoogleTranslationModelConfig } from './translation/google-translation-model';
63
+ export {
64
+ GoogleSpeechTranslationModel as Experimental_GoogleSpeechTranslationModel,
65
+ /** @deprecated Use `Experimental_GoogleSpeechTranslationModel` instead. */
66
+ GoogleSpeechTranslationModel as Experimental_GoogleTranslationModel,
67
+ } from './speech-translation/google-speech-translation-model';
68
+ export type {
69
+ GoogleSpeechTranslationModelConfig as Experimental_GoogleSpeechTranslationModelConfig,
70
+ /** @deprecated Use `Experimental_GoogleSpeechTranslationModelConfig` instead. */
71
+ GoogleSpeechTranslationModelConfig as Experimental_GoogleTranslationModelConfig,
72
+ } from './speech-translation/google-speech-translation-model';
65
73
  export type {
66
- GoogleTranslationModelId as Experimental_GoogleTranslationModelId,
67
- GoogleTranslationModelOptions as Experimental_GoogleTranslationModelOptions,
68
- } from './translation/google-translation-model-options';
74
+ GoogleSpeechTranslationModelId as Experimental_GoogleSpeechTranslationModelId,
75
+ /** @deprecated Use `Experimental_GoogleSpeechTranslationModelId` instead. */
76
+ GoogleSpeechTranslationModelId as Experimental_GoogleTranslationModelId,
77
+ GoogleSpeechTranslationModelOptions as Experimental_GoogleSpeechTranslationModelOptions,
78
+ /** @deprecated Use `Experimental_GoogleSpeechTranslationModelOptions` instead. */
79
+ GoogleSpeechTranslationModelOptions as Experimental_GoogleTranslationModelOptions,
80
+ } from './speech-translation/google-speech-translation-model-options';
69
81
 
70
82
  export { VERSION } from './version';
@@ -5,11 +5,11 @@ import {
5
5
  } from '@ai-sdk/provider-utils';
6
6
  import { z } from 'zod/v4';
7
7
 
8
- export type GoogleTranslationModelId =
8
+ export type GoogleSpeechTranslationModelId =
9
9
  | 'gemini-3.5-live-translate-preview'
10
10
  | (string & {});
11
11
 
12
- export const googleTranslationModelOptions = lazySchema(() =>
12
+ export const googleSpeechTranslationModelOptions = lazySchema(() =>
13
13
  zodSchema(
14
14
  z.object({
15
15
  /**
@@ -21,6 +21,6 @@ export const googleTranslationModelOptions = lazySchema(() =>
21
21
  ),
22
22
  );
23
23
 
24
- export type GoogleTranslationModelOptions = InferSchema<
25
- typeof googleTranslationModelOptions
24
+ export type GoogleSpeechTranslationModelOptions = InferSchema<
25
+ typeof googleSpeechTranslationModelOptions
26
26
  >;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  InvalidArgumentError,
3
- type Experimental_SpeechTranslationModelV4 as TranslationModelV4,
3
+ type Experimental_SpeechTranslationModelV4 as SpeechTranslationModelV4,
4
4
  type Experimental_SpeechTranslationModelV4StreamOptions as SpeechTranslationModelV4StreamOptions,
5
5
  type Experimental_SpeechTranslationModelV4StreamPart as SpeechTranslationModelV4StreamPart,
6
6
  type Experimental_SpeechTranslationModelV4Usage as SpeechTranslationModelV4Usage,
@@ -24,10 +24,10 @@ import {
24
24
  import { getModelPath } from '../get-model-path';
25
25
  import { getRealtimeWebSocketURL } from '../get-realtime-base-url';
26
26
  import {
27
- googleTranslationModelOptions,
28
- type GoogleTranslationModelId,
29
- type GoogleTranslationModelOptions,
30
- } from './google-translation-model-options';
27
+ googleSpeechTranslationModelOptions,
28
+ type GoogleSpeechTranslationModelId,
29
+ type GoogleSpeechTranslationModelOptions,
30
+ } from './google-speech-translation-model-options';
31
31
 
32
32
  const liveWebSocketPath =
33
33
  'google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent';
@@ -71,7 +71,7 @@ type GoogleLiveServerMessage = {
71
71
  error?: { message?: string };
72
72
  };
73
73
 
74
- export type GoogleTranslationModelConfig = {
74
+ export type GoogleSpeechTranslationModelConfig = {
75
75
  provider: string;
76
76
  baseURL: string;
77
77
  headers: () => Record<string, string | undefined>;
@@ -82,13 +82,13 @@ export type GoogleTranslationModelConfig = {
82
82
  };
83
83
  };
84
84
 
85
- export class GoogleTranslationModel implements TranslationModelV4 {
85
+ export class GoogleSpeechTranslationModel implements SpeechTranslationModelV4 {
86
86
  readonly specificationVersion = 'v4';
87
- readonly modelId: GoogleTranslationModelId;
87
+ readonly modelId: GoogleSpeechTranslationModelId;
88
88
 
89
- private readonly config: GoogleTranslationModelConfig;
89
+ private readonly config: GoogleSpeechTranslationModelConfig;
90
90
 
91
- static [WORKFLOW_SERIALIZE](model: GoogleTranslationModel) {
91
+ static [WORKFLOW_SERIALIZE](model: GoogleSpeechTranslationModel) {
92
92
  return serializeModelOptions({
93
93
  modelId: model.modelId,
94
94
  config: model.config,
@@ -96,10 +96,10 @@ export class GoogleTranslationModel implements TranslationModelV4 {
96
96
  }
97
97
 
98
98
  static [WORKFLOW_DESERIALIZE](options: {
99
- modelId: GoogleTranslationModelId;
100
- config: GoogleTranslationModelConfig;
99
+ modelId: GoogleSpeechTranslationModelId;
100
+ config: GoogleSpeechTranslationModelConfig;
101
101
  }) {
102
- return new GoogleTranslationModel(options.modelId, options.config);
102
+ return new GoogleSpeechTranslationModel(options.modelId, options.config);
103
103
  }
104
104
 
105
105
  get provider(): string {
@@ -107,8 +107,8 @@ export class GoogleTranslationModel implements TranslationModelV4 {
107
107
  }
108
108
 
109
109
  constructor(
110
- modelId: GoogleTranslationModelId,
111
- config: GoogleTranslationModelConfig,
110
+ modelId: GoogleSpeechTranslationModelId,
111
+ config: GoogleSpeechTranslationModelConfig,
112
112
  ) {
113
113
  this.modelId = modelId;
114
114
  this.config = config;
@@ -116,7 +116,7 @@ export class GoogleTranslationModel implements TranslationModelV4 {
116
116
 
117
117
  async doStream(
118
118
  options: SpeechTranslationModelV4StreamOptions,
119
- ): Promise<Awaited<ReturnType<TranslationModelV4['doStream']>>> {
119
+ ): Promise<Awaited<ReturnType<SpeechTranslationModelV4['doStream']>>> {
120
120
  if (options.targetLanguage == null) {
121
121
  throw new InvalidArgumentError({
122
122
  argument: 'targetLanguage',
@@ -128,11 +128,11 @@ export class GoogleTranslationModel implements TranslationModelV4 {
128
128
  const googleOptions = await parseProviderOptions({
129
129
  provider: 'google',
130
130
  providerOptions: options.providerOptions,
131
- schema: googleTranslationModelOptions,
131
+ schema: googleSpeechTranslationModelOptions,
132
132
  });
133
133
  const warnings: SharedV4Warning[] = [];
134
134
 
135
- validateGoogleTranslationInputAudioFormat(options.inputAudioFormat);
135
+ validateGoogleSpeechTranslationInputAudioFormat(options.inputAudioFormat);
136
136
 
137
137
  if (options.sourceLanguage != null) {
138
138
  warnings.push({
@@ -172,7 +172,7 @@ export class GoogleTranslationModel implements TranslationModelV4 {
172
172
  ),
173
173
  );
174
174
 
175
- const setup = buildGoogleLiveTranslationSetup({
175
+ const setup = buildGoogleLiveSpeechTranslationSetup({
176
176
  modelId: this.modelId,
177
177
  targetLanguage: options.targetLanguage,
178
178
  providerOptions: googleOptions,
@@ -184,7 +184,7 @@ export class GoogleTranslationModel implements TranslationModelV4 {
184
184
  timestamp: currentDate,
185
185
  modelId: this.modelId,
186
186
  },
187
- stream: createGoogleLiveTranslationStream({
187
+ stream: createGoogleLiveSpeechTranslationStream({
188
188
  webSocket: this.config.webSocket,
189
189
  url: getLiveWebSocketURL(this.config.baseURL, apiKey),
190
190
  headers: webSocketHeaders,
@@ -201,7 +201,7 @@ export class GoogleTranslationModel implements TranslationModelV4 {
201
201
  }
202
202
  }
203
203
 
204
- function createGoogleLiveTranslationStream({
204
+ function createGoogleLiveSpeechTranslationStream({
205
205
  webSocket,
206
206
  url,
207
207
  headers,
@@ -571,14 +571,14 @@ function getPcm16SilenceDurationMs(audio: string): number | undefined {
571
571
  return (sampleCount / googleLiveOutputAudioRate) * 1000;
572
572
  }
573
573
 
574
- function buildGoogleLiveTranslationSetup({
574
+ function buildGoogleLiveSpeechTranslationSetup({
575
575
  modelId,
576
576
  targetLanguage,
577
577
  providerOptions,
578
578
  }: {
579
579
  modelId: string;
580
580
  targetLanguage: string;
581
- providerOptions: GoogleTranslationModelOptions | undefined;
581
+ providerOptions: GoogleSpeechTranslationModelOptions | undefined;
582
582
  }) {
583
583
  return {
584
584
  model: getModelPath(modelId),
@@ -596,7 +596,7 @@ function buildGoogleLiveTranslationSetup({
596
596
  };
597
597
  }
598
598
 
599
- function validateGoogleTranslationInputAudioFormat(
599
+ function validateGoogleSpeechTranslationInputAudioFormat(
600
600
  inputAudioFormat: SpeechTranslationModelV4StreamOptions['inputAudioFormat'],
601
601
  ) {
602
602
  if (