GithubHelp home page GithubHelp logo

walkerwzy / google-gemini-svr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samson-shukla/google-gemini-ai

0.0 1.0 0.0 84 KB

Google's Gemini API on NodeJs

Home Page: https://google-gemini-svr.vercel.app

JavaScript 83.39% HTML 16.61%

google-gemini-svr's Introduction

Google Gemini API Node.js Server

This Node.js server is designed to consume Google's Gemini API, a powerful generative AI tool. It includes two primary functionalities:

  1. Text Generation from Text-Only Input

    • Model Name: gemini-pro
  2. Text Generation from Text-and-Image Input (Multimodal)

    • Model Name: gemini-pro-vision

Prerequisites

Before running the project, make sure you have the following:

  • Node.js version 18 and above installed.
  • Gemini API keys generated from Google AI Studio.

Getting Started

  1. Clone the Repository:

    git clone https://github.com/samson-shukla/google-gemini-ai.git
    cd google-gemini-ai
  2. Install Dependencies:

    npm install
  3. Configure Settings:

    • Create a .env file in the project root with the following environment variables:
    PORT=3000
    GEMINI_API_KEY=your_api_key
    • Adjust other settings in the server/config folder if needed.
  4. Run the Server:

    npm run start

Usage and Making API Calls

  • The server will be running at http://localhost:3000 by default.
  • Access the API endpoints by making a POST request at http://localhost:3000/chat-with-gemini
  • The request body must contain the following: - "modelType" (valid values are "text_only" and "text_and_image") - "prompt" as a string where you ask what you want to ask. - "imageParts" is an array of image URLs of the images you want to ask your prompt for.
  • For "text_only" model, modelType and prompt is required
  • For "text_and_image" model, modelType, prompt and imageParts is required

Request body example of "text_and_image" model

{
  "modelType": "text_only",
  "prompt": "What can you do for me?"
}

Request body example of "text_and_image" model

{
  "modelType": "text_and_image",
  "prompt": "What do you see in these images?",
  "imageParts": ["https://firstImage.jpg", "https://secondImage.png"]
}

Integration with Frontend

To implement the views, you can integrate any frontend library of your choice, such as ReactJs, Swelte, etc.

Feel free to enhance and customize the project to meet your specific needs. If you encounter any issues or have suggestions for improvements, please refer to the GitHub repository and open an issue.

Happy coding! ๐Ÿš€

google-gemini-svr's People

Contributors

samson-shukla avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.