@google/genai 1.24.0 → 1.25.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.
@@ -221,6 +221,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
221
221
  throw error;
222
222
  }
223
223
  }
224
+ /**
225
+ * Moves values from source paths to destination paths.
226
+ *
227
+ * Examples:
228
+ * moveValueByPath(
229
+ * {'requests': [{'content': v1}, {'content': v2}]},
230
+ * {'requests[].*': 'requests[].request.*'}
231
+ * )
232
+ * -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
233
+ */
234
+ function moveValueByPath(data, paths) {
235
+ for (const [sourcePath, destPath] of Object.entries(paths)) {
236
+ const sourceKeys = sourcePath.split('.');
237
+ const destKeys = destPath.split('.');
238
+ // Determine keys to exclude from wildcard to avoid cyclic references
239
+ const excludeKeys = new Set();
240
+ let wildcardIdx = -1;
241
+ for (let i = 0; i < sourceKeys.length; i++) {
242
+ if (sourceKeys[i] === '*') {
243
+ wildcardIdx = i;
244
+ break;
245
+ }
246
+ }
247
+ if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
248
+ // Extract the intermediate key between source and dest paths
249
+ // Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
250
+ // We want to exclude 'request'
251
+ for (let i = wildcardIdx; i < destKeys.length; i++) {
252
+ const key = destKeys[i];
253
+ if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
254
+ excludeKeys.add(key);
255
+ }
256
+ }
257
+ }
258
+ _moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
259
+ }
260
+ }
261
+ /**
262
+ * Recursively moves values from source path to destination path.
263
+ */
264
+ function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
265
+ if (keyIdx >= sourceKeys.length) {
266
+ return;
267
+ }
268
+ if (typeof data !== 'object' || data === null) {
269
+ return;
270
+ }
271
+ const key = sourceKeys[keyIdx];
272
+ if (key.endsWith('[]')) {
273
+ const keyName = key.slice(0, -2);
274
+ const dataRecord = data;
275
+ if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
276
+ for (const item of dataRecord[keyName]) {
277
+ _moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
278
+ }
279
+ }
280
+ }
281
+ else if (key === '*') {
282
+ // wildcard - move all fields
283
+ if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
284
+ const dataRecord = data;
285
+ const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
286
+ const valuesToMove = {};
287
+ for (const k of keysToMove) {
288
+ valuesToMove[k] = dataRecord[k];
289
+ }
290
+ // Set values at destination
291
+ for (const [k, v] of Object.entries(valuesToMove)) {
292
+ const newDestKeys = [];
293
+ for (const dk of destKeys.slice(keyIdx)) {
294
+ if (dk === '*') {
295
+ newDestKeys.push(k);
296
+ }
297
+ else {
298
+ newDestKeys.push(dk);
299
+ }
300
+ }
301
+ setValueByPath(dataRecord, newDestKeys, v);
302
+ }
303
+ for (const k of keysToMove) {
304
+ delete dataRecord[k];
305
+ }
306
+ }
307
+ }
308
+ else {
309
+ // Navigate to next level
310
+ const dataRecord = data;
311
+ if (key in dataRecord) {
312
+ _moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
313
+ }
314
+ }
315
+ }
224
316
 
225
317
  /**
226
318
  * @license
@@ -362,7 +454,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
362
454
  }
363
455
  function generatedVideoFromMldev$1(fromObject) {
364
456
  const toObject = {};
365
- const fromVideo = getValueByPath(fromObject, ['_self']);
457
+ const fromVideo = getValueByPath(fromObject, ['video']);
366
458
  if (fromVideo != null) {
367
459
  setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
368
460
  }
@@ -398,14 +490,11 @@ function getOperationParametersToVertex(fromObject) {
398
490
  }
399
491
  function videoFromMldev$1(fromObject) {
400
492
  const toObject = {};
401
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
493
+ const fromUri = getValueByPath(fromObject, ['uri']);
402
494
  if (fromUri != null) {
403
495
  setValueByPath(toObject, ['uri'], fromUri);
404
496
  }
405
- const fromVideoBytes = getValueByPath(fromObject, [
406
- 'video',
407
- 'encodedVideo',
408
- ]);
497
+ const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
409
498
  if (fromVideoBytes != null) {
410
499
  setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
411
500
  }
@@ -3538,6 +3627,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
3538
3627
  const fromConfig = getValueByPath(fromObject, ['config']);
3539
3628
  if (fromConfig != null) {
3540
3629
  setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
3630
+ moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
3541
3631
  }
3542
3632
  return toObject;
3543
3633
  }
@@ -4319,38 +4409,11 @@ class Batches extends BaseModule {
4319
4409
  * ```
4320
4410
  */
