@google/genai 0.3.1 → 0.5.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
@@ -8,24 +8,25 @@
8
8
 
9
9
  ----------------------
10
10
 
11
- The Google Gen AI JavaScript SDK is an **experimental SDK** designed for
11
+ The Google Gen AI JavaScript SDK is designed for
12
12
  TypeScript and JavaScript developers to build applications powered by Gemini. The SDK
13
13
  supports both the [Gemini Developer API](https://ai.google.dev/gemini-api/docs)
14
14
  and [Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/overview).
15
15
 
16
16
  The Google Gen AI SDK is designed to work with Gemini 2.0 features.
17
17
 
18
- > [!CAUTION] **Experimental SDK:** This SDK is under active development and may
19
- experience breaking changes.
18
+ > [!NOTE]
19
+ > **SDK Preview:**
20
+ > See: [Preview Launch](#preview-launch).
20
21
 
21
- > [!CAUTION] **API Key Security:** Avoid exposing API keys in client-side code.
22
- Use server-side implementations in production environments.
22
+ > [!CAUTION]
23
+ > **API Key Security:** Avoid exposing API keys in client-side code.
24
+ > Use server-side implementations in production environments.
23
25
 
24
26
 
25
27
  ## Prerequisites
26
28
 
27
29
  * Node.js version 18 or later
28
- * `pnpm` or `npm`
29
30
 
30
31
  ## Installation
31
32
 
@@ -62,30 +63,31 @@ main();
62
63
  The package contents are also available unzipped in the
63
64
  `package/` directory of the bucket, so an equivalent web example is:
64
65
 
65
- ```
66
+ ```html
66
67
  <!DOCTYPE html>
67
68
  <html lang="en">
68
- <head>
69
- <meta charset="UTF-8">
70
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
69
+ <head>
70
+ <meta charset="UTF-8" />
71
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
71
72
  <title>Using My Package</title>
72
- </head>
73
- <body>
73
+ </head>
74
+ <body>
74
75
  <script type="module">
75
- import {GoogleGenAI, Type} from 'dist/web/index.mjs';
76
- const ai = new GoogleGenAI({apiKey:"YOUR_API_KEY"});
77
-
78
- async function main() {
79
- const response = await ai.models.generateContent({
80
- model: 'gemini-2.0-flash-001',
81
- contents: 'Why is the sky blue?',
82
- });
83
- console.log(response.text());
84
- }
76
+ import {GoogleGenAI} from 'https://cdn.jsdelivr.net/npm/@google/genai@latest/+esm'
77
+
78
+ const ai = new GoogleGenAI({apiKey:"GEMINI_API_KEY"});
85
79
 
86
- main();
80
+ async function main() {
81
+ const response = await ai.models.generateContent({
82
+ model: 'gemini-2.0-flash-001',
83
+ contents: 'Why is the sky blue?',
84
+ });
85
+ console.log(response.text);
86
+ }
87
+
88
+ main();
87
89
  </script>
88
- </body>
90
+ </body>
89
91
  </html>
90
92
  ```
91
93
 
@@ -108,8 +110,9 @@ const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
108
110
 
109
111
  #### Browser
110
112
 
111
- > [!CAUTION] **API Key Security:** Avoid exposing API keys in client-side code.
112
- Use server-side implementations in production environments.
113
+ > [!CAUTION]
114
+ > **API Key Security:** Avoid exposing API keys in client-side code.
115
+ > Use server-side implementations in production environments.
113
116
 
114
117
  In the browser the initialization code is identical:
115
118
 
@@ -138,26 +141,26 @@ const ai = new GoogleGenAI({
138
141
  All API features are accessed through an instance of the `GoogleGenAI` classes.
139
142
  The submodules bundle together related API methods:
140
143
 
141
- - [`client.models`](https://googleapis.github.io/js-genai/classes/models.Models.html):
144
+ - [`ai.models`](https://googleapis.github.io/js-genai/classes/models.Models.html):
142
145
  Use `models` to query models (`generateContent`, `generateImages`, ...), or
143
146
  examine their metadata.
144
- - [`client.caches`](https://googleapis.github.io/js-genai/classes/caches.Caches.html):
147
+ - [`ai.caches`](https://googleapis.github.io/js-genai/classes/caches.Caches.html):
145
148
  Create and manage `caches` to reduce costs when repeatedly using the same
146
149
  large prompt prefix.
147
- - [`client.chats`](https://googleapis.github.io/js-genai/classes/chats.Chats.html):
150
+ - [`ai.chats`](https://googleapis.github.io/js-genai/classes/chats.Chats.html):
148
151
  Create local stateful `chat` objects to simplify multi turn interactions.
149
- - [`client.files`](https://googleapis.github.io/js-genai/classes/files.Files.html):
152
+ - [`ai.files`](https://googleapis.github.io/js-genai/classes/files.Files.html):
150
153
  Upload `files` to the API and reference them in your prompts.
151
- This reduces bandwidth if you use a file many times, and handles files too
154
+ This reduces bandwidth if you use a file many times, and handles files too
152
155
  large to fit inline with your prompt.
153
- - [`client.live`](https://googleapis.github.io/js-genai/classes/live.Live.html):
156
+ - [`ai.live`](https://googleapis.github.io/js-genai/classes/live.Live.html):
154
157
  Start a `live` session for real time interaction, allows text + audio + video
155
158
  input, and text or audio output.
156
159
 
157
160
  ## Samples
158
161
 
159
162
  More samples can be found in the
160
- [github samples directory](https://github.com/google-gemini/generative-ai-js/tree/main/samples).
163
+ [github samples directory](https://github.com/googleapis/js-genai/tree/main/sdk-samples).
161
164
 
162
165
 
163
166
  ### Streaming
@@ -242,3 +245,11 @@ async function main() {
242
245
 
243
246
  main();
244
247
  ```
248
+
249
+
250
+ ## Preview Launch
251
+
252
+ The SDK is curently in a preview launch stage, per [Google's launch stages](https://cloud.google.com/products?hl=en#section-22) this means:
253
+
254
+ > At Preview, products or features are ready for testing by customers. Preview offerings are often publicly announced, but are not necessarily feature-complete, and no SLAs or technical support commitments are provided for these. Unless stated otherwise by Google, Preview offerings are intended for use in test environments only. The average Preview stage lasts about six months.
255
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/genai",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "main": "dist/node/index.js",
6
6
  "module": "dist/web/index.mjs",
@@ -37,9 +37,9 @@
37
37
  "scripts": {
38
38
  "build": "rollup -c && api-extractor run --local --verbose && api-extractor run -c api-extractor.node.json --local --verbose&& api-extractor run -c api-extractor.web.json --local --verbose",
39
39
  "build-prod": "rollup -c && api-extractor run --verbose && api-extractor run -c api-extractor.node.json --verbose && api-extractor run -c api-extractor.web.json --verbose",
40
- "unit-test": "ts-node node_modules/jasmine/bin/jasmine test/unit/**/*_test.ts test/unit/*_test.ts",
40
+ "unit-test": "ts-node node_modules/jasmine/bin/jasmine test/unit/web/*_test.ts test/unit/node/*_test.ts test/unit/*_test.ts",
41
41
  "system-test": "ts-node node_modules/jasmine/bin/jasmine test/system/**/*_test.ts",
42
- "docs": "typedoc && scripts/add_typedoc_headers.sh",
42
+ "docs": "typedoc && ts-node scripts/add_docsite_license_headers.ts",
43
43
  "format": "prettier '**/*.ts' '**/*.mjs' '**/*.json' --write",
44
44
  "lint": "eslint '**/*.ts'",
45
45
  "lint-fix": "eslint --fix '**/*.ts'"