@google/genai 0.9.0 → 0.10.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.
@@ -164,6 +164,14 @@ export declare interface AutomaticActivityDetection {
164
164
  declare class BaseModule {
165
165
  }
166
166
 
167
+ /**
168
+ * Parameters for setting the base URLs for the Gemini API and Vertex AI API.
169
+ */
170
+ export declare interface BaseUrlParameters {
171
+ geminiUrl?: string;
172
+ vertexUrl?: string;
173
+ }
174
+
167
175
  /** Content blob. */
168
176
  declare interface Blob_2 {
169
177
  /** Required. Raw bytes. */
@@ -173,6 +181,8 @@ declare interface Blob_2 {
173
181
  }
174
182
  export { Blob_2 as Blob }
175
183
 
184
+ export declare type BlobImageUnion = Blob_2;
185
+
176
186
  /** Output only. Blocked reason. */
177
187
  export declare enum BlockedReason {
178
188
  BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED",
@@ -487,6 +497,13 @@ export declare interface CodeExecutionResult {
487
497
  export declare interface ComputeTokensConfig {
488
498
  /** Used to override HTTP request options. */
489
499
  httpOptions?: HttpOptions;
500
+ /** Abort signal which can be used to cancel the request.
501
+
502
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
503
+ operation will not cancel the request in the service. You will still
504
+ be charged usage for any applicable operations.
505
+ */
506
+ abortSignal?: AbortSignal;
490
507
  }
491
508
 
492
509
  /** Parameters for computing tokens. */
@@ -595,6 +612,13 @@ export declare enum ControlReferenceType {
595
612
  export declare interface CountTokensConfig {
596
613
  /** Used to override HTTP request options. */
597
614
  httpOptions?: HttpOptions;
615
+ /** Abort signal which can be used to cancel the request.
616
+
617
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
618
+ operation will not cancel the request in the service. You will still
619
+ be charged usage for any applicable operations.
620
+ */
621
+ abortSignal?: AbortSignal;
598
622
  /** Instructions for the model to steer it toward better performance.
599
623
  */
600
624
  systemInstruction?: ContentUnion;
@@ -631,6 +655,13 @@ export declare class CountTokensResponse {
631
655
  export declare interface CreateCachedContentConfig {
632
656
  /** Used to override HTTP request options. */
633
657
  httpOptions?: HttpOptions;
658
+ /** Abort signal which can be used to cancel the request.
659
+
660
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
661
+ operation will not cancel the request in the service. You will still
662
+ be charged usage for any applicable operations.
663
+ */
664
+ abortSignal?: AbortSignal;
634
665
  /** The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s". */
635
666
  ttl?: string;
636
667
  /** Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z. */
@@ -692,6 +723,13 @@ export declare interface CreateChatParameters {
692
723
  export declare interface CreateFileConfig {
693
724
  /** Used to override HTTP request options. */
694
725
  httpOptions?: HttpOptions;
726
+ /** Abort signal which can be used to cancel the request.
727
+
728
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
729
+ operation will not cancel the request in the service. You will still
730
+ be charged usage for any applicable operations.
731
+ */
732
+ abortSignal?: AbortSignal;
695
733
  }
696
734
 
697
735
  /** Generates the parameters for the private _create method. */
@@ -762,6 +800,13 @@ export declare function createUserContent(partOrString: PartListUnion | string):
762
800
  export declare interface DeleteCachedContentConfig {
763
801
  /** Used to override HTTP request options. */
764
802
  httpOptions?: HttpOptions;
803
+ /** Abort signal which can be used to cancel the request.
804
+
805
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
806
+ operation will not cancel the request in the service. You will still
807
+ be charged usage for any applicable operations.
808
+ */
809
+ abortSignal?: AbortSignal;
765
810
  }
766
811
 
767
812
  /** Parameters for caches.delete method. */
@@ -782,6 +827,13 @@ export declare class DeleteCachedContentResponse {
782
827
  export declare interface DeleteFileConfig {
783
828
  /** Used to override HTTP request options. */
784
829
  httpOptions?: HttpOptions;
830
+ /** Abort signal which can be used to cancel the request.
831
+
832
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
833
+ operation will not cancel the request in the service. You will still
834
+ be charged usage for any applicable operations.
835
+ */
836
+ abortSignal?: AbortSignal;
785
837
  }
786
838
 
787
839
  /** Generates the parameters for the get method. */
@@ -800,6 +852,13 @@ export declare class DeleteFileResponse {
800
852
  export declare interface DownloadFileConfig {
801
853
  /** Used to override HTTP request options. */
802
854
  httpOptions?: HttpOptions;
855
+ /** Abort signal which can be used to cancel the request.
856
+
857
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
858
+ operation will not cancel the request in the service. You will still
859
+ be charged usage for any applicable operations.
860
+ */
861
+ abortSignal?: AbortSignal;
803
862
  }
804
863
 
805
864
  /** Describes the options to customize dynamic retrieval. */
@@ -819,6 +878,13 @@ export declare enum DynamicRetrievalConfigMode {
819
878
  export declare interface EmbedContentConfig {
820
879
  /** Used to override HTTP request options. */
821
880
  httpOptions?: HttpOptions;
881
+ /** Abort signal which can be used to cancel the request.
882
+
883
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
884
+ operation will not cancel the request in the service. You will still
885
+ be charged usage for any applicable operations.
886
+ */
887
+ abortSignal?: AbortSignal;
822
888
  /** Type of task for which the embedding will be used.
823
889
  */
824
890
  taskType?: string;
@@ -908,6 +974,13 @@ export declare enum FeatureSelectionPreference {
908
974
  export declare interface FetchPredictOperationConfig {
909
975
  /** Used to override HTTP request options. */
910
976
  httpOptions?: HttpOptions;
977
+ /** Abort signal which can be used to cancel the request.
978
+
979
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
980
+ operation will not cancel the request in the service. You will still
981
+ be charged usage for any applicable operations.
982
+ */
983
+ abortSignal?: AbortSignal;
911
984
  }
912
985
 
913
986
  /** Parameters for the fetchPredictOperation method. */
@@ -1111,6 +1184,7 @@ export declare enum FinishReason {
1111
1184
  MAX_TOKENS = "MAX_TOKENS",
1112
1185
  SAFETY = "SAFETY",
1113
1186
  RECITATION = "RECITATION",
1187
+ LANGUAGE = "LANGUAGE",
1114
1188
  OTHER = "OTHER",
1115
1189
  BLOCKLIST = "BLOCKLIST",
1116
1190
  PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
@@ -1182,6 +1256,13 @@ export declare class FunctionResponse {
1182
1256
  export declare interface GenerateContentConfig {
1183
1257
  /** Used to override HTTP request options. */
1184
1258
  httpOptions?: HttpOptions;
1259
+ /** Abort signal which can be used to cancel the request.
1260
+
1261
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1262
+ operation will not cancel the request in the service. You will still
1263
+ be charged usage for any applicable operations.
1264
+ */
1265
+ abortSignal?: AbortSignal;
1185
1266
  /** Instructions for the model to steer it toward better performance.
1186
1267
  For example, "Answer as concisely as possible" or "Don't use technical
1187
1268
  terms in your response".
@@ -1339,6 +1420,17 @@ export declare class GenerateContentResponse {
1339
1420
  * ```
1340
1421
  */
1341
1422
  get text(): string | undefined;
1423
+ /**
1424
+ * Returns the concatenation of all inline data parts from the first candidate
1425
+ * in the response.
1426
+ *
1427
+ * @remarks
1428
+ * If there are multiple candidates in the response, the inline data from the
1429
+ * first one will be returned. If there are non-inline data parts in the
1430
+ * response, the concatenation of all inline data parts will be returned, and
1431
+ * a warning will be logged.
1432
+ */
1433
+ get data(): string | undefined;
1342
1434
  /**
1343
1435
  * Returns the function calls from the first candidate in the response.
1344
1436
  *
@@ -1499,6 +1591,13 @@ export declare interface GeneratedVideo {
1499
1591
  export declare interface GenerateImagesConfig {
1500
1592
  /** Used to override HTTP request options. */
1501
1593
  httpOptions?: HttpOptions;
1594
+ /** Abort signal which can be used to cancel the request.
1595
+
1596
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1597
+ operation will not cancel the request in the service. You will still
1598
+ be charged usage for any applicable operations.
1599
+ */
1600
+ abortSignal?: AbortSignal;
1502
1601
  /** Cloud Storage URI used to store the generated images.
1503
1602
  */
1504
1603
  outputGcsUri?: string;
@@ -1580,6 +1679,13 @@ export declare class GenerateImagesResponse {
1580
1679
  export declare interface GenerateVideosConfig {
1581
1680
  /** Used to override HTTP request options. */
1582
1681
  httpOptions?: HttpOptions;
1682
+ /** Abort signal which can be used to cancel the request.
1683
+
1684
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1685
+ operation will not cancel the request in the service. You will still
1686
+ be charged usage for any applicable operations.
1687
+ */
1688
+ abortSignal?: AbortSignal;
1583
1689
  /** Number of output videos. */
1584
1690
  numberOfVideos?: number;
1585
1691
  /** The gcs bucket where to save the generated videos. */
@@ -1702,6 +1808,13 @@ export declare interface GenerationConfigRoutingConfigManualRoutingMode {
1702
1808
  export declare interface GetCachedContentConfig {
1703
1809
  /** Used to override HTTP request options. */
1704
1810
  httpOptions?: HttpOptions;
1811
+ /** Abort signal which can be used to cancel the request.
1812
+
1813
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1814
+ operation will not cancel the request in the service. You will still
1815
+ be charged usage for any applicable operations.
1816
+ */
1817
+ abortSignal?: AbortSignal;
1705
1818
  }
1706
1819
 
1707
1820
  /** Parameters for caches.get method. */
@@ -1718,6 +1831,13 @@ export declare interface GetCachedContentParameters {
1718
1831
  export declare interface GetFileConfig {
1719
1832
  /** Used to override HTTP request options. */
1720
1833
  httpOptions?: HttpOptions;
1834
+ /** Abort signal which can be used to cancel the request.
1835
+
1836
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1837
+ operation will not cancel the request in the service. You will still
1838
+ be charged usage for any applicable operations.
1839
+ */
1840
+ abortSignal?: AbortSignal;
1721
1841
  }
1722
1842
 
1723
1843
  /** Generates the parameters for the get method. */
@@ -1732,6 +1852,13 @@ export declare interface GetFileParameters {
1732
1852
  export declare interface GetModelConfig {
1733
1853
  /** Used to override HTTP request options. */
1734
1854
  httpOptions?: HttpOptions;
1855
+ /** Abort signal which can be used to cancel the request.
1856
+
1857
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1858
+ operation will not cancel the request in the service. You will still
1859
+ be charged usage for any applicable operations.
1860
+ */
1861
+ abortSignal?: AbortSignal;
1735
1862
  }
1736
1863
 
1737
1864
  export declare interface GetModelParameters {
@@ -1743,6 +1870,13 @@ export declare interface GetModelParameters {
1743
1870
  export declare interface GetOperationConfig {
1744
1871
  /** Used to override HTTP request options. */
1745
1872
  httpOptions?: HttpOptions;
1873
+ /** Abort signal which can be used to cancel the request.
1874
+
1875
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1876
+ operation will not cancel the request in the service. You will still
1877
+ be charged usage for any applicable operations.
1878
+ */
1879
+ abortSignal?: AbortSignal;
1746
1880
  }
1747
1881
 
1748
1882
  /** Parameters for the GET method. */
@@ -2045,6 +2179,10 @@ declare interface HttpRequest {
2045
2179
  * Optional set of customizable configuration for HTTP requests.
2046
2180
  */
2047
2181
  httpOptions?: HttpOptions;
2182
+ /**
2183
+ * Optional abort signal which can be used to cancel the request.
2184
+ */
2185
+ abortSignal?: AbortSignal;
2048
2186
  }
2049
2187
 
2050
2188
  /** A wrapper class for the http response. */
@@ -2093,6 +2231,13 @@ export declare enum Language {
2093
2231
  export declare interface ListCachedContentsConfig {
2094
2232
  /** Used to override HTTP request options. */
2095
2233
  httpOptions?: HttpOptions;
2234
+ /** Abort signal which can be used to cancel the request.
2235
+
2236
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
2237
+ operation will not cancel the request in the service. You will still
2238
+ be charged usage for any applicable operations.
2239
+ */
2240
+ abortSignal?: AbortSignal;
2096
2241
  pageSize?: number;
2097
2242
  pageToken?: string;
2098
2243
  }
@@ -2115,6 +2260,13 @@ export declare class ListCachedContentsResponse {
2115
2260
  export declare interface ListFilesConfig {
2116
2261
  /** Used to override HTTP request options. */
2117
2262
  httpOptions?: HttpOptions;
2263
+ /** Abort signal which can be used to cancel the request.
2264
+
2265
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
2266
+ operation will not cancel the request in the service. You will still
2267
+ be charged usage for any applicable operations.
2268
+ */
2269
+ abortSignal?: AbortSignal;
2118
2270
  pageSize?: number;
2119
2271
  pageToken?: string;
2120
2272
  }
@@ -2259,6 +2411,22 @@ export declare interface LiveClientMessage {
2259
2411
  export declare interface LiveClientRealtimeInput {
2260
2412
  /** Inlined bytes data for media input. */
2261
2413
  mediaChunks?: Blob_2[];
2414
+ /** The realtime audio input stream. */
2415
+ audio?: Blob_2;
2416
+ /**
2417
+ Indicates that the audio stream has ended, e.g. because the microphone was
2418
+ turned off.
2419
+
2420
+ This should only be sent when automatic activity detection is enabled
2421
+ (which is the default).
2422
+
2423
+ The client can reopen the stream by sending an audio message.
2424
+ */
2425
+ audioStreamEnd?: boolean;
2426
+ /** The realtime video input stream. */
2427
+ video?: Blob_2;
2428
+ /** The realtime text input stream. */
2429
+ text?: string;
2262
2430
  /** Marks the start of user activity. */
2263
2431
  activityStart?: ActivityStart;
2264
2432
  /** Marks the end of user activity. */
@@ -2414,7 +2582,23 @@ export declare interface LiveSendClientContentParameters {
2414
2582
  /** Parameters for sending realtime input to the live API. */
2415
2583
  export declare interface LiveSendRealtimeInputParameters {
2416
2584
  /** Realtime input to send to the session. */
2417
- media: Blob_2;
2585
+ media?: BlobImageUnion;
2586
+ /** The realtime audio input stream. */
2587
+ audio?: Blob_2;
2588
+ /**
2589
+ Indicates that the audio stream has ended, e.g. because the microphone was
2590
+ turned off.
2591
+
2592
+ This should only be sent when automatic activity detection is enabled
2593
+ (which is the default).
2594
+
2595
+ The client can reopen the stream by sending an audio message.
2596
+ */
2597
+ audioStreamEnd?: boolean;
2598
+ /** The realtime video input stream. */
2599
+ video?: BlobImageUnion;
2600
+ /** The realtime text input stream. */
2601
+ text?: string;
2418
2602
  /** Marks the start of user activity. */
2419
2603
  activityStart?: ActivityStart;
2420
2604
  /** Marks the end of user activity. */
@@ -3363,7 +3547,6 @@ export declare class Session {
3363
3547
  private readonly apiClient;
3364
3548
  constructor(conn: WebSocket_2, apiClient: ApiClient);
3365
3549
  private tLiveClientContent;
3366
- private tLiveClientRealtimeInput;
3367
3550
  private tLiveClienttToolResponse;
3368
3551
  /**
3369
3552
  Send a message over the established connection.
@@ -3493,6 +3676,28 @@ export declare interface SessionResumptionConfig {
3493
3676
  transparent?: boolean;
3494
3677
  }
3495
3678
 
3679
+ /**
3680
+ * Overrides the base URLs for the Gemini API and Vertex AI API.
3681
+ *
3682
+ * @remarks This function should be called before initializing the SDK. If the
3683
+ * base URLs are set after initializing the SDK, the base URLs will not be
3684
+ * updated. Base URLs provided in the HttpOptions will also take precedence over
3685
+ * URLs set here.
3686
+ *
3687
+ * @example
3688
+ * ```ts
3689
+ * import {GoogleGenAI, setDefaultBaseUrls} from '@google/genai';
3690
+ * // Override the base URL for the Gemini API.
3691
+ * setDefaultBaseUrls({geminiUrl:'https://gemini.google.com'});
3692
+ *
3693
+ * // Override the base URL for the Vertex AI API.
3694
+ * setDefaultBaseUrls({vertexUrl: 'https://vertexai.googleapis.com'});
3695
+ *
3696
+ * const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
3697
+ * ```
3698
+ */
3699
+ export declare function setDefaultBaseUrls(baseUrlParams: BaseUrlParameters): void;
3700
+
3496
3701
  /** Context window will be truncated by keeping only suffix of it.
3497
3702
 
3498
3703
  Context window will always be cut at start of USER role turn. System
@@ -3921,6 +4126,7 @@ declare namespace types {
3921
4126
  LiveSendRealtimeInputParameters,
3922
4127
  LiveSendToolResponseParameters,
3923
4128
  OperationGetParameters,
4129
+ BlobImageUnion,
3924
4130
  PartUnion,
3925
4131
  PartListUnion,
3926
4132
  ContentUnion,
@@ -3935,6 +4141,13 @@ declare namespace types {
3935
4141
  export declare interface UpdateCachedContentConfig {
3936
4142
  /** Used to override HTTP request options. */
3937
4143
  httpOptions?: HttpOptions;
4144
+ /** Abort signal which can be used to cancel the request.
4145
+
4146
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
4147
+ operation will not cancel the request in the service. You will still
4148
+ be charged usage for any applicable operations.
4149
+ */
4150
+ abortSignal?: AbortSignal;
3938
4151
  /** The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s". */
3939
4152
  ttl?: string;
3940
4153
  /** Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z. */
@@ -3977,6 +4190,13 @@ declare interface Uploader {
3977
4190
  export declare interface UploadFileConfig {
3978
4191
  /** Used to override HTTP request options. */
3979
4192
  httpOptions?: HttpOptions;
4193
+ /** Abort signal which can be used to cancel the request.
4194
+
4195
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
4196
+ operation will not cancel the request in the service. You will still
4197
+ be charged usage for any applicable operations.
4198
+ */
4199
+ abortSignal?: AbortSignal;
3980
4200
  /** The name of the file in the destination (e.g., 'files/sample-image'. If not provided one will be generated. */
3981
4201
  name?: string;
3982
4202
  /** mime_type: The MIME type of the file. If not provided, it will be inferred from the file extension. */
@@ -4002,6 +4222,13 @@ export declare interface UploadFileParameters {
4002
4222
  export declare interface UpscaleImageConfig {
4003
4223
  /** Used to override HTTP request options. */
4004
4224
  httpOptions?: HttpOptions;
4225
+ /** Abort signal which can be used to cancel the request.
4226
+
4227
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
4228
+ operation will not cancel the request in the service. You will still
4229
+ be charged usage for any applicable operations.
4230
+ */
4231
+ abortSignal?: AbortSignal;
4005
4232
  /** Whether to include a reason for filtered-out images in the
4006
4233
  response. */
4007
4234
  includeRaiReason?: boolean;