4321
4411
  this.createEmbeddings = async (params) => {
4322
- var _a, _b;
4323
4412
  console.warn('batches.createEmbeddings() is experimental and may change without notice.');
4324
4413
  if (this.apiClient.isVertexAI()) {
4325
4414
  throw new Error('Vertex AI does not support batches.createEmbeddings.');
4326
4415
  }
4327
- // MLDEV
4328
- const src = params.src;
4329
- const is_inlined = src.inlinedRequests !== undefined;
4330
- if (!is_inlined) {
4331
- return this.createEmbeddingsInternal(params); // Fixed typo here
4332
- }
4333
- // Inlined embed content requests handling
4334
- const result = this.createInlinedEmbedContentRequest(params);
4335
- const path = result.path;
4336
- const requestBody = result.body;
4337
- const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4338
- const response = this.apiClient
4339
- .request({
4340
- path: path,
4341
- queryParams: queryParams,
4342
- body: JSON.stringify(requestBody),
4343
- httpMethod: 'POST',
4344
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4345
- abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4346
- })
4347
- .then((httpResponse) => {
4348
- return httpResponse.json();
4349
- });
4350
- return response.then((apiResponse) => {
4351
- const resp = batchJobFromMldev(apiResponse);
4352
- return resp;
4353
- });
4416
+ return this.createEmbeddingsInternal(params);
4354
4417
  };
4355
4418
  /**
4356
4419
  * Lists batch job configurations.
@@ -4398,35 +4461,6 @@ class Batches extends BaseModule {
4398
4461
  delete body['_query'];
4399
4462
  return { path, body };
4400
4463
  }
4401
- // Helper function to handle inlined embedding requests
4402
- createInlinedEmbedContentRequest(params) {
4403
- const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4404
- params);
4405
- const urlParams = body['_url'];
4406
- const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
4407
- const batch = body['batch'];
4408
- const inputConfig = batch['inputConfig'];
4409
- const requestsWrapper = inputConfig['requests'];
4410
- const requests = requestsWrapper['requests'];
4411
- const newRequests = [];
4412
- delete requestsWrapper['config']; // Remove top-level config
4413
- for (const request of requests) {
4414
- const requestDict = Object.assign({}, request); // Clone
4415
- const innerRequest = requestDict['request'];
4416
- for (const key in requestDict) {
4417
- if (key !== 'request') {
4418
- innerRequest[key] = requestDict[key];
4419
- delete requestDict[key];
4420
- }
4421
- }
4422
- newRequests.push(requestDict);
4423
- }
4424
- requestsWrapper['requests'] = newRequests;
4425
- delete body['config'];
4426
- delete body['_url'];
4427
- delete body['_query'];
4428
- return { path, body };
4429
- }
4430
4464
  // Helper function to get the first GCS URI
4431
4465
  getGcsUri(src) {
4432
4466
  if (typeof src === 'string') {
@@ -9301,7 +9335,7 @@ function generatedImageMaskFromVertex(fromObject) {
9301
9335
  }
9302
9336
  function generatedVideoFromMldev(fromObject) {
9303
9337
  const toObject = {};
9304
- const fromVideo = getValueByPath(fromObject, ['_self']);
9338
+ const fromVideo = getValueByPath(fromObject, ['video']);
9305
9339
  if (fromVideo != null) {
9306
9340
  setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
9307
9341
  }
@@ -10447,14 +10481,11 @@ function upscaleImageResponseFromVertex(fromObject) {
10447
10481
  }
10448
10482
  function videoFromMldev(fromObject) {
10449
10483
  const toObject = {};
10450
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
10484
+ const fromUri = getValueByPath(fromObject, ['uri']);
10451
10485
  if (fromUri != null) {
10452
10486
  setValueByPath(toObject, ['uri'], fromUri);
10453
10487
  }
10454
- const fromVideoBytes = getValueByPath(fromObject, [
10455
- 'video',
10456
- 'encodedVideo',
10457
- ]);
10488
+ const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
10458
10489
  if (fromVideoBytes != null) {
10459
10490
  setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
10460
10491
  }
@@ -10526,11 +10557,11 @@ function videoToMldev(fromObject) {
10526
10557
  const toObject = {};
10527
10558
  const fromUri = getValueByPath(fromObject, ['uri']);
10528
10559
  if (fromUri != null) {
10529
- setValueByPath(toObject, ['video', 'uri'], fromUri);
10560
+ setValueByPath(toObject, ['uri'], fromUri);
10530
10561
  }
10531
10562
  const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
10532
10563
  if (fromVideoBytes != null) {
10533
- setValueByPath(toObject, ['video', 'encodedVideo'], tBytes(fromVideoBytes));
10564
+ setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
10534
10565
  }
10535
10566
  const fromMimeType = getValueByPath(fromObject, ['mimeType']);
10536
10567
  if (fromMimeType != null) {
@@ -10564,7 +10595,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
10564
10595
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
10565
10596
  const USER_AGENT_HEADER = 'User-Agent';
10566
10597
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
10567
- const SDK_VERSION = '1.24.0'; // x-release-please-version
10598
+ const SDK_VERSION = '1.25.0'; // x-release-please-version
10568
10599
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
10569
10600
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
10570
10601
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -12342,9 +12373,26 @@ class Models extends BaseModule {
12342
12373
  * ```
12343
12374
  */
