This README provides a quick setup guide for the Omi backend. For a comprehensive step-by-step guide with detailed explanations, please refer to the Backend Setup Documentation.
-
Install the google-cloud-sdk
- Mac:
brew install google-cloud-sdk
- Windows:
choco install gcloudsdk
- Nix envdir: It should be pre-installed
- Mac:
-
You will need to have your own Google Cloud Project with Firebase enabled. If you've already set up Firebase for the Omi app, you're good to go. If not, please refer to the Firebase Setup Guide.
- IMPORTANT: Make sure you have the
Cloud Resource Manager API
,Firebase Management API
, andCloud Firestore API
enabled in the Google Cloud API Console before proceeding to the next steps. Failure to enable these APIs will result in authentication errors.
- IMPORTANT: Make sure you have the
-
Run the following commands one by one to authenticate with Google Cloud:
gcloud auth login gcloud config set project <project-id> gcloud auth application-default login --project <project-id>
Replace
<project-id>
with your Google Cloud Project ID. This should generate theapplication_default_credentials.json
file in the~/.config/gcloud
directory. This file is read automatically by gcloud in Python. -
Install Python
- Mac:
brew install python
- Windows:
choco install python
- Nix envdir: It should be pre-installed
- Mac:
-
Install
pip
if it doesn't exist (follow instructions on pip installation page) -
Install
git
andffmpeg
- Mac:
brew install git ffmpeg
- Windows:
choco install git.install ffmpeg
- Nix envdir: These should be pre-installed
- Mac:
-
Install
opus
(required for audio processing)- Mac:
brew install opus
- Windows: You should already have it if you're on Windows 10 version 1903 and above
- Mac:
-
Move to the backend directory:
cd backend
-
Create your environment file:
cp .env.template .env
-
Set up Redis
- Upstash is recommended - sign up and create a free instance
-
Add the necessary API keys in the
.env
file:- OpenAI API Key
- Deepgram API Key
- Redis credentials from your Upstash Console
- Set
ADMIN_KEY
to a temporary value (e.g.,123
) for local development - IMPORTANT: For Pinecone vector database:
- Make sure to set
PINECONE_INDEX_NAME
to the name of your Pinecone index - If you don't have a Pinecone index yet, create one in the Pinecone Console
- The index should be created with the appropriate dimension setting (e.g., 1536 for OpenAI embeddings)
- Make sure to set
-
Install Python dependencies (choose one of the following approaches):
Option A: Using a virtual environment (recommended)
# Create a virtual environment python -m venv venv # Activate the virtual environment # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate # Install dependencies within the virtual environment pip install -r requirements.txt
You should see
(venv)
at the beginning of your command prompt when the virtual environment is active.Option B: Direct installation
# Install dependencies globally pip install -r requirements.txt
-
Sign up on ngrok and follow the steps to configure it
- During onboarding, get your authentication token and run
ngrok config add-authtoken <your-token>
- During onboarding, get your authentication token and run
-
During the onboarding flow, under the
Static Domain
section, Ngrok should provide you with a static domain and a command to point your localhost to that static domain. Replace the port from 80 to 8000 in that command and run it in your terminal:ngrok http --domain=example.ngrok-free.app 8000
-
Start the backend server:
uvicorn main:app --reload --env-file .env
-
Troubleshooting: If you get any error mentioning "no internet connection" while downloading models, add the following lines in the
utils/stt/vad.py
file after the import statements:import ssl ssl._create_default_https_context = ssl._create_unverified_context
-
Now try running the server again:
uvicorn main:app --reload --env-file .env
-
In your Omi app's environment, set
API_BASE_URL
to the URL provided by ngrok (e.g.,https://example.ngrok-free.app
) -
Your app should now be using your local backend
-
If you used a virtual environment, when you're done, deactivate it by running:
deactivate