This tutorial shows you how to set up and run a React-based demo application for the Live API. The application features real-time audio and video streaming and uses a Python WebSocket proxy to handle secure authentication with Google Cloud.
The following diagram shows the structure of the project:
Before you begin
Ensure you have the following installed:
- Python 3.9 or later
pipgit
Set up the environment
To set up your local environment:
Clone the repository.
git clone https://github.com/GoogleCloudPlatform/generative-ai.git cd generative-ai/gemini/multimodal-live-api/native-audio-websocket-demo-apps/react-demo-appCreate and activate a Python virtual environment.
# Create the virtual environment python -m venv .venv # Activate the virtual environment in each new terminal # For macOS or Linux: source .venv/bin/activate # For Windows CMD: .venv\Scripts\activate.bat # For Windows PowerShell: .venv\Scripts\Activate.ps1Install the required Python dependencies.
pip install -r requirements.txtAuthenticate with Google Cloud.
gcloud auth application-default login
Run the application
After you set up the environment, run the application:
Start the Python proxy server.
python server.pyIn a new terminal, install the Node modules and start the React development server.
# Install Node modules npm install # Start development server npm run devOpen
http://localhost:5173in your browser to view the application.
What's next
- Get started with the Live API using the Google Gen AI SDK
- Get started with the Live API using WebSockets