@google/genai 1.8.0 → 1.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.
package/README.md CHANGED
@@ -218,10 +218,10 @@ main();
218
218
 
219
219
  ### Function Calling
220
220
 
221
- To let Gemini to interact with external systems, you can provide provide
221
+ To let Gemini to interact with external systems, you can provide
222
222
  `functionDeclaration` objects as `tools`. To use these tools it's a 4 step
223
223
 
224
- 1. **Declare the function name, description, and parameters**
224
+ 1. **Declare the function name, description, and parametersJsonSchema**
225
225
  2. **Call `generateContent` with function calling enabled**
226
226
  3. **Use the returned `FunctionCall` parameters to call your actual function**
227
227
  3. **Send the result back to the model (with history, easier in `ai.chat`)
@@ -234,19 +234,14 @@ const GEMINI_API_KEY = process.env.GEMINI_API_KEY;
234
234
  async function main() {
235
235
  const controlLightDeclaration: FunctionDeclaration = {
236
236
  name: 'controlLight',
237
- parameters: {
238
- type: Type.OBJECT,
239
- description: 'Set the brightness and color temperature of a room light.',
240
- properties: {
237
+ parametersJsonSchema: {
238
+ type: 'object',
239
+ properties:{
241
240
  brightness: {
242
- type: Type.NUMBER,
243
- description:
244
- 'Light level from 0 to 100. Zero is off and 100 is full brightness.',
241
+ type:'number',
245
242
  },
246
243
  colorTemperature: {
247
- type: Type.STRING,
248
- description:
249
- 'Color temperature of the light fixture which can be `daylight`, `cool`, or `warm`.',
244
+ type:'string',
250
245
  },
251
246
  },
252
247
  required: ['brightness', 'colorTemperature'],
package/dist/genai.d.ts CHANGED
@@ -560,6 +560,8 @@ export declare interface BatchJobDestination {
560
560
  inlinedResponses?: InlinedResponse[];
561
561
  }
562
562
 
563
+ export declare type BatchJobDestinationUnion = BatchJobDestination | string;
564
+
563
565
  /** Config for `src` parameter. */
564
566
  export declare interface BatchJobSource {
565
567
  /** Storage format of the input files. Must be one of:
@@ -1229,7 +1231,7 @@ export declare interface CreateBatchJobConfig {
1229
1231
  /** GCS or BigQuery URI prefix for the output predictions. Example:
1230
1232
  "gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".
1231
1233
  */
1232
- dest?: string;
1234
+ dest?: BatchJobDestinationUnion;
1233
1235
  }
1234
1236
 
1235
1237
  /** Config for batches.create parameters. */
@@ -1745,6 +1747,9 @@ export declare interface EditImageConfig {
1745
1747
  only).
1746
1748
  */
1747
1749
  outputCompressionQuality?: number;
1750
+ /** Whether to add a watermark to the generated images.
1751
+ */
1752
+ addWatermark?: boolean;
1748
1753
  /** Describes the editing mode for the request. */
1749
1754
  editMode?: EditMode;
1750
1755
  /** The number of sampling steps. A higher value has better image
@@ -2480,6 +2485,8 @@ export declare interface GenerateContentParameters {
2480
2485
 
2481
2486
  /** Response message for PredictionService.GenerateContent. */
2482
2487
  export declare class GenerateContentResponse {
2488
+ /** Used to retain the full HTTP response. */
2489
+ sdkHttpResponse?: HttpResponse;
2483
2490
  /** Response variations returned by the model.
2484
2491
  */
2485
2492
  candidates?: Candidate[];
@@ -2800,7 +2807,7 @@ export declare interface GenerateVideosConfig {
2800
2807
  seed?: number;
2801
2808
  /** The aspect ratio for the generated video. 16:9 (landscape) and 9:16 (portrait) are supported. */
2802
2809
  aspectRatio?: string;
2803
- /** The resolution for the generated video. 1280x720, 1920x1080 are supported. */
2810
+ /** The resolution for the generated video. 720p and 1080p are supported. */
2804
2811
  resolution?: string;
2805
2812
  /** Whether allow to generate person videos, and restrict to specific ages. Supported values are: dont_allow, allow_adult. */
2806
2813
  personGeneration?: string;
@@ -3415,7 +3422,10 @@ export declare interface HttpOptions {
3415
3422
  headers?: Record<string, string>;
3416
3423
  /** Timeout for the request in milliseconds. */
3417
3424
  timeout?: number;
3418
- /** Extra parameters to add to the request body. */
3425
+ /** Extra parameters to add to the request body.
3426
+ The structure must match the backend API's request structure.
3427
+ - VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
3428
+ - GeminiAPI backend API docs: https://ai.google.dev/api/rest */
3419
3429
  extraBody?: Record<string, unknown>;
3420
3430
  }
3421
3431
 
@@ -3498,11 +3508,38 @@ export { Image_2 as Image }
3498
3508
 
3499
3509
  /** Enum that specifies the language of the text in the prompt. */
3500
3510
  export declare enum ImagePromptLanguage {
3511
+ /**
3512
+ * Auto-detect the language.
3513
+ */
3501
3514
  auto = "auto",
3515
+ /**
3516
+ * English
3517
+ */
3502
3518
  en = "en",
3519
+ /**
3520
+ * Japanese
3521
+ */
3503
3522
  ja = "ja",
3523
+ /**
3524
+ * Korean
3525
+ */
3504
3526
  ko = "ko",
3505
- hi = "hi"
3527
+ /**
3528
+ * Hindi
3529
+ */
3530
+ hi = "hi",
3531
+ /**
3532
+ * Chinese
3533
+ */
3534
+ zh = "zh",
3535
+ /**
3536
+ * Portuguese
3537
+ */
3538
+ pt = "pt",
3539
+ /**
3540
+ * Spanish
3541
+ */
3542
+ es = "es"
3506
3543
  }
3507
3544
 
3508
3545
  /** Config for inlined request. */
@@ -3800,7 +3837,7 @@ export declare class Live {
3800
3837
  if (GOOGLE_GENAI_USE_VERTEXAI) {
3801
3838
  model = 'gemini-2.0-flash-live-preview-04-09';
3802
3839
  } else {
3803
- model = 'gemini-2.0-flash-live-001';
3840
+ model = 'gemini-live-2.5-flash-preview';
3804
3841
  }
3805
3842
  const session = await ai.live.connect({
3806
3843
  model: model,
@@ -4766,6 +4803,14 @@ export declare class Models extends BaseModule {
4766
4803
  * ```
4767
4804
  */
4768
4805
  generateContent: (params: types.GenerateContentParameters) => Promise<types.GenerateContentResponse>;
4806
+ /**
4807
+ * This logic is needed for GenerateContentConfig only.
4808
+ * Previously we made GenerateContentConfig.responseSchema field to accept
4809
+ * unknown. Since v1.9.0, we switch to use backend JSON schema support.
4810
+ * To maintain backward compatibility, we move the data that was treated as
4811
+ * JSON schema from the responseSchema field to the responseJsonSchema field.
4812
+ */
4813
+ private maybeMoveToResponseJsonSchem;
4769
4814
  /**
4770
4815
  * Makes an API request to generate content with a given model and yields the
4771
4816
  * response in chunks.
@@ -5040,18 +5085,6 @@ export declare interface MultiSpeakerVoiceConfig {
5040
5085
  speakerVoiceConfigs?: SpeakerVoiceConfig[];
5041
5086
  }
5042
5087
 
5043
- /** A long-running operation. */
5044
- export declare interface Operation {
5045
- /** 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}`. */
5046
- name?: string;
5047
- /** Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. */
5048
- metadata?: Record<string, unknown>;
5049
- /** If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. */
5050
- done?: boolean;
5051
- /** The error result of the operation in case of failure or cancellation. */
5052
- error?: Record<string, unknown>;
5053
- }
5054
-
5055
5088
  /** Parameters for the get method of the operations module. */
5056
5089
  export declare interface OperationGetParameters {
5057
5090
  /** The operation to be retrieved. */
@@ -5778,7 +5811,7 @@ export declare class Session {
5778
5811
  if (GOOGLE_GENAI_USE_VERTEXAI) {
5779
5812
  model = 'gemini-2.0-flash-live-preview-04-09';
5780
5813
  } else {
5781
- model = 'gemini-2.0-flash-live-001';
5814
+ model = 'gemini-live-2.5-flash-preview';
5782
5815
  }
5783
5816
  const session = await ai.live.connect({
5784
5817
  model: model,
@@ -6073,14 +6106,20 @@ export declare class Tokens extends BaseModule {
6073
6106
  * @experimental
6074
6107
  *
6075
6108
  * @remarks
6076
- * Ephermeral auth tokens is only supported in the Gemini Developer API.
6109
+ * Ephemeral auth tokens is only supported in the Gemini Developer API.
6077
6110
  * It can be used for the session connection to the Live constrained API.
6111
+ * Support in v1alpha only.
6078
6112
  *
6079
6113
  * @param params - The parameters for the create request.
6080
6114
  * @return The created auth token.
6081
6115
  *
6082
6116
  * @example
6083
6117
  * ```ts
6118
+ * const ai = new GoogleGenAI({
6119
+ * apiKey: token.name,
6120
+ * httpOptions: { apiVersion: 'v1alpha' } // Support in v1alpha only.
6121
+ * });
6122
+ *
6084
6123
  * // Case 1: If LiveEphemeralParameters is unset, unlock LiveConnectConfig
6085
6124
  * // when using the token in Live API sessions. Each session connection can
6086
6125
  * // use a different configuration.
@@ -6345,6 +6384,18 @@ export declare interface TuningJob {
6345
6384
  tunedModelDisplayName?: string;
6346
6385
  }
6347
6386
 
6387
+ /** A long-running operation. */
6388
+ export declare interface TuningOperation {
6389
+ /** 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}`. */
6390
+ name?: string;
6391
+ /** Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. */
6392
+ metadata?: Record<string, unknown>;
6393
+ /** If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. */
6394
+ done?: boolean;
6395
+ /** The error result of the operation in case of failure or cancellation. */
6396
+ error?: Record<string, unknown>;
6397
+ }
6398
+
6348
6399
  declare class Tunings extends BaseModule {
6349
6400
  private readonly apiClient;
6350
6401
  constructor(apiClient: ApiClient);
@@ -6662,7 +6713,7 @@ declare namespace types {
6662
6713
  TuningValidationDataset,
6663
6714
  CreateTuningJobConfig,
6664
6715
  CreateTuningJobParameters,
6665
- Operation,
6716
+ TuningOperation,
6666
6717
  CreateCachedContentConfig,
6667
6718
  CreateCachedContentParameters,
6668
6719
  CachedContentUsageMetadata,
@@ -6791,7 +6842,8 @@ declare namespace types {
6791
6842
  ToolUnion,
6792
6843
  ToolListUnion,
6793
6844
  DownloadableFileUnion,
6794
- BatchJobSourceUnion
6845
+ BatchJobSourceUnion,
6846
+ BatchJobDestinationUnion
6795
6847
  }
6796
6848
  }
6797
6849