@google/genai 2.8.0 → 2.9.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.
@@ -157,7 +157,7 @@ declare interface ApiAuthApiKeyConfig {
157
157
  * WARNING: This is an internal API and may change without notice. Direct usage
158
158
  * is not supported and may break your application.
159
159
  */
160
- export declare class ApiClient implements GeminiNextGenAPIClientAdapter {
160
+ export declare class ApiClient {
161
161
  readonly clientOptions: ApiClientInitOptions;
162
162
  private readonly customBaseUrl?;
163
163
  constructor(opts: ApiClientInitOptions);
@@ -322,9 +322,14 @@ declare interface AudioChunk {
322
322
 
323
323
  /** The audio transcription configuration in Setup. */
324
324
  declare interface AudioTranscriptionConfig {
325
- /** The language codes of the audio. BCP-47 language code. If not set, the transcription will be in the language detected by the model. If set, the server will use the language code specified in the model config as a hint for the language of the audio
326
- */
325
+ /** Deprecated: use LanguageAuto or LanguageHints instead. */
327
326
  languageCodes?: string[];
327
+ /** The model will detect the language automatically. Do not use together with LanguageHints. */
328
+ languageAuto?: LanguageAuto;
329
+ /** Specifies one or more languages in the audio. Do not use together with LanguageAuto. */
330
+ languageHints?: LanguageHints;
331
+ /** A list of phrases used for speech adaptation, which biases the ASR model to improve recognition of these specific terms. */
332
+ adaptationPhrases?: string[];
328
333
  }
329
334
 
330
335
  /**
@@ -2181,7 +2186,7 @@ declare interface Endpoint {
2181
2186
  /** End of speech sensitivity. */
2182
2187
  declare enum EndSensitivity {
2183
2188
  /**
2184
- * The default is END_SENSITIVITY_LOW.
2189
+ * The default is END_SENSITIVITY_LOW for Gemini Enterprise Agent Platform and END_SENSITIVITY_HIGH for Gemini Live.
2185
2190
  */
2186
2191
  END_SENSITIVITY_UNSPECIFIED = "END_SENSITIVITY_UNSPECIFIED",
2187
2192
  /**
@@ -2675,18 +2680,6 @@ declare interface GcsSource {
2675
2680
  uris?: string[];
2676
2681
  }
2677
2682
 
2678
- /**
2679
- * @license
2680
- * Copyright 2025 Google LLC
2681
- * SPDX-License-Identifier: Apache-2.0
2682
- */
2683
- declare interface GeminiNextGenAPIClientAdapter {
2684
- isVertexAI: () => boolean;
2685
- getProject: () => string | undefined;
2686
- getLocation: () => string | undefined;
2687
- getAuthHeaders: () => Headers | Promise<Headers>;
2688
- }
2689
-
2690
2683
  /** Input example for preference optimization. This data type is not supported in Gemini API. */
2691
2684
  declare interface GeminiPreferenceExample {
2692
2685
  /** List of completions for a given prompt. */
@@ -4347,6 +4340,16 @@ declare enum Language {
4347
4340
  PYTHON = "PYTHON"
4348
4341
  }
4349
4342
 
4343
+ /** Indicates the language of the audio should be automatically detected. */
4344
+ declare interface LanguageAuto {
4345
+ }
4346
+
4347
+ /** Provides hints to the model about possible languages present in the audio. */
4348
+ declare interface LanguageHints {
4349
+ /** BCP-47 language codes. At least one must be specified. */
4350
+ languageCodes?: string[];
4351
+ }
4352
+
4350
4353
  /** An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges. */
4351
4354
  declare interface LatLng {
4352
4355
  /** The latitude in degrees. It must be in the range [-90.0, +90.0]. */
@@ -5096,6 +5099,8 @@ declare interface LiveServerContent {
5096
5099
  it is waiting for more input from the user, e.g. because it expects the
5097
5100
  user to continue talking. */
5098
5101
  waitingForInput?: boolean;
5102
+ /** Low latency transcription updated while the user is speaking. */
5103
+ interimInputTranscription?: Transcription;
5099
5104
  }
5100
5105
 
5101
5106
  /** Server will not be able to service client soon. */
@@ -5279,30 +5284,30 @@ declare interface McpServer {
5279
5284
  streamableHttpTransport?: StreamableHttpTransport;
5280
5285
  }
5281
5286
 
5282
- /** Server content modalities. */
5287
+ /** The modality that this token count applies to. */
5283
5288
  declare enum MediaModality {
5284
5289
  /**
5285
- * The modality is unspecified.
5290
+ * When a modality is not specified, it is treated as `TEXT`.
5286
5291
  */
5287
5292
  MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
5288
5293
  /**
5289
- * Plain text.
5294
+ * The `Part` contains plain text.
5290
5295
  */
5291
5296
  TEXT = "TEXT",
5292
5297
  /**
5293
- * Images.
5298
+ * The `Part` contains an image.
5294
5299
  */
5295
5300
  IMAGE = "IMAGE",
5296
5301
  /**
5297
- * Video.
5302
+ * The `Part` contains a video.
5298
5303
  */
5299
5304
  VIDEO = "VIDEO",
5300
5305
  /**
5301
- * Audio.
5306
+ * The `Part` contains audio.
5302
5307
  */
5303
5308
  AUDIO = "AUDIO",
5304
5309
  /**
5305
- * Document, e.g. PDF.
5310
+ * The `Part` contains a document, such as a PDF.
5306
5311
  */
5307
5312
  DOCUMENT = "DOCUMENT"
5308
5313
  }
@@ -5351,9 +5356,9 @@ declare enum Modality {
5351
5356
  VIDEO = "VIDEO"
5352
5357
  }
5353
5358
 
5354
- /** Represents token counting info for a single modality. */
5359
+ /** Represents a breakdown of token usage by modality. This message is used in CountTokensResponse and GenerateContentResponse.UsageMetadata to provide a detailed view of how many tokens are used by each modality (e.g., text, image, video) in a request. This is particularly useful for multimodal models, allowing you to track and manage token consumption for billing and quota purposes. */
5355
5360
  declare interface ModalityTokenCount {
5356
- /** The modality associated with this token count. */
5361
+ /** The modality that this token count applies to. */
5357
5362
  modality?: MediaModality;
5358
5363
  /** The number of tokens counted for this modality. */
5359
5364
  tokenCount?: number;
@@ -6762,7 +6767,7 @@ declare type SpeechConfigUnion = SpeechConfig | string;
6762
6767
  /** Start of speech sensitivity. */
6763
6768
  declare enum StartSensitivity {
6764
6769
  /**
6765
- * The default is START_SENSITIVITY_LOW.
6770
+ * The default is START_SENSITIVITY_LOW for Gemini Enterprise Agent Platform and START_SENSITIVITY_HIGH for Gemini Live.
6766
6771
  */
6767
6772
  START_SENSITIVITY_UNSPECIFIED = "START_SENSITIVITY_UNSPECIFIED",
6768
6773
  /**
@@ -7156,7 +7161,7 @@ declare enum TrafficType {
7156
7161
  PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT"
7157
7162
  }
7158
7163
 
7159
- /** Audio transcription in Server Conent. */
7164
+ /** Audio transcription in Server Content. */
7160
7165
  declare interface Transcription {
7161
7166
  /** Optional. Transcription text. */
7162
7167
  text?: string;
@@ -7657,9 +7662,10 @@ declare namespace types {
7657
7662
  UrlRetrievalStatus,
7658
7663
  BlockedReason,
7659
7664
  TrafficType,
7660
- Modality,
7665
+ MediaModality,
7661
7666
  ModelStage,
7662
7667
  MediaResolution,
7668
+ Modality,
7663
7669
  TuningMode,
7664
7670
  AdapterSize,
7665
7671
  JobState,
@@ -7670,10 +7676,10 @@ declare namespace types {
7670
7676
  TuningTask,
7671
7677
  VideoOrientation,
7672
7678
  DocumentState,
7679
+ ServiceTier,
7673
7680
  PartMediaResolutionLevel,
7674
7681
  ToolType,
7675
7682
  ResourceScope,
7676
- ServiceTier,
7677
7683
  FeatureSelectionPreference,
7678
7684
  EmbeddingApiType,
7679
7685
  SafetyFilterLevel,
@@ -7694,7 +7700,6 @@ declare namespace types {
7694
7700
  FileState,
7695
7701
  FileSource,
7696
7702
  TurnCompleteReason,
7697
- MediaModality,
7698
7703
  VadSignalType,
7699
7704
  VoiceActivityType,
7700
7705
  StartSensitivity,
@@ -8093,6 +8098,8 @@ declare namespace types {
8093
8098
  SessionResumptionConfig,
8094
8099
  SlidingWindow,
8095
8100
  ContextWindowCompressionConfig,
8101
+ LanguageAuto,
8102
+ LanguageHints,
8096
8103
  AudioTranscriptionConfig,
8097
8104
  ProactivityConfig,
8098
8105
  CustomizedAvatar,
@@ -8447,29 +8454,30 @@ declare enum UrlRetrievalStatus {
8447
8454
 
8448
8455
  /** Usage metadata about response(s). */
8449
8456
  declare interface UsageMetadata {
8450
- /** Number of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content. */
8457
+ /** The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content. */
8451
8458
  promptTokenCount?: number;
8452
- /** Number of tokens in the cached part of the prompt (the cached content). */
8459
+ /** Output only. The number of tokens in the cached content that was used for this request. */
8453
8460
  cachedContentTokenCount?: number;
8454
8461
  /** Total number of tokens across all the generated response candidates. */
8455
8462
  responseTokenCount?: number;
8456
- /** Number of tokens present in tool-use prompt(s). */
8463
+ /** Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable. */
8457
8464
  toolUsePromptTokenCount?: number;
8458
- /** Number of tokens of thoughts for thinking models. */
8465
+ /** Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable. */
8459
8466
  thoughtsTokenCount?: number;
8460
- /** Total token count for prompt, response candidates, and tool-use prompts(if present). */
8467
+ /** The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`. */
8461
8468
  totalTokenCount?: number;
8462
- /** List of modalities that were processed in the request input. */
8469
+ /** Output only. A detailed breakdown of the token count for each modality in the prompt. */
8463
8470
  promptTokensDetails?: ModalityTokenCount[];
8464
- /** List of modalities that were processed in the cache input. */
8471
+ /** Output only. A detailed breakdown of the token count for each modality in the cached content. */
8465
8472
  cacheTokensDetails?: ModalityTokenCount[];
8466
8473
  /** List of modalities that were returned in the response. */
8467
8474
  responseTokensDetails?: ModalityTokenCount[];
8468
- /** List of modalities that were processed in the tool-use prompt. */
8475
+ /** Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input. */
8469
8476
  toolUsePromptTokensDetails?: ModalityTokenCount[];
8470
- /** Traffic type. This shows whether a request consumes Pay-As-You-Go
8471
- or Provisioned Throughput quota. */
8477
+ /** Output only. The traffic type for this request. This field is not supported in Gemini API. */
8472
8478
  trafficType?: TrafficType;
8479
+ /** Output only. Service tier of the request. This field is not supported in Vertex AI. */
8480
+ serviceTier?: ServiceTier;
8473
8481
  }
8474
8482
 
8475
8483
  /** The type of the VAD signal. */
@@ -8745,6 +8753,8 @@ declare enum VideoOrientation {
8745
8753
  declare interface VoiceActivity {
8746
8754
  /** The type of the voice activity signal. */
8747
8755
  voiceActivityType?: VoiceActivityType;
8756
+ /** The time voice activity detected in audio time, relative to the start of the audio stream. */
8757
+ audioOffset?: string;
8748
8758
  }
8749
8759
 
8750
8760
  declare interface VoiceActivityDetectionSignal {
@@ -944,30 +944,34 @@ var TrafficType;
944
944
  */
945
945
  TrafficType["PROVISIONED_THROUGHPUT"] = "PROVISIONED_THROUGHPUT";
946
946
  })(TrafficType || (TrafficType = {}));
947
- /** Server content modalities. */
948
- var Modality;
949
- (function (Modality) {
947
+ /** The modality that this token count applies to. */
948
+ var MediaModality;
949
+ (function (MediaModality) {
950
950
  /**
951
- * The modality is unspecified.
951
+ * When a modality is not specified, it is treated as `TEXT`.
952
952
  */
953
- Modality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
953
+ MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
954
954
  /**
955
- * Indicates the model should return text
955
+ * The `Part` contains plain text.
956
956
  */
957
- Modality["TEXT"] = "TEXT";
957
+ MediaModality["TEXT"] = "TEXT";
958
958
  /**
959
- * Indicates the model should return images.
959
+ * The `Part` contains an image.
960
960
  */
961
- Modality["IMAGE"] = "IMAGE";
961
+ MediaModality["IMAGE"] = "IMAGE";
962
962
  /**
963
- * Indicates the model should return audio.
963
+ * The `Part` contains a video.
964
964
  */
965
- Modality["AUDIO"] = "AUDIO";
965
+ MediaModality["VIDEO"] = "VIDEO";
966
966
  /**
967
- * Indicates the model should return video.
967
+ * The `Part` contains audio.
968
968
  */
969
- Modality["VIDEO"] = "VIDEO";
970
- })(Modality || (Modality = {}));
969
+ MediaModality["AUDIO"] = "AUDIO";
970
+ /**
971
+ * The `Part` contains a document, such as a PDF.
972
+ */
973
+ MediaModality["DOCUMENT"] = "DOCUMENT";
974
+ })(MediaModality || (MediaModality = {}));
971
975
  /** The stage of the underlying model. This enum is not supported in Vertex AI. */
972
976
  var ModelStage;
973
977
  (function (ModelStage) {
@@ -1024,6 +1028,30 @@ var MediaResolution;
1024
1028
  */
1025
1029
  MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
1026
1030
  })(MediaResolution || (MediaResolution = {}));
1031
+ /** Server content modalities. */
1032
+ var Modality;
1033
+ (function (Modality) {
1034
+ /**
1035
+ * The modality is unspecified.
1036
+ */
1037
+ Modality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
1038
+ /**
1039
+ * Indicates the model should return text
1040
+ */
1041
+ Modality["TEXT"] = "TEXT";
1042
+ /**
1043
+ * Indicates the model should return images.
1044
+ */
1045
+ Modality["IMAGE"] = "IMAGE";
1046
+ /**
1047
+ * Indicates the model should return audio.
1048
+ */
1049
+ Modality["AUDIO"] = "AUDIO";
1050
+ /**
1051
+ * Indicates the model should return video.
1052
+ */
1053
+ Modality["VIDEO"] = "VIDEO";
1054
+ })(Modality || (Modality = {}));
1027
1055
  /** Tuning mode. This enum is not supported in Gemini API. */
1028
1056
  var TuningMode;
1029
1057
  (function (TuningMode) {
@@ -1292,6 +1320,26 @@ var DocumentState;
1292
1320
  */
1293
1321
  DocumentState["STATE_FAILED"] = "STATE_FAILED";
1294
1322
  })(DocumentState || (DocumentState = {}));
1323
+ /** Pricing and performance service tier. */
1324
+ var ServiceTier;
1325
+ (function (ServiceTier) {
1326
+ /**
1327
+ * Default service tier, which is standard.
1328
+ */
1329
+ ServiceTier["UNSPECIFIED"] = "unspecified";
1330
+ /**
1331
+ * Flex service tier.
1332
+ */
1333
+ ServiceTier["FLEX"] = "flex";
1334
+ /**
1335
+ * Standard service tier.
1336
+ */
1337
+ ServiceTier["STANDARD"] = "standard";
1338
+ /**
1339
+ * Priority service tier.
1340
+ */
1341
+ ServiceTier["PRIORITY"] = "priority";
1342
+ })(ServiceTier || (ServiceTier = {}));
1295
1343
  /** The tokenization quality used for given media. */
1296
1344
  var PartMediaResolutionLevel;
1297
1345
  (function (PartMediaResolutionLevel) {
@@ -1356,26 +1404,6 @@ var ResourceScope;
1356
1404
  */
1357
1405
  ResourceScope["COLLECTION"] = "COLLECTION";
1358
1406
  })(ResourceScope || (ResourceScope = {}));
1359
- /** Pricing and performance service tier. */
1360
- var ServiceTier;
1361
- (function (ServiceTier) {
1362
- /**
1363
- * Default service tier, which is standard.
1364
- */
1365
- ServiceTier["UNSPECIFIED"] = "unspecified";
1366
- /**
1367
- * Flex service tier.
1368
- */
1369
- ServiceTier["FLEX"] = "flex";
1370
- /**
1371
- * Standard service tier.
1372
- */
1373
- ServiceTier["STANDARD"] = "standard";
1374
- /**
1375
- * Priority service tier.
1376
- */
1377
- ServiceTier["PRIORITY"] = "priority";
1378
- })(ServiceTier || (ServiceTier = {}));
1379
1407
  /** Options for feature selection preference. */
1380
1408
  var FeatureSelectionPreference;
1381
1409
  (function (FeatureSelectionPreference) {
@@ -1760,34 +1788,6 @@ var TurnCompleteReason;
1760
1788
  */
1761
1789
  TurnCompleteReason["MAX_REGENERATION_REACHED"] = "MAX_REGENERATION_REACHED";
1762
1790
  })(TurnCompleteReason || (TurnCompleteReason = {}));
1763
- /** Server content modalities. */
1764
- var MediaModality;
1765
- (function (MediaModality) {
1766
- /**
1767
- * The modality is unspecified.
1768
- */
1769
- MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
1770
- /**
1771
- * Plain text.
1772
- */
1773
- MediaModality["TEXT"] = "TEXT";
1774
- /**
1775
- * Images.
1776
- */
1777
- MediaModality["IMAGE"] = "IMAGE";
1778
- /**
1779
- * Video.
1780
- */
1781
- MediaModality["VIDEO"] = "VIDEO";
1782
- /**
1783
- * Audio.
1784
- */
1785
- MediaModality["AUDIO"] = "AUDIO";
1786
- /**
1787
- * Document, e.g. PDF.
1788
- */
1789
- MediaModality["DOCUMENT"] = "DOCUMENT";
1790
- })(MediaModality || (MediaModality = {}));
1791
1791
  /** The type of the VAD signal. */
1792
1792
  var VadSignalType;
1793
1793
  (function (VadSignalType) {
@@ -1824,7 +1824,7 @@ var VoiceActivityType;
1824
1824
  var StartSensitivity;
1825
1825
  (function (StartSensitivity) {
1826
1826
  /**
1827
- * The default is START_SENSITIVITY_LOW.
1827
+ * The default is START_SENSITIVITY_LOW for Gemini Enterprise Agent Platform and START_SENSITIVITY_HIGH for Gemini Live.
1828
1828
  */
1829
1829
  StartSensitivity["START_SENSITIVITY_UNSPECIFIED"] = "START_SENSITIVITY_UNSPECIFIED";
1830
1830
  /**
@@ -1840,7 +1840,7 @@ var StartSensitivity;
1840
1840
  var EndSensitivity;
1841
1841
  (function (EndSensitivity) {
1842
1842
  /**
1843
- * The default is END_SENSITIVITY_LOW.
1843
+ * The default is END_SENSITIVITY_LOW for Gemini Enterprise Agent Platform and END_SENSITIVITY_HIGH for Gemini Live.
1844
1844
  */
1845
1845
  EndSensitivity["END_SENSITIVITY_UNSPECIFIED"] = "END_SENSITIVITY_UNSPECIFIED";
1846
1846
  /**
@@ -2146,7 +2146,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
2146
2146
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
2147
2147
  const USER_AGENT_HEADER = 'User-Agent';
2148
2148
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
2149
- const SDK_VERSION = '2.8.0'; // x-release-please-version
2149
+ const SDK_VERSION = '2.9.0'; // x-release-please-version
2150
2150
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
2151
2151
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
2152
2152
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';