@google/genai 1.1.0 → 1.3.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/README.md CHANGED
@@ -33,7 +33,7 @@ npm install @google/genai
33
33
 
34
34
  ## Quickstart
35
35
 
36
- The simplest way to get started is to using an API key from
36
+ The simplest way to get started is to use an API key from
37
37
  [Google AI Studio](https://aistudio.google.com/apikey):
38
38
 
39
39
  ```typescript
package/dist/genai.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Client } from '@modelcontextprotocol/sdk/client/index.js';
1
+ import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
2
  import { GoogleAuthOptions } from 'google-auth-library';
3
3
 
4
4
  /** Marks the end of user activity.
@@ -272,6 +272,12 @@ export declare interface AuthConfigOidcConfig {
272
272
  serviceAccount?: string;
273
273
  }
274
274
 
275
+ /** Config for auth_tokens.create parameters. */
276
+ export declare interface AuthToken {
277
+ /** The name of the auth token. */
278
+ name?: string;
279
+ }
280
+
275
281
  /** Type of auth scheme. */
276
282
  export declare enum AuthType {
277
283
  AUTH_TYPE_UNSPECIFIED = "AUTH_TYPE_UNSPECIFIED",
@@ -855,7 +861,7 @@ export declare class ControlReferenceImage {
855
861
  /** Configuration for the control reference image. */
856
862
  config?: ControlReferenceConfig;
857
863
  /** Internal method to convert to ReferenceImageAPIInternal. */
858
- toReferenceImageAPI(): any;
864
+ toReferenceImageAPI(): ReferenceImageAPIInternal;
859
865
  }
860
866
 
861
867
  /** Enum representing the control type of a control reference image. */
@@ -938,11 +944,17 @@ export declare interface CreateAuthTokenConfig {
938
944
  not count as a use. */
939
945
  uses?: number;
940
946
  /** Configuration specific to Live API connections created using this token. */
941
- liveEphemeralParameters?: LiveEphemeralParameters;
947
+ liveConnectConstraints?: LiveConnectConstraints;
942
948
  /** Additional fields to lock in the effective LiveConnectParameters. */
943
949
  lockAdditionalFields?: string[];
944
950
  }
945
951
 
952
+ /** Config for auth_tokens.create parameters. */
953
+ export declare interface CreateAuthTokenParameters {
954
+ /** Optional parameters for the request. */
955
+ config?: CreateAuthTokenConfig;
956
+ }
957
+
946
958
  /** Optional configuration for cached content creation. */
947
959
  export declare interface CreateCachedContentConfig {
948
960
  /** Used to override HTTP request options. */
@@ -1837,7 +1849,11 @@ export declare enum FinishReason {
1837
1849
  /**
1838
1850
  * Token generation stopped because generated images have safety violations.
1839
1851
  */
1840
- IMAGE_SAFETY = "IMAGE_SAFETY"
1852
+ IMAGE_SAFETY = "IMAGE_SAFETY",
1853
+ /**
1854
+ * The tool call generated by the model is invalid.
1855
+ */
1856
+ UNEXPECTED_TOOL_CALL = "UNEXPECTED_TOOL_CALL"
1841
1857
  }
1842
1858
 
1843
1859
  /** A function call. */
@@ -2408,6 +2424,8 @@ export declare interface GenerateVideosConfig {
2408
2424
  negativePrompt?: string;
2409
2425
  /** Whether to use the prompt rewriting logic. */
2410
2426
  enhancePrompt?: boolean;
2427
+ /** Whether to generate audio along with the video. */
2428
+ generateAudio?: boolean;
2411
2429
  }
2412
2430
 
2413
2431
  /** A video generation operation. */
@@ -2665,6 +2683,7 @@ export declare class GoogleGenAI {
2665
2683
  readonly caches: Caches;
2666
2684
  readonly files: Files;
2667
2685
  readonly operations: Operations;
2686
+ readonly authTokens: Tokens;
2668
2687
  readonly tunings: Tunings;
2669
2688
  constructor(options: GoogleGenAIOptions);
2670
2689
  }
@@ -3542,6 +3561,16 @@ export declare interface LiveConnectConfig {
3542
3561
  proactivity?: ProactivityConfig;
3543
3562
  }
3544
3563
 
3564
+ /** Config for LiveConnectConstraints for Auth Token creation. */
3565
+ export declare interface LiveConnectConstraints {
3566
+ /** ID of the model to configure in the ephemeral token for Live API.
3567
+ For a list of models, see `Gemini models
3568
+ <https://ai.google.dev/gemini-api/docs/models>`. */
3569
+ model?: string;
3570
+ /** Configuration specific to Live API connections created using this token. */
3571
+ config?: LiveConnectConfig;
3572
+ }
3573
+
3545
3574
  /** Parameters for connecting to the live API. */
