@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/web/web.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
|
|
|
@@ -5434,6 +5468,8 @@ export declare interface HttpOptions {
|
|
|
5434
5468
|
- VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
|
|
5435
5469
|
- GeminiAPI backend API docs: https://ai.google.dev/api/rest */
|
|
5436
5470
|
extraBody?: Record<string, unknown>;
|
|
5471
|
+
/** HTTP retry options for the request. */
|
|
5472
|
+
retryOptions?: HttpRetryOptions;
|
|
5437
5473
|
}
|
|
5438
5474
|
|
|
5439
5475
|
/**
|
|
@@ -5497,6 +5533,13 @@ export declare class HttpResponse {
|
|
|
5497
5533
|
json(): Promise<unknown>;
|
|
5498
5534
|
}
|
|
5499
5535
|
|
|
5536
|
+
/** HTTP retry options to be used in each of the requests. */
|
|
5537
|
+
export declare interface HttpRetryOptions {
|
|
5538
|
+
/** Maximum number of attempts, including the original request.
|
|
5539
|
+
If 0 or 1, it means no retries. If not specified, default to 5. */
|
|
5540
|
+
attempts?: number;
|
|
5541
|
+
}
|
|
5542
|
+
|
|
5500
5543
|
/** An image. */
|
|
5501
5544
|
declare interface Image_2 {
|
|
5502
5545
|
/** The Cloud Storage URI of the image. ``Image`` can contain a value
|
|
@@ -5709,7 +5752,7 @@ declare interface Interaction {
|
|
|
5709
5752
|
/**
|
|
5710
5753
|
* Output only. The status of the interaction.
|
|
5711
5754
|
*/
|
|
5712
|
-
status: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled';
|
|
5755
|
+
status: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled' | 'incomplete';
|
|
5713
5756
|
/**
|
|
5714
5757
|
* The name of the `Agent` used for generating the interaction.
|
|
5715
5758
|
*/
|
|
@@ -5754,11 +5797,11 @@ declare interface InteractionCancelParams {
|
|
|
5754
5797
|
}
|
|
5755
5798
|
|
|
5756
5799
|
declare interface InteractionCompleteEvent {
|
|
5800
|
+
event_type: 'interaction.complete';
|
|
5757
5801
|
/**
|
|
5758
5802
|
* The event_id token to be used to resume the interaction stream, from this event.
|
|
5759
5803
|
*/
|
|
5760
5804
|
event_id?: string;
|
|
5761
|
-
event_type?: 'interaction.complete';
|
|
5762
5805
|
/**
|
|
5763
5806
|
* The Interaction resource.
|
|
5764
5807
|
*/
|
|
@@ -5900,11 +5943,11 @@ declare namespace InteractionsAPI {
|
|
|
5900
5943
|
declare type InteractionSSEEvent = InteractionStartEvent | InteractionCompleteEvent | InteractionStatusUpdate | ContentStart | ContentDelta | ContentStop | ErrorEvent_2;
|
|
5901
5944
|
|
|
5902
5945
|
declare interface InteractionStartEvent {
|
|
5946
|
+
event_type: 'interaction.start';
|
|
5903
5947
|
/**
|
|
5904
5948
|
* The event_id token to be used to resume the interaction stream, from this event.
|
|
5905
5949
|
*/
|
|
5906
5950
|
event_id?: string;
|
|
5907
|
-
event_type?: 'interaction.start';
|
|
5908
5951
|
/**
|
|
5909
5952
|
* The Interaction resource.
|
|
5910
5953
|
*/
|
|
@@ -5912,13 +5955,13 @@ declare interface InteractionStartEvent {
|
|
|
5912
5955
|
}
|
|
5913
5956
|
|
|
5914
5957
|
declare interface InteractionStatusUpdate {
|
|
5958
|
+
event_type: 'interaction.status_update';
|
|
5915
5959
|
/**
|
|
5916
5960
|
* The event_id token to be used to resume the interaction stream, from this event.
|
|
5917
5961
|
*/
|
|
5918
5962
|
event_id?: string;
|
|
5919
|
-
event_type?: 'interaction.status_update';
|
|
5920
5963
|
interaction_id?: string;
|
|
5921
|
-
status?: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled';
|
|
5964
|
+
status?: 'in_progress' | 'requires_action' | 'completed' | 'failed' | 'cancelled' | 'incomplete';
|
|
5922
5965
|
}
|
|
5923
5966
|
|
|
5924
5967
|
/** Parameters for the private _Register method. */
|
|
@@ -7138,7 +7181,7 @@ declare interface MCPServerToolResultContent {
|
|
|
7138
7181
|
|
|
7139
7182
|
declare namespace MCPServerToolResultContent {
|
|
7140
7183
|
interface Items {
|
|
7141
|
-
items?: Array<
|
|
7184
|
+
items?: Array<InteractionsAPI.TextContent | InteractionsAPI.ImageContent>;
|
|
7142
7185
|
}
|
|
7143
7186
|
}
|
|
7144
7187
|
|
|
@@ -7296,7 +7339,7 @@ export declare interface Model {
|
|
|
7296
7339
|
/**
|
|
7297
7340
|
* The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.
|
|
7298
7341
|
*/
|
|
7299
|
-
declare type Model_2 = 'gemini-2.5-
|
|
7342
|
+
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 & {});
|
|
7300
7343
|
|
|
7301
7344
|
/** Configuration for Model Armor integrations of prompt and responses. This data type is not supported in Gemini API. */
|
|
7302
7345
|
export declare interface ModelArmorConfig {
|
|
@@ -7309,6 +7352,28 @@ export declare interface ModelArmorConfig {
|
|
|
7309
7352
|
export declare class Models extends BaseModule {
|
|
7310
7353
|
private readonly apiClient;
|
|
7311
7354
|
constructor(apiClient: ApiClient);
|
|
7355
|
+
/**
|
|
7356
|
+
* Calculates embeddings for the given contents.
|
|
7357
|
+
*
|
|
7358
|
+
* @param params - The parameters for embedding contents.
|
|
7359
|
+
* @return The response from the API.
|
|
7360
|
+
*
|
|
7361
|
+
* @example
|
|
7362
|
+
* ```ts
|
|
7363
|
+
* const response = await ai.models.embedContent({
|
|
7364
|
+
* model: 'text-embedding-004',
|
|
7365
|
+
* contents: [
|
|
7366
|
+
* 'What is your name?',
|
|
7367
|
+
* 'What is your favorite color?',
|
|
7368
|
+
* ],
|
|
7369
|
+
* config: {
|
|
7370
|
+
* outputDimensionality: 64,
|
|
7371
|
+
* },
|
|
7372
|
+
* });
|
|
7373
|
+
* console.log(response);
|
|
7374
|
+
* ```
|
|
7375
|
+
*/
|
|
7376
|
+
embedContent: (params: types.EmbedContentParameters) => Promise<types.EmbedContentResponse>;
|
|
7312
7377
|
/**
|
|
7313
7378
|
* Makes an API request to generate content with a given model.
|
|
7314
7379
|
*
|
|
@@ -7519,7 +7584,7 @@ export declare class Models extends BaseModule {
|
|
|
7519
7584
|
* console.log(response);
|
|
7520
7585
|
* ```
|
|
7521
7586
|
*/
|
|
7522
|
-
|
|
7587
|
+
private embedContentInternal;
|
|
7523
7588
|
/**
|
|
7524
7589
|
* Private method for generating images.
|
|
7525
7590
|
*/
|
|
@@ -10012,6 +10077,7 @@ declare namespace types {
|
|
|
10012
10077
|
ResourceScope,
|
|
10013
10078
|
FeatureSelectionPreference,
|
|
10014
10079
|
Environment,
|
|
10080
|
+
EmbeddingApiType,
|
|
10015
10081
|
SafetyFilterLevel,
|
|
10016
10082
|
PersonGeneration,
|
|
10017
10083
|
ImagePromptLanguage,
|
|
@@ -10052,6 +10118,7 @@ declare namespace types {
|
|
|
10052
10118
|
VideoMetadata,
|
|
10053
10119
|
Part,
|
|
10054
10120
|
Content,
|
|
10121
|
+
HttpRetryOptions,
|
|
10055
10122
|
HttpOptions,
|
|
10056
10123
|
Schema,
|
|
10057
10124
|
ModelSelectionConfig,
|
|
@@ -10143,7 +10210,7 @@ declare namespace types {
|
|
|
10143
10210
|
ReferenceImage,
|
|
10144
10211
|
EditImageParameters,
|
|
10145
10212
|
EmbedContentConfig,
|
|
10146
|
-
|
|
10213
|
+
EmbedContentParametersPrivate,
|
|
10147
10214
|
ContentEmbeddingStatistics,
|
|
10148
10215
|
ContentEmbedding,
|
|
10149
10216
|
EmbedContentMetadata,
|
|
@@ -10411,6 +10478,7 @@ declare namespace types {
|
|
|
10411
10478
|
CountTokensResult,
|
|
10412
10479
|
ComputeTokensResult,
|
|
10413
10480
|
CreateTuningJobParameters,
|
|
10481
|
+
EmbedContentParameters,
|
|
10414
10482
|
UploadToFileSearchStoreResponse,
|
|
10415
10483
|
UploadToFileSearchStoreOperation,
|
|
10416
10484
|
BlobImageUnion,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google/genai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/node/index.mjs",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"web/package.json"
|
|
106
106
|
],
|
|
107
107
|
"devDependencies": {
|
|
108
|
+
"@cfworker/json-schema": "^4.1.1",
|
|
108
109
|
"@eslint/js": "9.20.0",
|
|
109
110
|
"@microsoft/api-extractor": "^7.52.9",
|
|
110
111
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
@@ -114,7 +115,6 @@
|
|
|
114
115
|
"@types/node-fetch": "^2.6.13",
|
|
115
116
|
"@types/unist": "^3.0.3",
|
|
116
117
|
"@types/ws": "^8.5.14",
|
|
117
|
-
"@cfworker/json-schema": "^4.1.1",
|
|
118
118
|
"c8": "^10.1.3",
|
|
119
119
|
"eslint": "8.57.0",
|
|
120
120
|
"gts": "^5.2.0",
|
|
@@ -142,6 +142,7 @@
|
|
|
142
142
|
},
|
|
143
143
|
"dependencies": {
|
|
144
144
|
"google-auth-library": "^10.3.0",
|
|
145
|
+
"p-retry": "^4.6.2",
|
|
145
146
|
"protobufjs": "^7.5.4",
|
|
146
147
|
"ws": "^8.18.0"
|
|
147
148
|
},
|