@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.
- package/dist/genai.d.ts +89 -21
- package/dist/index.cjs +263 -37
- package/dist/index.mjs +264 -38
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +262 -37
- package/dist/node/index.mjs +263 -38
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +89 -21
- package/dist/tokenizer/node.cjs +12 -0
- package/dist/tokenizer/node.d.ts +9 -0
- package/dist/tokenizer/node.mjs +12 -0
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/web/index.mjs +264 -38
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +89 -21
- package/package.json +3 -2
package/dist/genai.d.ts
CHANGED
|
@@ -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-
|
|
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
|
|
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<
|
|
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
|
|
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
|
|
3999
|
+
items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent>;
|
|
3966
4000
|
}
|
|
3967
4001
|
}
|
|
3968
4002
|
|
|
@@ -5429,6 +5463,8 @@ export declare interface HttpOptions {
|
|
|
5429
5463
|
- VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
|
|
5430
5464
|
- GeminiAPI backend API docs: https://ai.google.dev/api/rest */
|
|
5431
5465
|
extraBody?: Record<string, unknown>;
|
|
5466
|
+
/** HTTP retry options for the request. */
|
|
5467
|
+
retryOptions?: HttpRetryOptions;
|
|
5432
5468
|
}
|
|
5433
5469
|
|
|
5434
5470
|
/**
|
|
@@ -5492,6 +5528,13 @@ export declare class HttpResponse {
|
|
|
5492
5528
|
json(): Promise<unknown>;
|
|
5493
5529
|
}
|
|
5494
5530
|
|
|
5531
|
+
/** HTTP retry options to be used in each of the requests. */
|
|
5532
|
+
export declare interface HttpRetryOptions {
|
|
5533
|
+
/** Maximum number of attempts, including the original request.
|
|
5534
|
+
If 0 or 1, it means no retries. If not specified, default to 5. */
|
|
5535
|
+
attempts?: number;
|
|
5536
|
+
}
|
|
5537
|
+
|
|
5495
5538
|
/** An image. */
|
|
5496
5539
|
declare interface Image_2 {
|
|
5497
5540
|
/** The Cloud Storage URI of the image. ``Image`` can contain a value
|
|
@@ -5704,7 +5747,7 @@ declare interface Interaction {
|
|
|
5704
5747
|
/**
|
|
5705
5748
|
* Output only. The status of the interaction.
|
|
5706
5749
|
*/
|
|
5707
|
-
status: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled';
|
|
5750
|
+
status: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled' | 'incomplete';
|
|
5708
5751
|
/**
|
|
5709
5752
|
* The name of the `Agent` used for generating the interaction.
|
|
5710
5753
|
*/
|
|
@@ -5749,11 +5792,11 @@ declare interface InteractionCancelParams {
|
|
|
5749
5792
|
}
|
|
5750
5793
|
|
|
5751
5794
|
declare interface InteractionCompleteEvent {
|
|
5795
|
+
event_type: 'interaction.complete';
|
|
5752
5796
|
/**
|
|
5753
5797
|
* The event_id token to be used to resume the interaction stream, from this event.
|
|
5754
5798
|
*/
|
|
5755
5799
|
event_id?: string;
|
|
5756
|
-
event_type?: 'interaction.complete';
|
|
5757
5800
|
/**
|
|
5758
5801
|
* The Interaction resource.
|
|
5759
5802
|
*/
|
|
@@ -5895,11 +5938,11 @@ declare namespace InteractionsAPI {
|
|
|
5895
5938
|
declare type InteractionSSEEvent = InteractionStartEvent | InteractionCompleteEvent | InteractionStatusUpdate | ContentStart | ContentDelta | ContentStop | ErrorEvent_2;
|
|
5896
5939
|
|
|
5897
5940
|
declare interface InteractionStartEvent {
|
|
5941
|
+
event_type: 'interaction.start';
|
|
5898
5942
|
/**
|
|
5899
5943
|
* The event_id token to be used to resume the interaction stream, from this event.
|
|
5900
5944
|
*/
|
|
5901
5945
|
event_id?: string;
|
|
5902
|
-
event_type?: 'interaction.start';
|
|
5903
5946
|
/**
|
|
5904
5947
|
* The Interaction resource.
|
|
5905
5948
|
*/
|
|
@@ -5907,13 +5950,13 @@ declare interface InteractionStartEvent {
|
|
|
5907
5950
|
}
|
|
5908
5951
|
|
|
5909
5952
|
declare interface InteractionStatusUpdate {
|
|
5953
|
+
event_type: 'interaction.status_update';
|
|
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.status_update';
|
|
5915
5958
|
interaction_id?: string;
|
|
5916
|
-
status?: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled';
|
|
5959
|
+
status?: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled' | 'incomplete';
|
|
5917
5960
|
}
|
|
5918
5961
|
|
|
5919
5962
|
/** Parameters for the private _Register method. */
|
|
@@ -7133,7 +7176,7 @@ declare interface MCPServerToolResultContent {
|
|
|
7133
7176
|
|
|
7134
7177
|
declare namespace MCPServerToolResultContent {
|
|
7135
7178
|
interface Items {
|
|
7136
|
-
items?: Array<
|
|
7179
|
+
items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent>;
|
|
7137
7180
|
}
|
|
7138
7181
|
}
|
|
7139
7182
|
|
|
@@ -7291,7 +7334,7 @@ export declare interface Model {
|
|
|
7291
7334
|
/**
|
|
7292
7335
|
* The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.
|
|
7293
7336
|
*/
|
|
7294
|
-
declare type Model_2 = 'gemini-2.5-
|
|
7337
|
+
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 & {});
|
|
7295
7338
|
|
|
7296
7339
|
/** Configuration for Model Armor integrations of prompt and responses. This data type is not supported in Gemini API. */
|
|
7297
7340
|
export declare interface ModelArmorConfig {
|
|
@@ -7304,6 +7347,28 @@ export declare interface ModelArmorConfig {
|
|
|
7304
7347
|
export declare class Models extends BaseModule {
|
|
7305
7348
|
private readonly apiClient;
|
|
7306
7349
|
constructor(apiClient: ApiClient);
|
|
7350
|
+
/**
|
|
7351
|
+
* Calculates embeddings for the given contents.
|
|
7352
|
+
*
|
|
7353
|
+
* @param params - The parameters for embedding contents.
|
|
7354
|
+
* @return The response from the API.
|
|
7355
|
+
*
|
|
7356
|
+
* @example
|
|
7357
|
+
* ```ts
|
|
7358
|
+
* const response = await ai.models.embedContent({
|
|
7359
|
+
* model: 'text-embedding-004',
|
|
7360
|
+
* contents: [
|
|
7361
|
+
* 'What is your name?',
|
|
7362
|
+
* 'What is your favorite color?',
|
|
7363
|
+
* ],
|
|
7364
|
+
* config: {
|
|
7365
|
+
* outputDimensionality: 64,
|
|
7366
|
+
* },
|
|
7367
|
+
* });
|
|
7368
|
+
* console.log(response);
|
|
7369
|
+
* ```
|
|
7370
|
+
*/
|
|
7371
|
+
embedContent: (params: types.EmbedContentParameters) => Promise<types.EmbedContentResponse>;
|
|
7307
7372
|
/**
|
|
7308
7373
|
* Makes an API request to generate content with a given model.
|
|
7309
7374
|
*
|
|
@@ -7514,7 +7579,7 @@ export declare class Models extends BaseModule {
|
|
|
7514
7579
|
* console.log(response);
|
|
7515
7580
|
* ```
|
|
7516
7581
|
*/
|
|
7517
|
-
|
|
7582
|
+
private embedContentInternal;
|
|
7518
7583
|
/**
|
|
7519
7584
|
* Private method for generating images.
|
|
7520
7585
|
*/
|
|
@@ -10007,6 +10072,7 @@ declare namespace types {
|
|
|
10007
10072
|
ResourceScope,
|
|
10008
10073
|
FeatureSelectionPreference,
|
|
10009
10074
|
Environment,
|
|
10075
|
+
EmbeddingApiType,
|
|
10010
10076
|
SafetyFilterLevel,
|
|
10011
10077
|
PersonGeneration,
|
|
10012
10078
|
ImagePromptLanguage,
|
|
@@ -10047,6 +10113,7 @@ declare namespace types {
|
|
|
10047
10113
|
VideoMetadata,
|
|
10048
10114
|
Part,
|
|
10049
10115
|
Content,
|
|
10116
|
+
HttpRetryOptions,
|
|
10050
10117
|
HttpOptions,
|
|
10051
10118
|
Schema,
|
|
10052
10119
|
ModelSelectionConfig,
|
|
@@ -10138,7 +10205,7 @@ declare namespace types {
|
|
|
10138
10205
|
ReferenceImage,
|
|
10139
10206
|
EditImageParameters,
|
|
10140
10207
|
EmbedContentConfig,
|
|
10141
|
-
|
|
10208
|
+
EmbedContentParametersPrivate,
|
|
10142
10209
|
ContentEmbeddingStatistics,
|
|
10143
10210
|
ContentEmbedding,
|
|
10144
10211
|
EmbedContentMetadata,
|
|
@@ -10406,6 +10473,7 @@ declare namespace types {
|
|
|
10406
10473
|
CountTokensResult,
|
|
10407
10474
|
ComputeTokensResult,
|
|
10408
10475
|
CreateTuningJobParameters,
|
|
10476
|
+
EmbedContentParameters,
|
|
10409
10477
|
UploadToFileSearchStoreResponse,
|
|
10410
10478
|
UploadToFileSearchStoreOperation,
|
|
10411
10479
|
BlobImageUnion,
|