{"id":26772305,"url":"https://github.com/AgoraIO/openai-realtime-python","last_synced_at":"2025-03-29T01:01:51.003Z","repository":{"id":260015392,"uuid":"866697207","full_name":"AgoraIO/openai-realtime-python","owner":"AgoraIO","description":"Real-time voice agent powered by Agora and OpenAI","archived":false,"fork":false,"pushed_at":"2024-12-26T02:53:56.000Z","size":369,"stargazers_count":74,"open_issues_count":7,"forks_count":34,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-23T04:05:43.748Z","etag":null,"topics":["agent","agora","audio","conversational-ai","interactive-ai","openai","reatime","rte"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AgoraIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-02T18:03:19.000Z","updated_at":"2025-03-12T22:23:48.000Z","dependencies_parsed_at":"2024-10-29T04:25:25.586Z","dependency_job_id":"d0fd2637-a652-4527-92e9-8ef24c66a846","html_url":"https://github.com/AgoraIO/openai-realtime-python","commit_stats":null,"previous_names":["agoraio/openai-realtime-python"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgoraIO%2Fopenai-realtime-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgoraIO%2Fopenai-realtime-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgoraIO%2Fopenai-realtime-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgoraIO%2Fopenai-realtime-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgoraIO","download_url":"https://codeload.github.com/AgoraIO/openai-realtime-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246122358,"owners_count":20726823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","agora","audio","conversational-ai","interactive-ai","openai","reatime","rte"],"created_at":"2025-03-29T01:00:53.542Z","updated_at":"2025-03-29T01:01:50.940Z","avatar_url":"https://github.com/AgoraIO.png","language":"Python","funding_links":[],"categories":["API Examples"],"sub_categories":["OpenAI Partnership Project"],"readme":"# Realtime Agent\n\nThis project demonstrates how to deliver ultra-low latency access to OpenAI with exceptional audio quality using Agora's SD-RTN and OpenAI's Realtime API. By integrating Agora's SDK with OpenAI's Realtime API, it ensures seamless performance and minimal delay across the globe.\n\n## Prerequisites\n\nBefore running the demo, ensure you have the following installed and configured:\n\n- Python 3.11 or above\n\n- Agora account:\n\n  - [Login to Agora](https://console.agora.io/en/)\n  - Create a [New Project](https://console.agora.io/projects), using `Secured mode: APP ID + Token` to obtain an App ID and App Certificate.\n\n- OpenAI account:\n\n  - [Login to OpenAI](https://platform.openai.com/signup)\n  - Go to Dashboard and [obtain your API key](https://platform.openai.com/api-keys).\n\n- Additional Packages:\n\n  - On macOS:\n    ```bash\n    brew install ffmpeg portaudio\n    ```\n  - On Ubuntu (verified on versions 22.04 \u0026 24.04):\n    ```bash\n    sudo apt install portaudio19-dev python3-dev build-essential\n    sudo apt install ffmpeg\n    ```\n\n## Network Architecture\n\n\u003c!-- \u003cimg src=\"./architecture.png\" alt=\"architecture\" width=\"700\" height=\"400\" /\u003e --\u003e\n\u003cpicture\u003e\n  \u003csource srcset=\"architecture-dark-theme.png\" media=\"(prefers-color-scheme: dark)\"\u003e\n  \u003cimg src=\"architecture-light-theme.png\" alt=\"Architecture diagram of Conversational Ai by Agora and OpenAi\"\u003e\n\u003c/picture\u003e\n\n## Organization of this Repo\n\n- `realtimeAgent/realtime` contains the Python implementation for interacting with the Realtime API.\n- `realtimeAgent/agent.py` includes a demo agent that leverages the `realtime` module and the [agora-realtime-ai-api](https://pypi.org/project/agora-realtime-ai-api/) package to build a simple application.\n- `realtimeAgent/main.py` provides a web server that allows clients to start and stop AI-driven agents.\n\n## Run the Demo\n\n### Setup and run the backend\n\n1. Create a `.env` file for the backend. Copy `.env.example` to `.env` in the root of the repo and fill in the required values:\n   ```bash\n   cp .env.example .env\n   ```\n1. Create a virtual environment:\n   ```bash\n   python3 -m venv venv \u0026\u0026 source venv/bin/activate\n   ```\n1. Install the required dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n1. Run the demo agent:\n   ```bash\n   python -m realtime_agent.main agent --channel_name=\u003cchannel_name\u003e --uid=\u003cagent_uid\u003e\n   ```\n\n### Start HTTP Server\n\n1. Run the http server to start demo agent via restful service\n   ```bash\n   python -m realtime_agent.main server\n   ```\n   The server provides a simple layer for managing agent processes.\n\n### API Resources\n\n- [POST /start](#post-start)\n- [POST /stop](#post-stop)\n\n### POST /start\n\nThis api starts an agent with given graph and override properties. The started agent will join into the specified channel, and subscribe to the uid which your browser/device's rtc use to join.\n\n| Param        | Description                                                                                                                                                            |\n| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| channel_name | (string) channel name, it needs to be the same with the one your browser/device joins, agent needs to stay with your browser/device in the same channel to communicate |\n| uid          | (int)the uid which ai agent use to join                                                                                                                                |\n| system_instruction    | The system instruction for the agent                                                                                                                          |\n| voice        | The voice of the agent                                                                                                                                                 |\n\nExample:\n\n```bash\ncurl 'http://localhost:8080/start_agent' \\\n  -H 'Content-Type: application/json' \\\n  --data-raw '{\n    \"channel_name\": \"test\",\n    \"uid\": 123\n  }'\n```\n\n### POST /stop\n\nThis api stops the agent you started\n\n| Param        | Description                                                |\n| ------------ | ---------------------------------------------------------- |\n| channel_name | (string) channel name, the one you used to start the agent |\n\nExample:\n\n```bash\ncurl 'http://localhost:8080/stop_agent' \\\n  -H 'Content-Type: application/json' \\\n  --data-raw '{\n    \"channel_name\": \"test\"\n  }'\n```\n\n### Front-End for Testing\n\nTo test agents, use Agora's [Voice Call Demo](https://webdemo.agora.io/basicVoiceCall/index.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAgoraIO%2Fopenai-realtime-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAgoraIO%2Fopenai-realtime-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAgoraIO%2Fopenai-realtime-python/lists"}