12344
12375
  this.generateVideos = async (params) => {
12376
+ var _a, _b, _c, _d, _e, _f;
12345
12377
  if ((params.prompt || params.image || params.video) && params.source) {
12346
12378
  throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
12347
12379
  }
12380
+ // Gemini API does not support video bytes.
12381
+ if (!this.apiClient.isVertexAI()) {
12382
+ if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
12383
+ params.video = {
12384
+ uri: params.video.uri,
12385
+ mimeType: params.video.mimeType,
12386
+ };
12387
+ }
12388
+ else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
12389
+ ((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
12390
+ params.source.video = {
12391
+ uri: params.source.video.uri,
12392
+ mimeType: params.source.video.mimeType,
12393
+ };
12394
+ }
12395
+ }
12348
12396
  return await this.generateVideosInternal(params);
12349
12397
  };
12350
12398
  }
@@ -199,6 +199,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
199
199
  throw error;
200
200
  }
201
201
  }
202
+ /**
203
+ * Moves values from source paths to destination paths.
204
+ *
205
+ * Examples:
206
+ * moveValueByPath(
207
+ * {'requests': [{'content': v1}, {'content': v2}]},
208
+ * {'requests[].*': 'requests[].request.*'}
209
+ * )
210
+ * -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
211
+ */
212
+ function moveValueByPath(data, paths) {
213
+ for (const [sourcePath, destPath] of Object.entries(paths)) {
214
+ const sourceKeys = sourcePath.split('.');
215
+ const destKeys = destPath.split('.');
216
+ // Determine keys to exclude from wildcard to avoid cyclic references
217
+ const excludeKeys = new Set();
218
+ let wildcardIdx = -1;
219
+ for (let i = 0; i < sourceKeys.length; i++) {
220
+ if (sourceKeys[i] === '*') {
221
+ wildcardIdx = i;
222
+ break;
223
+ }
224
+ }
225
+ if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
226
+ // Extract the intermediate key between source and dest paths
227
+ // Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
228
+ // We want to exclude 'request'
229
+ for (let i = wildcardIdx; i < destKeys.length; i++) {
230
+ const key = destKeys[i];
231
+ if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
232
+ excludeKeys.add(key);
233
+ }
234
+ }
235
+ }
236
+ _moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
237
+ }
238
+ }
239
+ /**
240
+ * Recursively moves values from source path to destination path.
241
+ */
242
+ function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
243
+ if (keyIdx >= sourceKeys.length) {
244
+ return;
245
+ }
246
+ if (typeof data !== 'object' || data === null) {
247
+ return;
248
+ }
249
+ const key = sourceKeys[keyIdx];
250
+ if (key.endsWith('[]')) {
251
+ const keyName = key.slice(0, -2);
252
+ const dataRecord = data;
253
+ if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
254
+ for (const item of dataRecord[keyName]) {
255
+ _moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
256
+ }
257
+ }
258
+ }
259
+ else if (key === '*') {
260
+ // wildcard - move all fields
261
+ if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
262
+ const dataRecord = data;
263
+ const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
264
+ const valuesToMove = {};
265
+ for (const k of keysToMove) {
266
+ valuesToMove[k] = dataRecord[k];
267
+ }
268
+ // Set values at destination
269
+ for (const [k, v] of Object.entries(valuesToMove)) {
270
+ const newDestKeys = [];
271
+ for (const dk of destKeys.slice(keyIdx)) {
272
+ if (dk === '*') {
273
+ newDestKeys.push(k);
274
+ }
275
+ else {
276
+ newDestKeys.push(dk);
277
+ }
278
+ }
279
+ setValueByPath(dataRecord, newDestKeys, v);
280
+ }
281
+ for (const k of keysToMove) {
282
+ delete dataRecord[k];
283
+ }
284
+ }
285
+ }
286
+ else {
287
+ // Navigate to next level
288
+ const dataRecord = data;
289
+ if (key in dataRecord) {
290
+ _moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
291
+ }
292
+ }
293
+ }
202
294
 
