Coder Social home page Coder Social logo

machalvl99 / gemini-api-quickstart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from logankilpatrick/gemini-api-quickstart

1.0 0.0 0.0 126 KB

Get up and running in under 5 minutes with the Google AI Gemini API (in Python)

Home Page: https://ai.google.dev/gemini-api/docs

License: MIT License

Python 15.42% CSS 37.38% HTML 47.20%

gemini-api-quickstart's Introduction

Gemini API Quickstart - Python

This repository contains a simple Python Flask App running with the Google AI Gemini API, designed to get you started building with Gemini's multi-modal capabilities. The app comes with a basic UI and a Flask backend.

Screenshot 2024-05-07 at 7 42 28 AM

Basic request

To send your first API request with the Gemini API Python SDK, make sure you have the right dependencies installed (see installation steps below) and then run the following code:

import google.generativeai as genai
genai.configure(api_key=GOOGLE_API_KEY)
model = genai.GenerativeModel('gemini-pro')

chat = model.start_chat(history=[])
response = chat.send_message("In one sentence, explain how AI works to a child.")
# Note that the chat object is temporarily stateful, as you send messages and get responses, you can 
# see the history changing by doing `chat.history`.

print(response.text)

Setup

  1. If you don’t have Python installed, install it from Python.org.

  2. Clone this repository.

  3. Create a new virtual environment:

    • macOS:

      $ python -m venv venv
      $ . venv/bin/activate
    • Windows:

      > python -m venv venv
      > .\venv\Scripts\activate
  4. Install the requirements:

    $ pip install -r requirements.txt
  5. Make a copy of the example environment variables file:

    $ cp .env.example .env
  6. Add your API key to the newly created .env file.

  7. Run the app:

$ flask run

You should now be able to access the app from your browser at the following URL: http://localhost:5000!

Attribution

This repo includes code that was forked from another repo I made, under an MIT license.

gemini-api-quickstart's People

Contributors

logankilpatrick avatar

Stargazers

 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.