Skip to content

Commit fc8045f

Browse files
committedMay 25, 2024
Merge branch 'v2'
2 parents ede54b8 + 9bbc09d commit fc8045f

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed
 

‎.github/README.md

+27-5
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ That's nearly 4 times less code!
6767

6868
</details>
6969

70-
And there's no sacrifices either. Gemini AI uses Google's REST API under the hood, so you get simplicity without compromise.
71-
72-
And, there's also more!
70+
There's also more...
7371

72+
-[**Native REST API**](#inititalization): Simplicity without compromise.
7473
- 📝 [**Optimized File Uploads**](#optimized-file-uploads): Automatically uses Google's File API when necessary
7574
- 📁 [**Automatic File Type Detection**](#optimized-file-uploads): Gemini AI will detect MIME types of files automatically
76-
- 🧩 [**Automatic Request Creation**](): Auto-formats your requests—So you don't have to.
75+
- 🧩 [**Automatic Request Creation**](#array-form): Auto-formats your requests—So you don't have to.
7776

7877
## Table of Contents
7978

79+
- [**Installation**](#installation)
8080
- [**Getting an API Key**](#getting-an-api-key)
8181
- [**Quickstart**](#quickstart)
8282
- [**Special Features**](#special-features)
@@ -90,6 +90,16 @@ And, there's also more!
9090
- [**FAQ**](#faq)
9191
- [**Contributors**](#contributors)
9292

93+
## Installation
94+
95+
Install with the following command, or the command for your favorite package manager.
96+
97+
```bash
98+
npm install gemini-ai
99+
```
100+
101+
Gemini AI is a pure ES6 Module, which means you will have to use it with `import`. It is recommended that your project is also ES6, but [look in the FAQ]() for a CJS (`require()`) workaround.
102+
93103
## Getting an API Key
94104

95105
1. Go to [Google AI Studio's API keys tab](https://aistudio.google.com/app/apikey)
@@ -505,7 +515,7 @@ await gemini.ask([
505515

506516
Learn more in the [dedicated section](#uploading-media).
507517

508-
### What do I need to do for v2?
518+
### What do I need to change for v2?
509519

510520
> Does everything still work?
511521
@@ -567,5 +577,17 @@ const gemini = new Gemini(API_KEY, {
567577
});
568578
```
569579

580+
### How to use Gemini AI in a CJS environment
581+
582+
> I got `Error [ERR_REQUIRE_ESM]: require() of ES Module`, what can I do?
583+
584+
Gemini AI is a ESM (`import`) only module. It is recommended that you use ESM in your projects too. However, if you must use CJS, you can use dynamic imports. Here's an example:
585+
586+
```javascript
587+
import("gemini-ai").then((Gemini) => {
588+
let gemini = new Gemini(API_KEY);
589+
});
590+
```
591+
570592
<h2 align="center" id="contributors">Contributors</h2>
571593
<p align="center">A special shoutout to developers of and contributors to the <a href="https://github.com/EvanZhouDev/bard-ai"><code>bard-ai</code></a> and <a href="https://github.com/EvanZhouDev/palm-api"><code>palm-api</code></a> libraries. Gemini AI's interface is heavily based on what we have developed on these two projects.</p>

‎README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@
1515
<a href="https://github.com/EvanZhouDev/gemini-ai?tab=readme-ov-file#documentation">Docs</a> | <a href="https://github.com/evanzhoudev/gemini-ai">GitHub</a> | <a href="https://github.com/EvanZhouDev/gemini-ai?tab=readme-ov-file#faq">FAQ</a>
1616
</p>
1717

18-
## Quickstart
18+
## Installation
19+
20+
Install with the following command, or the command for your favorite package manager.
1921

22+
```bash
23+
npm install gemini-ai
24+
```
25+
26+
## Quickstart
2027

2128
Make a text request:
2229

@@ -56,6 +63,7 @@ Read the full docs at https://github.com/EvanZhouDev/gemini-ai.
5663

5764
#### Table of Contents
5865

66+
- [**Installation**](https://github.com/EvanZhouDev/gemini-ai?tab=readme-ov-file#installation)
5967
- [**Getting an API Key**](https://github.com/EvanZhouDev/gemini-ai?tab=readme-ov-file#getting-an-api-key)
6068
- [**Quickstart**](https://github.com/EvanZhouDev/gemini-ai?tab=readme-ov-file#quickstart)
6169
- [**Special Features**](https://github.com/EvanZhouDev/gemini-ai?tab=readme-ov-file#special-features)

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-ai",
33
"version": "2.0.0",
44
"author": "EvanZhouDev",
5-
"description": "The easiest way to use the powerful Google Gemini model.",
5+
"description": "The simpler JavaScript Gemini SDK",
66
"license": "GPL-3.0",
77
"repository": {
88
"type": "git",

0 commit comments

Comments
 (0)