3546
3575
  export declare interface LiveConnectParameters {
3547
3576
  /** ID of the model to use. For a list of models, see `Google models
@@ -3554,16 +3583,6 @@ export declare interface LiveConnectParameters {
3554
3583
  config?: LiveConnectConfig;
3555
3584
  }
3556
3585
 
3557
- /** Config for LiveEphemeralParameters for Auth Token creation. */
3558
- export declare interface LiveEphemeralParameters {
3559
- /** ID of the model to configure in the ephemeral token for Live API.
3560
- For a list of models, see `Gemini models
3561
- <https://ai.google.dev/gemini-api/docs/models>`. */
3562
- model?: string;
3563
- /** Configuration specific to Live API connections created using this token. */
3564
- config?: LiveConnectConfig;
3565
- }
3566
-
3567
3586
  /**
3568
3587
  LiveMusic class encapsulates the configuration for live music
3569
3588
  generation via Lyria Live models.
@@ -3695,8 +3714,6 @@ export declare interface LiveMusicGenerationConfig {
3695
3714
  muteDrums?: boolean;
3696
3715
  /** Whether the audio output should contain only bass and drums. */
3697
3716
  onlyBassAndDrums?: boolean;
3698
- /** The mode of music generation. Default mode is QUALITY. */
3699
- musicGenerationMode?: MusicGenerationMode;
3700
3717
  }
3701
3718
 
3702
3719
  /** The playback control signal to apply to the music generation. */
@@ -4059,7 +4076,7 @@ export declare class MaskReferenceImage {
4059
4076
  /** Configuration for the mask reference image. */
4060
4077
  config?: MaskReferenceConfig;
4061
4078
  /** Internal method to convert to ReferenceImageAPIInternal. */
4062
- toReferenceImageAPI(): any;
4079
+ toReferenceImageAPI(): ReferenceImageAPIInternal;
4063
4080
  }
4064
4081
 
4065
4082
  /** Enum representing the mask mode of a mask reference image. */
@@ -4146,7 +4163,7 @@ export declare enum Modality {
4146
4163
  */
4147
4164
  IMAGE = "IMAGE",
4148
4165
  /**
4149
- * Indicates the model should return images.
4166
+ * Indicates the model should return audio.
4150
4167
  */
4151
4168
  AUDIO = "AUDIO"
4152
4169
  }
@@ -4520,24 +4537,6 @@ export declare interface MultiSpeakerVoiceConfig {
4520
4537
  speakerVoiceConfigs?: SpeakerVoiceConfig[];
4521
4538
  }
4522
4539
 
4523
- /** The mode of music generation. */
4524
- export declare enum MusicGenerationMode {
4525
- /**
4526
- * This value is unused.
4527
- */
4528
- MUSIC_GENERATION_MODE_UNSPECIFIED = "MUSIC_GENERATION_MODE_UNSPECIFIED",
4529
- /**
4530
- * Steer text prompts to regions of latent space with higher quality
4531
- music.
4532
- */
4533
- QUALITY = "QUALITY",
4534
- /**
4535
- * Steer text prompts to regions of latent space with a larger diversity
4536
- of music.
4537
- */
4538
- DIVERSITY = "DIVERSITY"
4539
- }
4540
-
4541
4540
  /** A long-running operation. */
