https://github.com/greathayat/google-gemini-live
A repository to learn the implementation of Google Gemini Live API for text and audio Chat.
https://github.com/greathayat/google-gemini-live
fastapi gemini gemini-api gemini-live gemini-realtime google-ai google-ai-studio google-gemini python reactjs websockets
Last synced: 7 months ago
JSON representation
A repository to learn the implementation of Google Gemini Live API for text and audio Chat.
- Host: GitHub
- URL: https://github.com/greathayat/google-gemini-live
- Owner: GreatHayat
- Created: 2025-03-27T23:50:45.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-28T00:20:00.000Z (7 months ago)
- Last Synced: 2025-03-28T01:24:28.066Z (7 months ago)
- Topics: fastapi, gemini, gemini-api, gemini-live, gemini-realtime, google-ai, google-ai-studio, google-gemini, python, reactjs, websockets
- Language: TypeScript
- Homepage:
- Size: 58.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🌟 Real-Time Gemini Live API Chat Application
This repository contains a **FastAPI backend** and a **ReactJS frontend** that enables **real-time chat** with Gemini AI, supporting both **text-based** and **text-to-audio** interactions.
---
## 🚀 Features✅ **Real-time Text Chat (`/`)** – Chat with Gemini AI via text.
✅ **Real-time Text-to-Audio Chat (`/audio-chat`)** – Receive AI-generated audio responses.
✅ **Streaming Audio Chunks** – Immediate audio playback as chunks arrive.
✅ **FastAPI Backend** – Handles WebSocket communication and integrates with Gemini API.
✅ **ReactJS Frontend** – A user-friendly interface for seamless AI interaction.---
## 📌 Prerequisites
- **Python 3.7+**
- **Node.js & npm (for React)**
- **A valid Gemini API Key**---
## 🛠 Setup Instructions
### 🔹 Backend (FastAPI)
1️⃣ **Clone the repository**
```bash
git clone
cd /backend
```2️⃣ **Create and activate a virtual environment**
```bash
python3 -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
```3️⃣ **Install dependencies**
```bash
pip install -r requirements.txt
```4️⃣ **Set the Gemini API Key**
```bash
export GEMINI_API_KEY="your_api_key" # macOS/Linux
set GEMINI_API_KEY="your_api_key" # Windows
```5️⃣ **Run the FastAPI server**
```bash
uvicorn main:app --reload --port 5001
```
📍 Backend will be available at **http://127.0.0.1:5001**.---
### 🔹 Frontend (ReactJS)
1️⃣ **Navigate to the frontend directory**
```bash
cd ../frontend
```2️⃣ **Install dependencies**
```bash
npm install
```3️⃣ **Run the React application**
```bash
npm run dev
```
📍 Frontend will be available at **http://localhost:5173**.---
## 🎯 How to Use
### **1️⃣ Start the backend & frontend**
Make sure both are running before testing.### **2️⃣ Open the app in your browser**
Visit `http://localhost:5173`.### **3️⃣ Choose a chat mode**
- **Text Chat (`/`)** – Type a message and send it.
- **Audio Chat (`/audio-chat`)** – Enter a message and receive AI-generated speech.---
## 🔑 Environment Variables
- **`GEMINI_API_KEY`** – Required to access the Gemini API.
---
## ⚠️ Important Notes
- Ensure your Gemini API key is **active** and has the correct **permissions**.
- Adjust WebSocket URLs in the React app if running the backend on a different host/port.
- Audio streaming relies on **AudioContext API** (ensure browser compatibility).
- In production, consider implementing **security & authentication**.---
## 💡 Contributing
Want to improve this project? **Pull requests are welcome!** 🚀
For issues or suggestions, feel free to open a discussion.