Skip to content

Commit 5837f01

Browse files
Merge branch 'main' into update-for-new-sdk
2 parents ec51a77 + 4e36e77 commit 5837f01

File tree

1 file changed

+6
-95
lines changed

1 file changed

+6
-95
lines changed

README.md

Lines changed: 6 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,12 @@
1-
# Google Generative AI for Node.js
1+
# [Deprecated] Google AI JavaScript SDK for the Gemini API
22

33
> **IMPORTANT:** This SDK is intended for use with older Gemini models (e.g., Gemini 1.0 Pro, Gemini 1.5 Pro). For access to the latest models, including Gemini 2.0 and Gemini 2.5 Pro, please use the newer SDK available at [https://github.com/googleapis/js-genai](https://github.com/googleapis/js-genai).
44
5-
The Google AI JavaScript SDK is the easiest way for JavaScript developers to
6-
build with the Gemini API. The Gemini API gives you access to Gemini
7-
[models](https://ai.google.dev/models/gemini) created by
8-
[Google DeepMind](https://deepmind.google/technologies/gemini/#introduction).
9-
Gemini models are built from the ground up to be multimodal, so you can reason
10-
seamlessly across text, images, and code.
5+
=======
6+
With Gemini 2.0, we took the chance to create a single unified SDK for all developers who want to use Google's GenAI models (Gemini, Veo, Imagen, etc). As part of that process, we took all of the feedback from this SDK and what developers like about other SDKs in the ecosystem to create the [Google Gen AI SDK](https://github.com/googleapis/js-genai).
117

12-
> [!CAUTION] **Using the Google AI SDK for JavaScript directly from a
13-
> client-side app is recommended for prototyping only.** If you plan to enable
14-
> billing, we strongly recommend that you call the Google AI Gemini API only
15-
> server-side to keep your API key safe. You risk potentially exposing your API
16-
> key to malicious actors if you embed your API key directly in your JavaScript
17-
> app or fetch it remotely at runtime.
8+
The full migration guide from the old SDK to new SDK is available in the [Gemini API docs](https://ai.google.dev/gemini-api/docs/migrate).
189

19-
## Get started with the Gemini API
10+
We won't be adding anything to this SDK or making any further changes. The Gemini API docs are fully updated to show examples of the new Google Gen AI SDK. We know how disruptive an SDK change can be and don't take this change lightly, but our goal is to create an extremely simple and clear path for developers to build with our models so it felt necessary to make this change.
2011

21-
1. Go to [Google AI Studio](https://aistudio.google.com/).
22-
2. Login with your Google account.
23-
3. [Create an API key](https://aistudio.google.com/app/apikey). Note that in
24-
Europe the free tier is not available.
25-
4. Try the
26-
[Node.js quickstart](https://ai.google.dev/tutorials/node_quickstart)
27-
28-
## Usage example
29-
30-
See the [Node.js quickstart](https://ai.google.dev/tutorials/node_quickstart)
31-
for complete code.
32-
33-
1. Install the SDK package
34-
35-
```js
36-
npm install @google/generative-ai
37-
```
38-
39-
2. Initialize the model
40-
41-
```js
42-
import { GoogleGenerativeAI } from "@google/generative-ai";
43-
44-
const genAI = new GoogleGenerativeAI(process.env.API_KEY);
45-
46-
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
47-
```
48-
49-
3. Run a prompt
50-
51-
```js
52-
import * as fs from 'fs';
53-
const prompt = "Does this look store-bought or homemade?";
54-
const image = {
55-
inlineData: {
56-
data: Buffer.from(fs.readFileSync("cookie.png")).toString("base64"),
57-
mimeType: "image/png",
58-
},
59-
};
60-
61-
const result = await model.generateContent([prompt, image]);
62-
console.log(result.response.text());
63-
```
64-
65-
## Try out a sample app
66-
67-
This repository contains sample Node and web apps demonstrating how the SDK can
68-
access and utilize the Gemini model for various use cases.
69-
70-
**To try out the sample Node app, follow these steps:**
71-
72-
1. Check out this repository. \
73-
`git clone https://github.com/google/generative-ai-js`
74-
75-
1. [Obtain an API key](https://makersuite.google.com/app/apikey) to use with
76-
the Google AI SDKs.
77-
78-
2. cd into the `samples` folder and run `npm install`.
79-
80-
3. Assign your API key to an environment variable: `export API_KEY=MY_API_KEY`.
81-
82-
4. Open the sample file you're interested in. Example: `text_generation.js`.
83-
In the `runAll()` function, comment out any samples you don't want to run.
84-
85-
5. Run the sample file. Example: `node text_generation.js`.
86-
87-
## Documentation
88-
89-
See the
90-
[Gemini API Cookbook](https://github.com/google-gemini/gemini-api-cookbook/) or
91-
[ai.google.dev](https://ai.google.dev) for complete documentation. For the API reference docs, please refer to [JavaScript SDK Reference](https://github.com/google-gemini/generative-ai-js/blob/main/docs/reference/main/index.md).
92-
93-
## Contributing
94-
95-
See [Contributing](/docs/contributing.md) for more information on contributing
96-
to the Google AI JavaScript SDK.
97-
98-
## License
99-
100-
The contents of this repository are licensed under the
101-
[Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
12+
Thank you for building with Gemini and [let us know](https://discuss.ai.google.dev/c/gemini-api/4) if you need any help!

0 commit comments

Comments
 (0)