4542
4541
  export declare interface Operation {
4543
4542
  /** The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */
@@ -4572,11 +4571,6 @@ export declare class Operations extends BaseModule {
4572
4571
  private fetchPredictVideosOperationInternal;
4573
4572
  }
4574
4573
 
4575
- /**
4576
- * @license
4577
- * Copyright 2025 Google LLC
4578
- * SPDX-License-Identifier: Apache-2.0
4579
- */
4580
4574
  /** Required. Outcome of the code execution. */
4581
4575
  export declare enum Outcome {
4582
4576
  /**
@@ -4739,6 +4733,8 @@ export declare interface Part {
4739
4733
  inlineData?: Blob_2;
4740
4734
  /** Optional. URI based data. */
4741
4735
  fileData?: FileData;
4736
+ /** An opaque signature for the thought so it can be reused in subsequent requests. */
4737
+ thoughtSignature?: string;
4742
4738
  /** Optional. Result of executing the [ExecutableCode]. */
4743
4739
  codeExecutionResult?: CodeExecutionResult;
4744
4740
  /** Optional. Code generated by the model that is meant to be executed. */
@@ -4864,7 +4860,7 @@ export declare class RawReferenceImage {
4864
4860
  /** The type of the reference image. Only set by the SDK. */
4865
4861
  referenceType?: string;
4866
4862
  /** Internal method to convert to ReferenceImageAPIInternal. */
4867
- toReferenceImageAPI(): any;
4863
+ toReferenceImageAPI(): ReferenceImageAPIInternal;
4868
4864
  }
4869
4865
 
4870
4866
  /** Marks the end of user activity.
@@ -4883,6 +4879,24 @@ export declare interface RealtimeInputConfig {
4883
4879
 
4884
4880
  export declare type ReferenceImage = RawReferenceImage | MaskReferenceImage | ControlReferenceImage | StyleReferenceImage | SubjectReferenceImage;
4885
4881
 
4882
+ /** Private class that represents a Reference image that is sent to API. */
4883
+ declare interface ReferenceImageAPIInternal {
4884
+ /** The reference image for the editing operation. */
4885
+ referenceImage?: types.Image;
4886
+ /** The id of the reference image. */
4887
+ referenceId?: number;
4888
+ /** The type of the reference image. Only set by the SDK. */
4889
+ referenceType?: string;
4890
+ /** Configuration for the mask reference image. */
4891
+ maskImageConfig?: types.MaskReferenceConfig;
4892
+ /** Configuration for the control reference image. */
4893
+ controlImageConfig?: types.ControlReferenceConfig;
4894
+ /** Configuration for the style reference image. */
4895
+ styleImageConfig?: types.StyleReferenceConfig;
4896
+ /** Configuration for the subject reference image. */
4897
+ subjectImageConfig?: types.SubjectReferenceConfig;
4898
+ }
4899
+
4886
4900
  /** Represents a recorded session. */
4887
4901
  export declare interface ReplayFile {
4888
4902
  replayId?: string;
@@ -5375,7 +5389,7 @@ export declare class StyleReferenceImage {
5375
5389
  /** Configuration for the style reference image. */
5376
5390
  config?: StyleReferenceConfig;
5377
5391
  /** Internal method to convert to ReferenceImageAPIInternal. */
5378
- toReferenceImageAPI(): any;
5392
+ toReferenceImageAPI(): ReferenceImageAPIInternal;
5379
5393
  }
5380
5394
 
5381
5395
  /** Configuration for a Subject reference image. */
@@ -5403,7 +5417,7 @@ export declare class SubjectReferenceImage {
5403
5417
  referenceType?: string;
5404
5418
  /** Configuration for the subject reference image. */
5405
5419
  config?: SubjectReferenceConfig;
5406
- toReferenceImageAPI(): any;
5420
+ toReferenceImageAPI(): ReferenceImageAPIInternal;
5407
5421
  }
5408
5422
 
5409
5423
  /** Enum representing the subject type of a subject reference image. */
@@ -5532,6 +5546,89 @@ export declare interface ThinkingConfig {
5532
5546
  thinkingBudget?: number;
5533
5547
  }
5534
5548
 
5549
+ export declare class Tokens extends BaseModule {
5550
+ private readonly apiClient;
5551
+ constructor(apiClient: ApiClient);
5552
+ /**
5553
+ * Creates an ephemeral auth token resource.
5554
+ *
5555
+ * @experimental
5556
+ *
5557
+ * @remarks
5558
+ * Ephermeral auth tokens is only supported in the Gemini Developer API.
5559
+ * It can be used for the session connection to the Live constrained API.
5560
+ *
5561
+ * @param params - The parameters for the create request.
5562
+ * @return The created auth token.
5563
+ *
5564
+ * @example
5565
+ * ```ts
5566
+ * // Case 1: If LiveEphemeralParameters is unset, unlock LiveConnectConfig
5567
+ * // when using the token in Live API sessions. Each session connection can
5568
+ * // use a different configuration.
5569
+ * const config: CreateAuthTokenConfig = {
5570
+ * uses: 3,
5571
+ * expireTime: '2025-05-01T00:00:00Z',
5572
+ * }
5573
+ * const token = await ai.tokens.create(config);
5574
+ *
5575
+ * // Case 2: If LiveEphemeralParameters is set, lock all fields in
5576
+ * // LiveConnectConfig when using the token in Live API sessions. For
5577
+ * // example, changing `outputAudioTranscription` in the Live API
5578
+ * // connection will be ignored by the API.
5579
+ * const config: CreateAuthTokenConfig =
5580
+ * uses: 3,
5581
+ * expireTime: '2025-05-01T00:00:00Z',
5582
+ * LiveEphemeralParameters: {
5583
+ * model: 'gemini-2.0-flash-001',
5584
+ * config: {
5585
+ * 'responseModalities': ['AUDIO'],
5586
+ * 'systemInstruction': 'Always answer in English.',
5587
+ * }
5588
+ * }
5589
+ * }
5590
+ * const token = await ai.tokens.create(config);
5591
+ *
5592
+ * // Case 3: If LiveEphemeralParameters is set and lockAdditionalFields is
5593
+ * // set, lock LiveConnectConfig with set and additional fields (e.g.
5594
+ * // responseModalities, systemInstruction, temperature in this example) when
5595
+ * // using the token in Live API sessions.
5596
+ * const config: CreateAuthTokenConfig =
5597
+ * uses: 3,
5598
+ * expireTime: '2025-05-01T00:00:00Z',
5599
+ * LiveEphemeralParameters: {
5600
+ * model: 'gemini-2.0-flash-001',
5601
+ * config: {
5602
+ * 'responseModalities': ['AUDIO'],
5603
+ * 'systemInstruction': 'Always answer in English.',
5604
+ * }
5605
+ * },
5606
+ * lockAdditionalFields: ['temperature'],
5607
+ * }
5608
+ * const token = await ai.tokens.create(config);
5609
+ *
5610
+ * // Case 4: If LiveEphemeralParameters is set and lockAdditionalFields is
5611
+ * // empty array, lock LiveConnectConfig with set fields (e.g.
5612
+ * // responseModalities, systemInstruction in this example) when using the
5613
+ * // token in Live API sessions.
5614
+ * const config: CreateAuthTokenConfig =
5615
+ * uses: 3,
5616
+ * expireTime: '2025-05-01T00:00:00Z',
5617
+ * LiveEphemeralParameters: {
5618
+ * model: 'gemini-2.0-flash-001',
5619
+ * config: {
5620
+ * 'responseModalities': ['AUDIO'],
5621
+ * 'systemInstruction': 'Always answer in English.',
5622
+ * }
5623
+ * },
5624
+ * lockAdditionalFields: [],
5625
+ * }
5626
+ * const token = await ai.tokens.create(config);
5627
+ * ```
5628
+ */
5629
+ create(params: types.CreateAuthTokenParameters): Promise<types.AuthToken>;
5630
+ }
5631
+
5535
5632
  /** Tokens info with a list of tokens and the corresponding list of token ids. */
5536
5633
  export declare interface TokensInfo {
5537
5634
  /** Optional. Optional fields for the role from the corresponding Content. */
@@ -5860,7 +5957,6 @@ declare namespace types {
5860
5957
  TurnCoverage,
5861
5958
  FunctionResponseScheduling,
5862
5959
  Scale,
5863
- MusicGenerationMode,
5864
5960
  LiveMusicPlaybackControl,
5865
5961
  VideoMetadata,
5866
5962
  Blob_2 as Blob,
@@ -6117,8 +6213,10 @@ declare namespace types {
6117
6213
  LiveMusicConnectParameters,
6118
6214
  LiveMusicSetConfigParameters,
6119
6215
  LiveMusicSetWeightedPromptsParameters,
6120
- LiveEphemeralParameters,
6216
+ AuthToken,
6217
+ LiveConnectConstraints,
6121
6218
  CreateAuthTokenConfig,
6219
+ CreateAuthTokenParameters,
6122
6220
  OperationGetParameters,
6123
6221
  BlobImageUnion,
6124
6222
  PartUnion,