Welcome to the Gemini Text Generator App! This project demonstrates how to build and deploy a Node.js application that interfaces with the Google Gemini API to generate text based on user input. Follow the steps below to set up and run your own instance of this application.
gemini-image2.png gemini-image1.png
Before you begin, make sure you have the following installed:
- Node.js (LTS version)
- npm (usually comes with Node.js)
- A Google Cloud account to access Gemini API
- Visit Google Cloud Console.
- Create a new project or select an existing one.
- Navigate to "APIs & Services > Credentials".
- Click on "Create Credentials" and select "API key". Follow the instructions to create your API key.
- Once you have your API key, restrict it to the Gemini API to enhance security.
Clone this repository to your local machine:
git clone https://yourrepositoryurl.com/path/to/gemini-app.git
cd gemini-app
Install the required npm packages by running the following command in the root directory of your project:
npm install express dotenv node-fetch
This will install:
express
: A web application framework for Node.js.dotenv
: A module to load environment variables from a.env
file.node-fetch
: A module to allow usingfetch
in Node.js for making API calls.
Create a .env
file in the root directory and add your API key:
API_KEY=your_api_key_here
To run the server, execute:
node server.mjs
The server will start, and you can access the app at http://localhost:3001
.
After launching the app, navigate to http://localhost:3001
in your web browser. You will see an interface where you can enter a text prompt. Upon submitting the prompt, the Gemini API generates and displays text based on your input.
For deployment, consider platforms like Heroku, DigitalOcean, or any other cloud service that supports Node.js.
- Set up an account on the chosen platform.
- Follow the platform's documentation to deploy your Node.js app.
- Ensure that your environment variables (like
API_KEY
) are correctly set up in your deployment environment.
Contributions to this project are welcome! Please fork the repository and submit a pull request with your enhancements.
This project is open-sourced under the MIT License. See the LICENSE file for more details.
Thank you for trying out the Gemini Text Generator App!
This README provides a detailed guide on setting up and running the application, ensuring users understand how to get everything running and where to place and update necessary configurations.