Skip to main content

Overview

The Omi backend powers all AI capabilities including transcription, conversation processing, chat, and integrations. This guide will help you set up a local development environment.
If you just want to build apps or test features, you can use Omi’s development backend instead. See the App Setup Guide for the automatic setup option.

Video Walkthrough


Prerequisites

Before starting, gather these API keys and credentials:

Required Services

ServicePurposeGet Key
OpenAIAI language modelsGet Key
DeepgramSpeech-to-textGet Key
Redis (Upstash)Caching & sessionsGet Key
PineconeVector databaseGet Key
Hugging FaceVoice detectionGet Key

Optional Services

ServicePurposeGet Key
ModalServerless deploymentGet Key
GitHubFirmware updatesGet Key
Google MapsLocation featuresGet Key
TypesenseSearch functionalityGet Key
StripePayment processingGet Key
New to backend development? Install Homebrew (macOS/Linux) or Chocolatey (Windows) first - they make installing tools much easier.

1. Google Cloud & Firebase Setup

Install Google Cloud SDK

brew install google-cloud-sdk

Authenticate with Google Cloud

Run these commands in your terminal, replacing <project-id> with your Google Cloud project ID:
gcloud auth login
gcloud config set project <project-id>
gcloud auth application-default login --project <project-id>
This generates credentials at ~/.config/gcloud/application_default_credentials.json.

Copy Credentials to Backend

cp ~/.config/gcloud/application_default_credentials.json ./google-credentials.json

2. OAuth Authentication Setup

OAuth is required for user authentication. You need to configure both Google and Apple sign-in.
1

Create OAuth 2.0 Client

  1. Go to Google Cloud Console → Credentials
  2. Click Create CredentialsOAuth 2.0 Client ID
  3. Select Web application as the application type
  4. Set a name (e.g., “Omi Backend Auth”)
2

Configure Authorized Origins

Under Authorized JavaScript origins, add:
  • https://your-domain.com (production)
  • https://your-ngrok-domain.ngrok-free.app (local development)
3

Configure Redirect URIs

Under Authorized redirect URIs, add:
  • https://your-domain.com/v1/auth/callback/google
  • https://your-ngrok-domain.ngrok-free.app/v1/auth/callback/google
4

Save Credentials

Click Create and save your Client ID and Client Secret for the .env file.
5

Configure Consent Screen

Go to APIs & Services → OAuth consent screen:
  • Fill in required app information
  • Add your domain to Authorized domains
  • Add scopes: openid, email, profile

3. Backend Installation

Clone the Repository

git clone https://github.com/BasedHardware/Omi.git
cd Omi/backend

Install System Dependencies

brew install python git ffmpeg opus

Set Up Python Virtual Environment

Using a virtual environment is strongly recommended to avoid dependency conflicts.
# Create virtual environment (use Python 3.9-3.12)
python -m venv venv
source venv/bin/activate
You should see (venv) at the beginning of your command prompt.

Install Python Dependencies

pip install PyOgg
pip install -r requirements.txt

Create Environment File

cp .env.template .env
Edit .env and fill in your API keys (see Environment Variables below).

4. Optional Services

Skip this if you don’t need webhook functionality.
cd pusher
cp .env.template .env
Edit the .env file and set SERVICE_ACCOUNT_JSON to your Google credentials string.Start the service:
cd ..
uvicorn pusher.main:app --reload --env-file .env --port 8000
Optionally expose via Ngrok for external access.

5. Running the Backend

Set Up Ngrok Tunnel

Ngrok exposes your local backend to the internet so the Omi app can connect.
  1. Sign up at ngrok.com and install Ngrok
  2. Authenticate with your account
  3. Start the tunnel:
ngrok http --domain=your-domain.ngrok-free.app 8000
Note the public URL (e.g., https://your-domain.ngrok-free.app).

Start the Backend Server

uvicorn main:app --reload --env-file .env --port 8000
FlagPurpose
--reloadAuto-restart on code changes
--env-file .envLoad environment variables
--host 0.0.0.0Listen on all interfaces (optional)
--port 8000Port to listen on

Connect the Omi App

In your Omi app’s .dev.env file, set:
API_BASE_URL=https://your-domain.ngrok-free.app/
Don’t forget the trailing / in the URL!
Make sure your OAuth redirect URIs in Google Cloud Console and Apple Developer Console include your Ngrok URL.

When You're Done

Deactivate the virtual environment:
deactivate
To resume later, just activate the virtual environment again.

Troubleshooting

Add this to utils/stt/vad.py:
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
  • Double-check all API keys in your .env file
  • Ensure there are no trailing spaces or quotes around values
  • Verify keys are active and not expired
  • Ensure your Ngrok tunnel is running
  • Verify the URL is correctly set in the Omi app
  • Check that OAuth redirect URIs match your Ngrok URL
Try reinstalling dependencies:
pip install -r requirements.txt --upgrade --force-reinstall
  • On Windows, you may need to enable script execution: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  • Make sure you’re using Python 3.9-3.12

Environment Variables

Complete reference for all .env variables:
VariableDescription
OPENAI_API_KEYOpenAI API key for AI models
DEEPGRAM_API_KEYDeepgram API key for transcription
HUGGINGFACE_TOKENHugging Face token for voice detection models
REDIS_DB_HOSTRedis host address
REDIS_DB_PORTRedis port number
REDIS_DB_PASSWORDRedis password (blank if none)
PINECONE_API_KEYPinecone API key for vector database
PINECONE_INDEX_NAMEName of your Pinecone index
GOOGLE_APPLICATION_CREDENTIALSPath to google-credentials.json
ADMIN_KEYTemporary key for local dev (e.g., 123)
ENCRYPTION_SECRETAt least 32 bytes for encrypting user data
The ENCRYPTION_SECRET in .env.template is for development only. Generate a new secure key for production!

Code Formatting

We use black for code formatting with a line length of 120 characters.
pip install black
To auto-format on commit, install the pre-commit hook from the repository root:
ln -s -f ../../scripts/pre-commit .git/hooks/pre-commit


Need Help?