203
295
  /**
204
296
  * @license
@@ -340,7 +432,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
340
432
  }
341
433
  function generatedVideoFromMldev$1(fromObject) {
342
434
  const toObject = {};
343
- const fromVideo = getValueByPath(fromObject, ['_self']);
435
+ const fromVideo = getValueByPath(fromObject, ['video']);
344
436
  if (fromVideo != null) {
345
437
  setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
346
438
  }
@@ -376,14 +468,11 @@ function getOperationParametersToVertex(fromObject) {
376
468
  }
377
469
  function videoFromMldev$1(fromObject) {
378
470
  const toObject = {};
379
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
471
+ const fromUri = getValueByPath(fromObject, ['uri']);
380
472
  if (fromUri != null) {
381
473
  setValueByPath(toObject, ['uri'], fromUri);
382
474
  }
383
- const fromVideoBytes = getValueByPath(fromObject, [
384
- 'video',
385
- 'encodedVideo',
386
- ]);
475
+ const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
387
476
  if (fromVideoBytes != null) {
388
477
  setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
389
478
  }
@@ -3516,6 +3605,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
3516
3605
  const fromConfig = getValueByPath(fromObject, ['config']);
3517
3606
  if (fromConfig != null) {
3518
3607
  setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
3608
+ moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
3519
3609
  }
3520
3610
  return toObject;
3521
3611
  }
@@ -4297,38 +4387,11 @@ class Batches extends BaseModule {
4297
4387
  * ```
4298
4388
  */
4299
4389
  this.createEmbeddings = async (params) => {
4300
- var _a, _b;
4301
4390
  console.warn('batches.createEmbeddings() is experimental and may change without notice.');
4302
4391
  if (this.apiClient.isVertexAI()) {
4303
4392
  throw new Error('Vertex AI does not support batches.createEmbeddings.');
4304
4393
  }
4305
- // MLDEV
4306
- const src = params.src;
4307
- const is_inlined = src.inlinedRequests !== undefined;
4308
- if (!is_inlined) {
4309
- return this.createEmbeddingsInternal(params); // Fixed typo here
4310
- }
4311
- // Inlined embed content requests handling
4312
- const result = this.createInlinedEmbedContentRequest(params);
4313
- const path = result.path;
4314
- const requestBody = result.body;
4315
- const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4316
- const response = this.apiClient
4317
- .request({
4318
- path: path,
4319
- queryParams: queryParams,
4320
- body: JSON.stringify(requestBody),
4321
- httpMethod: 'POST',
4322
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4323
- abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4324
- })
4325
- .then((httpResponse) => {
4326
- return httpResponse.json();
4327
- });
4328
- return response.then((apiResponse) => {
4329
- const resp = batchJobFromMldev(apiResponse);
4330
- return resp;
4331
- });
4394
+ return this.createEmbeddingsInternal(params);
4332
4395
  };
