@ai-sdk/google 4.0.0-canary.76 → 4.0.0-canary.78

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.0-canary.76",
3
+ "version": "4.0.0-canary.78",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@ai-sdk/provider": "4.0.0-canary.17",
39
- "@ai-sdk/provider-utils": "5.0.0-canary.44"
39
+ "@ai-sdk/provider-utils": "5.0.0-canary.45"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "22.19.19",
@@ -17,6 +17,7 @@ import { googleSpeechResponseSchema } from './google-speech-api';
17
17
  import {
18
18
  googleSpeechProviderOptionsSchema,
19
19
  type GoogleSpeechModelId,
20
+ type GoogleSpeechModelOptions,
20
21
  } from './google-speech-model-options';
21
22
 
22
23
  interface GoogleSpeechModelConfig {
@@ -70,11 +71,35 @@ export class GoogleSpeechModel implements SpeechModelV4 {
70
71
  }: Parameters<SpeechModelV4['doGenerate']>[0]) {
71
72
  const warnings: SharedV4Warning[] = [];
72
73
 
73
- const googleOptions = await parseProviderOptions({
74
- provider: 'google',
75
- providerOptions,
76
- schema: googleSpeechProviderOptionsSchema,
77
- });
74
+ // Names to look up in providerOptions. The Vertex provider exposes these
75
+ // under `googleVertex`/`vertex` (matching the Google Vertex language model),
76
+ // while every other Google provider uses `google`.
77
+ const providerOptionsNames: readonly string[] =
78
+ this.config.provider.includes('vertex')
79
+ ? (['googleVertex', 'vertex'] as const)
80
+ : (['google'] as const);
81
+
82
+ let googleOptions: GoogleSpeechModelOptions | undefined;
83
+ for (const name of providerOptionsNames) {
84
+ googleOptions = await parseProviderOptions({
85
+ provider: name,
86
+ providerOptions,
87
+ schema: googleSpeechProviderOptionsSchema,
88
+ });
89
+ if (googleOptions != null) {
90
+ break;
91
+ }
92
+ }
93
+
94
+ // Cross-namespace fallback: a Vertex provider may receive options under the
95
+ // `google` key (e.g. via the AI Gateway).
96
+ if (googleOptions == null && !providerOptionsNames.includes('google')) {
97
+ googleOptions = await parseProviderOptions({
98
+ provider: 'google',
99
+ providerOptions,
100
+ schema: googleSpeechProviderOptionsSchema,
101
+ });
102
+ }
78
103
 
79
104
  // Multi-speaker (provider option) takes precedence over the single voice.
80
105
  const multiSpeakerVoiceConfig = googleOptions?.multiSpeakerVoiceConfig;
@@ -133,7 +158,7 @@ export class GoogleSpeechModel implements SpeechModelV4 {
133
158
  }
134
159
 
135
160
  const requestBody = {
136
- contents: [{ parts: [{ text: promptText }] }],
161
+ contents: [{ role: 'user', parts: [{ text: promptText }] }],
137
162
  generationConfig: {
138
163
  responseModalities: ['AUDIO'],
139
164
  speechConfig,
@@ -1,3 +1,4 @@
1
1
  export * from '../google-language-model';
2
+ export * from '../google-speech-model';
2
3
  export { googleTools } from '../google-tools';
3
4
  export type { GoogleModelId } from '../google-language-model-options';