@google/genai 1.12.0 → 1.13.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.
package/dist/web/web.d.ts CHANGED
@@ -1599,6 +1599,8 @@ export declare class DeleteModelResponse {
1599
1599
 
1600
1600
  /** The return value of delete operation. */
1601
1601
  export declare interface DeleteResourceJob {
1602
+ /** Used to retain the full HTTP response. */
1603
+ sdkHttpResponse?: HttpResponse;
1602
1604
  name?: string;
1603
1605
  done?: boolean;
1604
1606
  error?: JobError;
@@ -2501,9 +2503,6 @@ export declare class GenerateContentResponse {
2501
2503
  /** Timestamp when the request is made to the server.
2502
2504
  */
2503
2505
  createTime?: string;
2504
- /** Identifier for each response.
2505
- */
2506
- responseId?: string;
2507
2506
  /** The history of automatic function calling.
2508
2507
  */
2509
2508
  automaticFunctionCallingHistory?: Content[];
@@ -2511,6 +2510,8 @@ export declare class GenerateContentResponse {
2511
2510
  modelVersion?: string;
2512
2511
  /** Output only. Content filter results for a prompt sent in the request. Note: Sent only in the first stream chunk. Only happens when no candidates were generated due to content violations. */
2513
2512
  promptFeedback?: GenerateContentResponsePromptFeedback;
2513
+ /** Output only. response_id is used to identify each response. It is the encoding of the event_id. */
2514
+ responseId?: string;
2514
2515
  /** Usage metadata about the response(s). */
2515
2516
  usageMetadata?: GenerateContentResponseUsageMetadata;
2516
2517
  /**
@@ -4288,6 +4289,8 @@ export declare interface LiveMusicGenerationConfig {
4288
4289
  muteDrums?: boolean;
4289
4290
  /** Whether the audio output should contain only bass and drums. */
4290
4291
  onlyBassAndDrums?: boolean;
4292
+ /** The mode of music generation. Default mode is QUALITY. */
4293
+ musicGenerationMode?: MusicGenerationMode;
4291
4294
  }
4292
4295
 
4293
4296
  /** The playback control signal to apply to the music generation. */
@@ -5031,6 +5034,45 @@ export declare class Models extends BaseModule {
5031
5034
  private generateImagesInternal;
5032
5035
  private editImageInternal;
5033
5036
  private upscaleImageInternal;
5037
+ /**
5038
+ * Recontextualizes an image.
5039
+ *
5040
+ * There are two types of recontextualization currently supported:
5041
+ * 1) Imagen Product Recontext - Generate images of products in new scenes
5042
+ * and contexts.
5043
+ * 2) Virtual Try-On: Generate images of persons modeling fashion products.
5044
+ *
5045
+ * @param params - The parameters for recontextualizing an image.
5046
+ * @return The response from the API.
5047
+ *
5048
+ * @example
5049
+ * ```ts
5050
+ * const response1 = await ai.models.recontextImage({
5051
+ * model: 'imagen-product-recontext-preview-06-30',
5052
+ * source: {
5053
+ * prompt: 'In a modern kitchen setting.',
5054
+ * productImages: [productImage],
5055
+ * },
5056
+ * config: {
5057
+ * numberOfImages: 1,
5058
+ * },
5059
+ * });
5060
+ * console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
5061
+ *
5062
+ * const response2 = await ai.models.recontextImage({
5063
+ * model: 'virtual-try-on-preview-08-04',
5064
+ * source: {
5065
+ * personImage: personImage,
5066
+ * productImages: [productImage],
5067
+ * },
5068
+ * config: {
5069
+ * numberOfImages: 1,
5070
+ * },
5071
+ * });
5072
+ * console.log(response2?.generatedImages?.[0]?.image?.imageBytes);
5073
+ * ```
5074
+ */
5075
+ recontextImage(params: types.RecontextImageParameters): Promise<types.RecontextImageResponse>;
5034
5076
  /**
5035
5077
  * Fetches information about a model by name.
5036
5078
  *
@@ -5145,6 +5187,29 @@ export declare interface MultiSpeakerVoiceConfig {
5145
5187
  speakerVoiceConfigs?: SpeakerVoiceConfig[];
5146
5188
  }
5147
5189
 
5190
+ /** The mode of music generation. */
5191
+ export declare enum MusicGenerationMode {
5192
+ /**
5193
+ * Rely on the server default generation mode.
5194
+ */
5195
+ MUSIC_GENERATION_MODE_UNSPECIFIED = "MUSIC_GENERATION_MODE_UNSPECIFIED",
5196
+ /**
5197
+ * Steer text prompts to regions of latent space with higher quality
5198
+ music.
5199
+ */
5200
+ QUALITY = "QUALITY",
5201
+ /**
5202
+ * Steer text prompts to regions of latent space with a larger
5203
+ diversity of music.
5204
+ */
5205
+ DIVERSITY = "DIVERSITY",
5206
+ /**
5207
+ * Steer text prompts to regions of latent space more likely to
5208
+ generate music with vocals.
5209
+ */
5210
+ VOCALIZATION = "VOCALIZATION"
5211
+ }
5212
+
5148
5213
  /** A long-running operation. */
5149
5214
  export declare interface Operation<T> {
5150
5215
  /** The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */
@@ -5420,6 +5485,12 @@ export declare interface ProactivityConfig {
5420
5485
  proactiveAudio?: boolean;
5421
5486
  }
5422
5487
 
5488
+ /** An image of the product. */
5489
+ export declare interface ProductImage {
5490
+ /** An image of the product to be recontextualized. */
5491
+ productImage?: Image_2;
5492
+ }
5493
+
5423
5494
  /** A RagChunk includes the content of a chunk of a RagFile, and associated metadata. */
5424
5495
  export declare interface RagChunk {
5425
5496
  /** If populated, represents where the chunk starts and ends in the document. */
@@ -5515,6 +5586,69 @@ export declare interface RealtimeInputConfig {
5515
5586
  turnCoverage?: TurnCoverage;
5516
5587
  }
5517
5588
 
5589
+ /** Configuration for recontextualizing an image. */
5590
+ export declare interface RecontextImageConfig {
5591
+ /** Used to override HTTP request options. */
5592
+ httpOptions?: HttpOptions;
5593
+ /** Abort signal which can be used to cancel the request.
5594
+
5595
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
5596
+ operation will not cancel the request in the service. You will still
5597
+ be charged usage for any applicable operations.
5598
+ */
5599
+ abortSignal?: AbortSignal;
5600
+ /** Number of images to generate. */
5601
+ numberOfImages?: number;
5602
+ /** The number of sampling steps. A higher value has better image
5603
+ quality, while a lower value has better latency. */
5604
+ baseSteps?: number;
5605
+ /** Cloud Storage URI used to store the generated images. */
5606
+ outputGcsUri?: string;
5607
+ /** Random seed for image generation. */
5608
+ seed?: number;
5609
+ /** Filter level for safety filtering. */
5610
+ safetyFilterLevel?: SafetyFilterLevel;
5611
+ /** Whether allow to generate person images, and restrict to specific
5612
+ ages. */
5613
+ personGeneration?: PersonGeneration;
5614
+ /** MIME type of the generated image. */
5615
+ outputMimeType?: string;
5616
+ /** Compression quality of the generated image (for ``image/jpeg``
5617
+ only). */
5618
+ outputCompressionQuality?: number;
5619
+ /** Whether to use the prompt rewriting logic. */
5620
+ enhancePrompt?: boolean;
5621
+ }
5622
+
5623
+ /** The parameters for recontextualizing an image. */
5624
+ export declare interface RecontextImageParameters {
5625
+ /** ID of the model to use. For a list of models, see `Google models
5626
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
5627
+ model: string;
5628
+ /** A set of source input(s) for image recontextualization. */
5629
+ source: RecontextImageSource;
5630
+ /** Configuration for image recontextualization. */
5631
+ config?: RecontextImageConfig;
5632
+ }
5633
+
5634
+ /** The output images response. */
5635
+ export declare class RecontextImageResponse {
5636
+ /** List of generated images. */
5637
+ generatedImages?: GeneratedImage[];
5638
+ }
5639
+
5640
+ /** A set of source input(s) for image recontextualization. */
5641
+ export declare interface RecontextImageSource {
5642
+ /** A text prompt for guiding the model during image
5643
+ recontextualization. Not supported for Virtual Try-On. */
5644
+ prompt?: string;
5645
+ /** Image of the person or subject who will be wearing the
5646
+ product(s). */
5647
+ personImage?: Image_2;
5648
+ /** A list of product images. */
5649
+ productImages?: ProductImage[];
5650
+ }
5651
+
5518
5652
  export declare type ReferenceImage = RawReferenceImage | MaskReferenceImage | ControlReferenceImage | StyleReferenceImage | SubjectReferenceImage;
5519
5653
 
5520
5654
  /** Private class that represents a Reference image that is sent to API. */
@@ -6642,6 +6776,7 @@ declare namespace types {
6642
6776
  TurnCoverage,
6643
6777
  FunctionResponseScheduling,
6644
6778
  Scale,
6779
+ MusicGenerationMode,
6645
6780
  LiveMusicPlaybackControl,
6646
6781
  VideoMetadata,
6647
6782
  Blob_2 as Blob,
@@ -6752,6 +6887,11 @@ declare namespace types {
6752
6887
  EditImageConfig,
6753
6888
  EditImageResponse,
6754
6889
  UpscaleImageResponse,
6890
+ ProductImage,
6891
+ RecontextImageSource,
6892
+ RecontextImageConfig,
6893
+ RecontextImageParameters,
6894
+ RecontextImageResponse,
6755
6895
  GetModelConfig,
6756
6896
  GetModelParameters,
6757
6897
  Endpoint,
@@ -7128,7 +7268,15 @@ export declare enum UrlRetrievalStatus {
7128
7268
  /**
7129
7269
  * Url retrieval is failed due to error.
7130
7270
  */
7131
- URL_RETRIEVAL_STATUS_ERROR = "URL_RETRIEVAL_STATUS_ERROR"
7271
+ URL_RETRIEVAL_STATUS_ERROR = "URL_RETRIEVAL_STATUS_ERROR",
7272
+ /**
7273
+ * Url retrieval is failed because the content is behind paywall.
7274
+ */
7275
+ URL_RETRIEVAL_STATUS_PAYWALL = "URL_RETRIEVAL_STATUS_PAYWALL",
7276
+ /**
7277
+ * Url retrieval is failed because the content is unsafe.
7278
+ */
7279
+ URL_RETRIEVAL_STATUS_UNSAFE = "URL_RETRIEVAL_STATUS_UNSAFE"
7132
7280
  }
7133
7281
 
7134
7282
  /** Usage metadata about response(s). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/genai",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/node/index.mjs",
@@ -38,8 +38,14 @@
38
38
  },
39
39
  "scripts": {
40
40
  "prepare": "npm run build-prod",
41
- "build": "rollup -c && api-extractor run --local --verbose && api-extractor run -c api-extractor.node.json --local --verbose&& api-extractor run -c api-extractor.web.json --local --verbose && node scripts/ignore_missing_mcp_dep.js",
42
- "build-prod": "rollup -c && api-extractor run --verbose && api-extractor run -c api-extractor.node.json --verbose && api-extractor run -c api-extractor.web.json --verbose && node scripts/ignore_missing_mcp_dep.js",
41
+ "build": "rollup -c && npm-run-all --parallel api-extractor:dev:* && node scripts/ignore_missing_mcp_dep.js",
42
+ "build-prod": "rollup -c && npm-run-all --parallel api-extractor:prod:* && node scripts/ignore_missing_mcp_dep.js",
43
+ "api-extractor:dev:main": "api-extractor run --local --verbose",
44
+ "api-extractor:dev:node": "api-extractor run -c api-extractor.node.json --local --verbose",
45
+ "api-extractor:dev:web": "api-extractor run -c api-extractor.web.json --local --verbose",
46
+ "api-extractor:prod:main": "api-extractor run --verbose",
47
+ "api-extractor:prod:node": "api-extractor run -c api-extractor.node.json --verbose",
48
+ "api-extractor:prod:web": "api-extractor run -c api-extractor.web.json --verbose",
43
49
  "unit-test": "tsc && jasmine dist/test/unit/**/*_test.js dist/test/unit/*_test.js",
44
50
  "system-test": "tsc && jasmine dist/test/system/**/*_test.js",
45
51
  "test-server-tests": "tsc && GOOGLE_CLOUD_PROJECT=googcloudproj GOOGLE_CLOUD_LOCATION=googcloudloc jasmine dist/test/system/node/*_test.js -- --test-server",
@@ -49,7 +55,8 @@
49
55
  "pages-release": "node --loader ts-node/esm scripts/generate_pages.ts release",
50
56
  "format": "prettier '**/*.ts' '**/*.mjs' '**/*.json' --write",
51
57
  "lint": "eslint '**/*.ts'",
52
- "lint-fix": "eslint --fix '**/*.ts'"
58
+ "lint-fix": "eslint --fix '**/*.ts'",
59
+ "coverage-report": "./test/generate_report.sh"
53
60
  },
54
61
  "engines": {
55
62
  "node": ">=20.0.0"
@@ -71,16 +78,18 @@
71
78
  ],
72
79
  "devDependencies": {
73
80
  "@eslint/js": "9.20.0",
74
- "@microsoft/api-extractor": "^7.50.1",
81
+ "@microsoft/api-extractor": "^7.52.9",
75
82
  "@rollup/plugin-json": "^6.1.0",
76
83
  "@types/jasmine": "^5.1.2",
77
84
  "@types/node": "^20.9.0",
78
85
  "@types/unist": "^3.0.3",
79
86
  "@types/ws": "^8.5.14",
87
+ "c8": "^10.1.3",
80
88
  "eslint": "8.57.0",
81
89
  "gts": "^5.2.0",
82
90
  "jasmine": "^5.5.0",
83
91
  "jasmine-reporters": "^2.4.0",
92
+ "npm-run-all": "^4.1.5",
84
93
  "nyc": "^17.1.0",
85
94
  "prettier": "3.3.3",
86
95
  "prettier-plugin-organize-imports": "^4.1.0",