Gemini-API is a Node.js-based API utilizing the power of @google/generative-ai. This API is designed to address issues in countries where the original functionality might not be working.
Make sure you have Node.js installed. If not, you can download it here.
- Clone this repository:
git clone https://github.com/missnora07/Gemini-API.git
- Navigate to the project folder:
cd Gemini-API
- Install the required packages:
npm install axios express @google/generative-ai body-parser
- Run the API:
npm start
-
The API will be available at
http://localhost:3000
. -
Integrate the API into your project to leverage the generative capabilities provided by @google/generative-ai.
http://localhost:3000/gemini?prompt=Hello&api_key=your_key
const axios = require('axios');
const fs = require('fs').promises;
const apiUrl = "http://localhost:3000/";
const prompt = "Hello";
const filePath = "./image.jpeg";
const mimeType = "image/jpeg";
const api_key = "your_key";
(async () => {
try {
const imageData = await fs.readFile(filePath);
const base64Image = imageData.toString('base64');
const requestData = {
image: base64Image,
prompt: prompt,
mime_type: mimeType,
};
const response = await axios.post(apiUrl + 'gemini-vision', requestData, {
headers: {
'Content-Type': 'application/json',
'api_key': api_key,
},
});
console.log(response.data.text || "_Server down, Try again later_");
} catch (error) {
return console.error(error.response ? error.response.data : error.message);
}
})();
Make sure to replace your_key
with your actual API key.
(Currently only one image can process)
- Amruth
This project is licensed under the MIT License - see the LICENSE file for details.