Skip to content

Bandwidth-Samples/openai-realtime-sip-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bandwidth + OpenAI Realtime SIP Integration - Python

Bandwidth OpenAI Realtime SIP Integration Guide

Table of Contents

Description

This is a sample application that demonstrates how to use the Bandwidth Voice with OpenAI's Realtime SIP Interface to create a real-time AI-powered voice assistant.

Pre-Requisites

In order to integrate with OpenAI Realtime SIP, you must have the following:

  • A Bandwidth Universal Platform account. If you don't have one, please reach out to your Account Manager or contact us to get started.
  • An OpenAI account. If you don't have one, you can sign up here.

Environmental Variables

The sample app uses the below environmental variables.

OPENAI_API_KEY    # Your OpenAI API Key
REFER_TO          # The phone number to refer calls to
LOG_LEVEL         # The logging level you want.  Default is 'info'.  Other options are 'debug', 'warn', 'error'
LOCAL_PORT        # The port you want the app to run on.  Default is 3000

Running the Application

This application is built using Python 3.13. You can use pip to install the required packages, or Docker Compose to run the application.

To install the required packages and run the application, you can use either of the following methods:

# Using Docker Compose 
docker compose up --build
# Using Python
python -m venv .venv
source .venv/bin/activate
cd app
pip install -r requirements.txt
python main.py

Callback URLs

For a detailed introduction, check out our Bandwidth Product Specific Callbacks page.

Below are the callback paths:

  • /health - Health check endpoint
  • /webhooks/openai/realtime/call/inbound - Inbound call webhook endpoint

Ngrok

A simple way to set up a local callback URL for testing is to use the free tool ngrok.
After you have downloaded and installed ngrok run the following command to open a public tunnel to your port ($LOCAL_PORT)

ngrok http $LOCAL_PORT

You can view your public URL at http://127.0.0.1:4040 after ngrok is running. You can also view the status of the tunnel and requests/responses here.

About

openai-realtime-sip-python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •