@google/genai 1.40.0 → 1.42.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.
@@ -763,6 +763,7 @@ declare class BaseGeminiNextGenAPIClient {
763
763
  timeout: number;
764
764
  }>;
765
765
  private buildHeaders;
766
+ private _makeAbort;
766
767
  private buildBody;
767
768
  static DEFAULT_TIMEOUT: number;
768
769
  }
@@ -777,7 +778,7 @@ declare class BaseInteractions extends APIResource {
777
778
  * const interaction = await client.interactions.create({
778
779
  * api_version: 'api_version',
779
780
  * input: 'string',
780
- * model: 'gemini-2.5-pro',
781
+ * model: 'gemini-2.5-flash',
781
782
  * });
782
783
  * ```
783
784
  */
@@ -1729,12 +1730,12 @@ export declare interface Content {
1729
1730
  declare type Content_2 = TextContent | ImageContent | AudioContent | DocumentContent | VideoContent | ThoughtContent | FunctionCallContent | FunctionResultContent | CodeExecutionCallContent | CodeExecutionResultContent | URLContextCallContent | URLContextResultContent | GoogleSearchCallContent | GoogleSearchResultContent | MCPServerToolCallContent | MCPServerToolResultContent | FileSearchCallContent | FileSearchResultContent;
1730
1731
 
1731
1732
  declare interface ContentDelta {
1733
+ event_type: 'content.delta';
1732
1734
  delta?: ContentDelta.TextDelta | ContentDelta.ImageDelta | ContentDelta.AudioDelta | ContentDelta.DocumentDelta | ContentDelta.VideoDelta | ContentDelta.ThoughtSummaryDelta | ContentDelta.ThoughtSignatureDelta | ContentDelta.FunctionCallDelta | ContentDelta.FunctionResultDelta | ContentDelta.CodeExecutionCallDelta | ContentDelta.CodeExecutionResultDelta | ContentDelta.URLContextCallDelta | ContentDelta.URLContextResultDelta | ContentDelta.GoogleSearchCallDelta | ContentDelta.GoogleSearchResultDelta | ContentDelta.MCPServerToolCallDelta | ContentDelta.MCPServerToolResultDelta | ContentDelta.FileSearchCallDelta | ContentDelta.FileSearchResultDelta;
1733
1735
  /**
1734
1736
  * The event_id token to be used to resume the interaction stream, from this event.
1735
1737
  */
1736
1738
  event_id?: string;
1737
- event_type?: 'content.delta';
1738
1739
  index?: number;
1739
1740
  }
1740
1741
 
@@ -1827,11 +1828,11 @@ declare namespace ContentDelta {
1827
1828
  /**
1828
1829
  * Tool call result delta.
1829
1830
  */
1830
- result?: FunctionResultDelta.Items | string;
1831
+ result?: FunctionResultDelta.Items | unknown | string;
1831
1832
  }
1832
1833
  namespace FunctionResultDelta {
1833
1834
  interface Items {
1834
- items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent | unknown>;
1835
+ items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent>;
1835
1836
  }
1836
1837
  }
1837
1838
  interface CodeExecutionCallDelta {
@@ -1919,12 +1920,12 @@ declare namespace ContentDelta {
1919
1920
  /**
1920
1921
  * Tool call result delta.
1921
1922
  */
1922
- result?: MCPServerToolResultDelta.Items | string;
1923
+ result?: MCPServerToolResultDelta.Items | unknown | string;
1923
1924
  server_name?: string;
1924
1925
  }
1925
1926
  namespace MCPServerToolResultDelta {
1926
1927
  interface Items {
1927
- items?: Array<string | InteractionsAPI.ImageContent | unknown>;
1928
+ items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent>;
1928
1929
  }
1929
1930
  }
1930
1931
  interface FileSearchCallDelta {
@@ -2000,6 +2001,7 @@ export declare class ContentReferenceImage {
2000
2001
  }
2001
2002
 
2002
2003
  declare interface ContentStart {
2004
+ event_type: 'content.start';
2003
2005
  /**
2004
2006
  * The content of the response.
2005
2007
  */
@@ -2008,16 +2010,15 @@ declare interface ContentStart {
2008
2010
  * The event_id token to be used to resume the interaction stream, from this event.
2009
2011
  */
2010
2012
  event_id?: string;
2011
- event_type?: 'content.start';
2012
2013
  index?: number;
2013
2014
  }
2014
2015
 
2015
2016
  declare interface ContentStop {
2017
+ event_type: 'content.stop';
2016
2018
  /**
2017
2019
  * The event_id token to be used to resume the interaction stream, from this event.
2018
2020
  */
2019
2021
  event_id?: string;
2020
- event_type?: 'content.stop';
2021
2022
  index?: number;
2022
2023
  }
2023
2024
 
@@ -2484,6 +2485,8 @@ export declare interface CreateTuningJobConfig {
2484
2485
  sftLossWeightMultiplier?: number;
2485
2486
  /** The Google Cloud Storage location where the tuning job outputs are written. */
2486
2487
  outputUri?: string;
2488
+ /** The encryption spec of the tuning job. Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with provided encryption key. */
2489
+ encryptionSpec?: EncryptionSpec;
2487
2490
  }
2488
2491
 
2489
2492
  /** Fine-tuning job creation parameters - optional fields. */
@@ -2579,11 +2582,11 @@ export declare interface DatasetStats {
2579
2582
  * Configuration for the Deep Research agent.
2580
2583
  */
2581
2584
  declare interface DeepResearchAgentConfig {
2585
+ type: 'deep-research';
2582
2586
  /**
2583
2587
  * Whether to include thought summaries in the response.
2584
2588
  */
2585
2589
  thinking_summaries?: 'auto' | 'none';
2586
- type?: 'deep-research';
2587
2590
  }
2588
2591
 
2589
2592
  /** Optional parameters for models.get method. */
@@ -2919,7 +2922,7 @@ export declare interface DownloadFileParameters {
2919
2922
  * Configuration for dynamic agents.
2920
2923
  */
2921
2924
  declare interface DynamicAgentConfig {
2922
- type?: 'dynamic';
2925
+ type: 'dynamic';
2923
2926
  [k: string]: unknown;
2924
2927
  }
2925
2928
 
@@ -3095,6 +3098,25 @@ export declare interface EmbedContentParameters {
3095
3098
  config?: EmbedContentConfig;
3096
3099
  }
3097
3100
 
3101
+ /** Parameters for the _embed_content method. */
3102
+ export declare interface EmbedContentParametersPrivate {
3103
+ /** ID of the model to use. For a list of models, see `Google models
3104
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
3105
+ model: string;
3106
+ /** The content to embed. Only the `parts.text` fields will be counted.
3107
+ */
3108
+ contents?: ContentListUnion;
3109
+ /** The single content to embed. Only the `parts.text` fields will be counted.
3110
+ */
3111
+ content?: ContentUnion;
3112
+ /** The Vertex embedding API to use.
3113
+ */
3114
+ embeddingApiType?: EmbeddingApiType;
3115
+ /** Configuration that contains optional parameters.
3116
+ */
3117
+ config?: EmbedContentConfig;
3118
+ }
3119
+
3098
3120
  /** Response for the embed_content method. */
3099
3121
  export declare class EmbedContentResponse {
3100
3122
  /** Used to retain the full HTTP response. */
@@ -3108,6 +3130,18 @@ export declare class EmbedContentResponse {
3108
3130
  metadata?: EmbedContentMetadata;
3109
3131
  }
3110
3132
 
3133
+ /** Enum representing the Vertex embedding API to use. */
3134
+ export declare enum EmbeddingApiType {
3135
+ /**
3136
+ * predict API endpoint (default)
3137
+ */
3138
+ PREDICT = "PREDICT",
3139
+ /**
3140
+ * embedContent API Endpoint
3141
+ */
3142
+ EMBED_CONTENT = "EMBED_CONTENT"
3143
+ }
3144
+
3111
3145
  export declare interface EmbeddingsBatchJobSource {
3112
3146
  /** The Gemini Developer API's file resource name of the input data
3113
3147
  (e.g. "files/12345").
@@ -3177,6 +3211,7 @@ export declare enum Environment {
3177
3211
  }
3178
3212
 
3179
3213
  declare interface ErrorEvent_2 {
3214
+ event_type: 'error';
3180
3215
  /**
3181
3216
  * Error message from an interaction.
3182
3217
  */
@@ -3185,7 +3220,6 @@ declare interface ErrorEvent_2 {
3185
3220
  * The event_id token to be used to resume the interaction stream, from this event.
3186
3221
  */
3187
3222
  event_id?: string;
3188
- event_type?: 'error';
3189
3223
  }
3190
3224
 
3191
3225
  declare namespace ErrorEvent_2 {
@@ -3962,7 +3996,7 @@ declare interface FunctionResultContent {
3962
3996
 
3963
3997
  declare namespace FunctionResultContent {
3964
3998
  interface Items {
3965
- items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent | unknown>;
3999
+ items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent>;
3966
4000
  }
3967
4001
  }
3968
4002
 
@@ -5441,6 +5475,8 @@ export declare interface HttpOptions {
5441
5475
  - VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
5442
5476
  - GeminiAPI backend API docs: https://ai.google.dev/api/rest */
5443
5477
  extraBody?: Record<string, unknown>;
5478
+ /** HTTP retry options for the request. */
5479
+ retryOptions?: HttpRetryOptions;
5444
5480
  }
5445
5481
 
5446
5482
  /**
@@ -5504,6 +5540,13 @@ export declare class HttpResponse {
5504
5540
  json(): Promise<unknown>;
5505
5541
  }
5506
5542
 
5543
+ /** HTTP retry options to be used in each of the requests. */
5544
+ export declare interface HttpRetryOptions {
5545
+ /** Maximum number of attempts, including the original request.
5546
+ If 0 or 1, it means no retries. If not specified, default to 5. */
5547
+ attempts?: number;
5548
+ }
5549
+
5507
5550
  /** An image. */
5508
5551
  declare interface Image_2 {
5509
5552
  /** The Cloud Storage URI of the image. ``Image`` can contain a value
@@ -5716,7 +5759,7 @@ declare interface Interaction {
5716
5759
  /**
5717
5760
  * Output only. The status of the interaction.
5718
5761
  */
5719
- status: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled';
5762
+ status: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled' | 'incomplete';
5720
5763
  /**
5721
5764
  * The name of the `Agent` used for generating the interaction.
5722
5765
  */
@@ -5761,11 +5804,11 @@ declare interface InteractionCancelParams {
5761
5804
  }
5762
5805
 
5763
5806
  declare interface InteractionCompleteEvent {
5807
+ event_type: 'interaction.complete';
5764
5808
  /**
5765
5809
  * The event_id token to be used to resume the interaction stream, from this event.
5766
5810
  */
5767
5811
  event_id?: string;
5768
- event_type?: 'interaction.complete';
5769
5812
  /**
5770
5813
  * The Interaction resource.
5771
5814
  */
@@ -5907,11 +5950,11 @@ declare namespace InteractionsAPI {
5907
5950
  declare type InteractionSSEEvent = InteractionStartEvent | InteractionCompleteEvent | InteractionStatusUpdate | ContentStart | ContentDelta | ContentStop | ErrorEvent_2;
5908
5951
 
5909
5952
  declare interface InteractionStartEvent {
5953
+ event_type: 'interaction.start';
5910
5954
  /**
5911
5955
  * The event_id token to be used to resume the interaction stream, from this event.
5912
5956
  */
5913
5957
  event_id?: string;
5914
- event_type?: 'interaction.start';
5915
5958
  /**
5916
5959
  * The Interaction resource.
5917
5960
  */
@@ -5919,13 +5962,13 @@ declare interface InteractionStartEvent {
5919
5962
  }
5920
5963
 
5921
5964
  declare interface InteractionStatusUpdate {
5965
+ event_type: 'interaction.status_update';
5922
5966
  /**
5923
5967
  * The event_id token to be used to resume the interaction stream, from this event.
5924
5968
  */
5925
5969
  event_id?: string;
5926
- event_type?: 'interaction.status_update';
5927
5970
  interaction_id?: string;
5928
- status?: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled';
5971
+ status?: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled' | 'incomplete';
5929
5972
  }
5930
5973
 
5931
5974
  /** Parameters for the private _Register method. */
@@ -7145,7 +7188,7 @@ declare interface MCPServerToolResultContent {
7145
7188
 
7146
7189
  declare namespace MCPServerToolResultContent {
7147
7190
  interface Items {
7148
- items?: Array<string | InteractionsAPI.ImageContent | unknown>;
7191
+ items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent>;
7149
7192
  }
7150
7193
  }
7151
7194
 
@@ -7303,7 +7346,7 @@ export declare interface Model {
7303
7346
  /**
7304
7347
  * The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.
7305
7348
  */
7306
- declare type Model_2 = 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-native-audio-dialog' | 'gemini-2.5-flash-image-preview' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-pro-preview' | 'gemini-3-flash-preview' | (string & {});
7349
+ declare type Model_2 = 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | (string & {});
7307
7350
 
7308
7351
  /** Configuration for Model Armor integrations of prompt and responses. This data type is not supported in Gemini API. */
7309
7352
  export declare interface ModelArmorConfig {
@@ -7316,6 +7359,28 @@ export declare interface ModelArmorConfig {
7316
7359
  export declare class Models extends BaseModule {
7317
7360
  private readonly apiClient;
7318
7361
  constructor(apiClient: ApiClient);
7362
+ /**
7363
+ * Calculates embeddings for the given contents.
7364
+ *
7365
+ * @param params - The parameters for embedding contents.
7366
+ * @return The response from the API.
7367
+ *
7368
+ * @example
7369
+ * ```ts
7370
+ * const response = await ai.models.embedContent({
7371
+ * model: 'text-embedding-004',
7372
+ * contents: [
7373
+ * 'What is your name?',
7374
+ * 'What is your favorite color?',
7375
+ * ],
7376
+ * config: {
7377
+ * outputDimensionality: 64,
7378
+ * },
7379
+ * });
7380
+ * console.log(response);
7381
+ * ```
7382
+ */
7383
+ embedContent: (params: types.EmbedContentParameters) => Promise<types.EmbedContentResponse>;
7319
7384
  /**
7320
7385
  * Makes an API request to generate content with a given model.
7321
7386
  *
@@ -7526,7 +7591,7 @@ export declare class Models extends BaseModule {
7526
7591
  * console.log(response);
7527
7592
  * ```
7528
7593
  */
7529
- embedContent(params: types.EmbedContentParameters): Promise<types.EmbedContentResponse>;
7594
+ private embedContentInternal;
7530
7595
  /**
7531
7596
  * Private method for generating images.
7532
7597
  */
@@ -10019,6 +10084,7 @@ declare namespace types {
10019
10084
  ResourceScope,
10020
10085
  FeatureSelectionPreference,
10021
10086
  Environment,
10087
+ EmbeddingApiType,
10022
10088
  SafetyFilterLevel,
10023
10089
  PersonGeneration,
10024
10090
  ImagePromptLanguage,
@@ -10059,6 +10125,7 @@ declare namespace types {
10059
10125
  VideoMetadata,
10060
10126
  Part,
10061
10127
  Content,
10128
+ HttpRetryOptions,
10062
10129
  HttpOptions,
10063
10130
  Schema,
10064
10131
  ModelSelectionConfig,
@@ -10150,7 +10217,7 @@ declare namespace types {
10150
10217
  ReferenceImage,
10151
10218
  EditImageParameters,
10152
10219
  EmbedContentConfig,
10153
- EmbedContentParameters,
10220
+ EmbedContentParametersPrivate,
10154
10221
  ContentEmbeddingStatistics,
10155
10222
  ContentEmbedding,
10156
10223
  EmbedContentMetadata,
@@ -10418,6 +10485,7 @@ declare namespace types {
10418
10485
  CountTokensResult,
10419
10486
  ComputeTokensResult,
10420
10487
  CreateTuningJobParameters,
10488
+ EmbedContentParameters,
10421
10489
  UploadToFileSearchStoreResponse,
10422
10490
  UploadToFileSearchStoreOperation,
10423
10491
  BlobImageUnion,
@@ -805,6 +805,18 @@ var Environment;
805
805
  */
806
806
  Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
807
807
  })(Environment || (Environment = {}));
808
+ /** Enum representing the Vertex embedding API to use. */
809
+ var EmbeddingApiType;
810
+ (function (EmbeddingApiType) {
811
+ /**
812
+ * predict API endpoint (default)
813
+ */
814
+ EmbeddingApiType["PREDICT"] = "PREDICT";
815
+ /**
816
+ * embedContent API Endpoint
817
+ */
818
+ EmbeddingApiType["EMBED_CONTENT"] = "EMBED_CONTENT";
819
+ })(EmbeddingApiType || (EmbeddingApiType = {}));
808
820
  /** Enum that controls the safety filter level for objectionable content. */
809
821
  var SafetyFilterLevel;
810
822
  (function (SafetyFilterLevel) {
@@ -566,6 +566,15 @@ declare interface HttpOptions {
566
566
  - VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
567
567
  - GeminiAPI backend API docs: https://ai.google.dev/api/rest */
568
568
  extraBody?: Record<string, unknown>;
569
+ /** HTTP retry options for the request. */
570
+ retryOptions?: HttpRetryOptions;
571
+ }
572
+
573
+ /** HTTP retry options to be used in each of the requests. */
574
+ declare interface HttpRetryOptions {
575
+ /** Maximum number of attempts, including the original request.
576
+ If 0 or 1, it means no retries. If not specified, default to 5. */
577
+ attempts?: number;
569
578
  }
570
579
 
571
580
  /** Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time. */
@@ -781,6 +781,18 @@ var Environment;
781
781
  */
782
782
  Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
783
783
  })(Environment || (Environment = {}));
784
+ /** Enum representing the Vertex embedding API to use. */
785
+ var EmbeddingApiType;
786
+ (function (EmbeddingApiType) {
787
+ /**
788
+ * predict API endpoint (default)
789
+ */
790
+ EmbeddingApiType["PREDICT"] = "PREDICT";
791
+ /**
792
+ * embedContent API Endpoint
793
+ */
794
+ EmbeddingApiType["EMBED_CONTENT"] = "EMBED_CONTENT";
795
+ })(EmbeddingApiType || (EmbeddingApiType = {}));
784
796
  /** Enum that controls the safety filter level for objectionable content. */
785
797
  var SafetyFilterLevel;
786
798
  (function (SafetyFilterLevel) {