Use the terminal to interact with Google's Gemini AI.
- Runs on Windows, Mac, and Linux
- Test command
npm run test
- Gemini will tell you a joke and explain it- The jokes are rarely funny, while the explanations often are
- Chat command
npm run chat
- Activates the interactive chat prompt- Use cases: Ask a question, code review/help, write an article, research
- Type 'exit' to quit, or press CTRL/CMD+C
- Image command
npm run img
- Activates the image query and text prompt- Use cases: Captioning an image, identifying what an image is, or what's in an image
- Add images (jpg, png, gif) to the /images/ directory, then select image(s) when prompted
When any command above is first used a prompt with ask you for your Google AI Studio API key.
To skip this step manually create a .env
file, then add the API KEY variable with your Google AI Studio API Key.
API_KEY=your-api-key
TOKENS=500
TEMPERATURE=0.9
TOPP=0.95
TOPK=3
By default max tokens is set to 500, which is about 35,000 words.
A token is equivalent to about 4 characters. 100 tokens are about 60-80 English words.
- API Key from Google AI Studio
- Node.js version 20 and above
- Check Node.js version:
node --version
- Check Node.js version:
- Git * Optional but recommended
- Check Git version:
git --version
- Check Git version:
Do not share confidential or personal information with Gemini AI.
- Get an API Key from Google AI Studio
- Open a terminal
- Windows: Right-click the Start button and select:
Windows PowerShell
- Mac: Command + Space to open Spotlight search, type in
Terminal
and select - Linux: Press CTRL + ALT + T simultaneously
- Windows: Right-click the Start button and select:
- In the terminal change locations to store this project, such as
cd ~/Documents
- Optionally create a Projects directory instead of using the Documents directory
- Make the Projects directory:
mkdir ~/Projects
- Change directories into Projects:
cd ~/Projects
- Make the Projects directory:
- Optionally create a Projects directory instead of using the Documents directory
- 2 methods to setup the project
- Method 1 (with Git): Clone the project into the current directory
- Via HTTPS:
git clone https://github.com/ChrisWinters/gemini-chat.git
- Via SSH:
git clone [email protected]:ChrisWinters/gemini-chat.git
- Via CLI:
gh repo clone ChrisWinters/gemini-chat
- Via HTTPS:
- Method 2 (without Git): Use curl to quickly download the pre-packaged zip file into the current directory
- Windows terminal type:
curl
, press enter, then copy/paste the following Uri:https://github.com/ChrisWinters/gemini-chat/raw/main/gemini-chat.zip
- Mac/Linux terminal:
curl -c -O https://github.com/ChrisWinters/gemini-chat/raw/main/gemini-chat.zip
- Unzip the gemini-chat.zip file
- Windows terminal:
tar -xf gemini-chat.zip
- Mac terminal:
tar -xvf gemini-chat.zip
- Linux terminal:
tar -xzf gemini-chat.zip
- Windows terminal:
- Delete the zip file:
rm gemini-chat.zip
- Windows terminal type:
- Method 1 (with Git): Clone the project into the current directory
- Change directories into the Gemini chat directory:
cd gemini-chat
- Install build packages:
npm install
- Run any of the commands
Personal Gemini Chat is now ready to use.
Command | Script | Description |
---|---|---|
npm install |
Install dependencies | |
npm run test |
node index.js --test |
Runs test prompt |
npm run chat |
node index.js --chat |
Runs interactive chat prompt |
npm run img |
node index.js --img |
Runs image query prompt |
- Get started with the Gemini API in Node.js applications
- Master the Gemini API: A Node.js tutorial with real examples
Use at your own risk. The Gemini Chat script comes with ABSOLUTELY NO WARRANTY, NO GUARANTEES, NO MERCHANTABILITY, AND NO FITNESS FOR A PARTICULAR PURPOSE.
Distributed under Apache 2.0 License