4333
4396
  /**
4334
4397
  * Lists batch job configurations.
@@ -4376,35 +4439,6 @@ class Batches extends BaseModule {
4376
4439
  delete body['_query'];
4377
4440
  return { path, body };
4378
4441
  }
4379
- // Helper function to handle inlined embedding requests
4380
- createInlinedEmbedContentRequest(params) {
4381
- const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4382
- params);
4383
- const urlParams = body['_url'];
4384
- const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
4385
- const batch = body['batch'];
4386
- const inputConfig = batch['inputConfig'];
4387
- const requestsWrapper = inputConfig['requests'];
4388
- const requests = requestsWrapper['requests'];
4389
- const newRequests = [];
4390
- delete requestsWrapper['config']; // Remove top-level config
4391
- for (const request of requests) {
4392
- const requestDict = Object.assign({}, request); // Clone
4393
- const innerRequest = requestDict['request'];
4394
- for (const key in requestDict) {
4395
- if (key !== 'request') {
4396
- innerRequest[key] = requestDict[key];
4397
- delete requestDict[key];
4398
- }
4399
- }
4400
- newRequests.push(requestDict);
4401
- }
4402
- requestsWrapper['requests'] = newRequests;
4403
- delete body['config'];
4404
- delete body['_url'];
4405
- delete body['_query'];
4406
- return { path, body };
4407
- }
4408
4442
  // Helper function to get the first GCS URI
4409
4443
  getGcsUri(src) {
4410
4444
  if (typeof src === 'string') {
@@ -9279,7 +9313,7 @@ function generatedImageMaskFromVertex(fromObject) {
9279
9313
  }
9280
9314
  function generatedVideoFromMldev(fromObject) {
9281
9315
  const toObject = {};
9282
- const fromVideo = getValueByPath(fromObject, ['_self']);
9316
+ const fromVideo = getValueByPath(fromObject, ['video']);
9283
9317
  if (fromVideo != null) {
9284
9318
  setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
9285
9319
  }
@@ -10425,14 +10459,11 @@ function upscaleImageResponseFromVertex(fromObject) {
10425
10459
  }
10426
10460
  function videoFromMldev(fromObject) {
10427
10461
  const toObject = {};
10428
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
10462
+ const fromUri = getValueByPath(fromObject, ['uri']);
10429
10463
  if (fromUri != null) {
10430
10464
  setValueByPath(toObject, ['uri'], fromUri);
10431
10465
  }
10432
- const fromVideoBytes = getValueByPath(fromObject, [
10433
- 'video',
10434
- 'encodedVideo',
10435
- ]);
10466
+ const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
10436
10467
  if (fromVideoBytes != null) {
10437
10468
  setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
10438
10469
  }
@@ -10504,11 +10535,11 @@ function videoToMldev(fromObject) {
10504
10535
  const toObject = {};
10505
10536
  const fromUri = getValueByPath(fromObject, ['uri']);
10506
10537
  if (fromUri != null) {
10507
- setValueByPath(toObject, ['video', 'uri'], fromUri);
10538
+ setValueByPath(toObject, ['uri'], fromUri);
10508
10539
  }
10509
10540
  const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
10510
10541
  if (fromVideoBytes != null) {
10511
- setValueByPath(toObject, ['video', 'encodedVideo'], tBytes(fromVideoBytes));
10542
+ setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
10512
10543
  }
10513
10544
  const fromMimeType = getValueByPath(fromObject, ['mimeType']);
10514
10545
  if (fromMimeType != null) {
@@ -10542,7 +10573,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
10542
10573
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
10543
10574
  const USER_AGENT_HEADER = 'User-Agent';
10544
10575
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
10545
- const SDK_VERSION = '1.24.0'; // x-release-please-version
10576
+ const SDK_VERSION = '1.25.0'; // x-release-please-version
10546
10577
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
10547
10578
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
10548
10579
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -12320,9 +12351,26 @@ class Models extends BaseModule {
12320
12351
  * ```
12321
12352
  */
12322
12353
  this.generateVideos = async (params) => {
12354
+ var _a, _b, _c, _d, _e, _f;
12323
12355
  if ((params.prompt || params.image || params.video) && params.source) {
12324
12356
  throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
12325
12357
  }
12358
+ // Gemini API does not support video bytes.
12359
+ if (!this.apiClient.isVertexAI()) {
12360
+ if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
12361
+ params.video = {
12362
+ uri: params.video.uri,
12363
+ mimeType: params.video.mimeType,
12364
+ };
12365
+ }
12366
+ else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
12367
+ ((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
12368
+ params.source.video = {
12369
+ uri: params.source.video.uri,
12370
+ mimeType: params.source.video.mimeType,
12371
+ };
12372
+ }
12373
+ }
12326
12374
  return await this.generateVideosInternal(params);
12327
12375
  };
12328
12376
  }