惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tenable Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
L
LINUX DO - 热门话题
C
Cyber Attacks, Cyber Crime and Cyber Security
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
H
Hacker News: Front Page
C
Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Martin Fowler
Martin Fowler
Help Net Security
Help Net Security
Scott Helme
Scott Helme
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
Cloudbric
Cloudbric
Simon Willison's Weblog
Simon Willison's Weblog
A
Arctic Wolf
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
T
Tor Project blog
O
OpenAI News
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Exploit Database - CXSecurity.com
MyScale Blog
MyScale Blog
罗磊的独立博客
美团技术团队
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Apple Machine Learning Research
Apple Machine Learning Research
PCI Perspectives
PCI Perspectives
P
Privacy International News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Recorded Future
Recorded Future
Application and Cybersecurity Blog
Application and Cybersecurity Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Blog — PlanetScale
Blog — PlanetScale

OpenAI Developers

API deployment checklist | OpenAI API Sora 2 Prompting Guide Codex Prompting Guide Docs MCP | OpenAI Developers Gpt-image-1.5 Prompting Guide GPT-5.2 Prompting Guide Transcribing User Audio with a Separate Realtime Request Modernizing your Codebase with Codex GitHub - openai/openai-sora-sample-app: Sample app to get started using the Video API with Sora GitHub - openai/openai-apps-sdk-examples: Example apps for the Apps SDK GitHub - openai/openai-chatkit-advanced-samples: Starter app to build with OpenAI ChatKit SDK GitHub - openai/openai-chatkit-starter-app: Starter app to build with OpenAI ChatKit + Agent Builder Rate limits | OpenAI API Web search | OpenAI API Getting started with datasets | OpenAI API Prompt optimizer | OpenAI API Verifying gpt-oss implementations How to run gpt-oss locally with LM Studio Fine-tuning with gpt-oss and Hugging Face Transformers How to run gpt-oss locally with Ollama Function calling | OpenAI API Models | OpenAI API Reasoning best practices | OpenAI API Reasoning models | OpenAI API Background mode | OpenAI API Batch API | OpenAI API Conversation state | OpenAI API File search | OpenAI API Flex processing | OpenAI API MCP and Connectors | OpenAI API Code Interpreter | OpenAI API Quickstart - OpenAI Agents SDK Build Hour: Agentic Tool Calling Build Hour: Built-In Tools Reasoning best practices | OpenAI API Graders | OpenAI API Evaluation best practices | OpenAI API Working with evals | OpenAI API Guardrails - OpenAI Agents SDK Latency optimization | OpenAI API Optimizing LLM Accuracy | OpenAI API Agent orchestration - OpenAI Agents SDK Production best practices | OpenAI API Realtime transcription | OpenAI API Optimizing LLM Accuracy | OpenAI API Realtime and audio | OpenAI API Realtime conversations | OpenAI API Responses guide Migrate to the Responses API | OpenAI API Speech to text | OpenAI API Supervised fine-tuning | OpenAI API Tracing - OpenAI Agents SDK Vision fine-tuning | OpenAI API Audio and speech | OpenAI API GitHub - openai/openai-cs-agents-demo: Demo of a customer service use case implemented with the OpenAI Agents SDK Voice agents | OpenAI API Fine-tuning best practices | OpenAI API GitHub - openai/openai-agents-python: A lightweight, powerful framework for multi-agent workflows GitHub - openai/openai-agents-js: A lightweight, powerful framework for multi-agent workflows and voice agents Agents SDK | OpenAI API Using tools | OpenAI API Computer use | OpenAI API GitHub - openai/openai-cua-sample-app: Learn how to use CUA (our Computer Using Agent) via the API on multiple computer environments. GitHub - openai/openai-testing-agent-demo: Demo of a UI testing agent using the OpenAI CUA model and the Responses API. Model optimization | OpenAI API GitHub - openai/openai-fm: Code for openai.fm, a demo for the OpenAI Speech API Predicted Outputs | OpenAI API GitHub - openai/openai-realtime-console: React app for inspecting, building and debugging with the Realtime API Building Voice Agents GitHub - openai/openai-realtime-solar-system: Demo showing how to use the OpenAI Realtime API to navigate a 3D scene via tool calling Reinforcement fine-tuning | OpenAI API GitHub - openai/openai-responses-starter-app: Starter app to build with the OpenAI Responses API Structured model outputs | OpenAI API GitHub - openai/openai-structured-outputs-samples: Sample apps to help developers get started with Structured Outputs Voice agents | OpenAI API Model optimization | OpenAI API GitHub - openai/openai-realtime-agents: This is a simple demonstration of more advanced, agentic patterns built on top of the Realtime API. GitHub - openai/openai-support-agent-demo: Demo of a customer support agent interface using NextJS and the OpenAI Responses API with File Search Building Voice Agents Generate images with high input fidelity AI app development: Concept to production Model optimization Building agents Eval Driven System Design - From Prototype to Production Multi-Agent Portfolio Collaboration with OpenAI Agents SDK o3/o4-mini Function Calling Guide Exploring Model Graders for Reinforcement Fine-Tuning Guide to Using the Responses API Reinforcement Fine-Tuning for Conversational Reasoning with the OpenAI API Evals API Use-case - Responses Evaluation Comparing Speech-to-Text Methods with the OpenAI API Generate images with GPT Image Multi-Tool Orchestration with RAG approach using OpenAI Multi-Language One-Way Translation with the Realtime API Doing RAG on PDFs using File Search in the Responses API How to use the Usage API and Cost API to monitor your OpenAI usage Leveraging model distillation to fine-tune a model Orchestrating Agents: Routines and Handoffs Prompt Caching 101 Developing Hallucination Guardrails
GitHub - openai/openai-realtime-twilio-demo
2025-07-18 · via OpenAI Developers

OpenAI Realtime API with Twilio Quickstart

Combine OpenAI's Realtime API and Twilio's phone calling capability to build an AI calling assistant.

Screenshot 2024-12-18 at 4 59 30 PM

Quick Setup

Open three terminal windows:

Terminal Purpose Quick Reference (see below for more)
1 To run the webapp npm run dev
2 To run the websocket-server npm run dev
3 To run ngrok ngrok http 8081

Make sure all vars in webapp/.env and websocket-server/.env are set correctly. See full setup section for more.

Overview

This repo implements a phone calling assistant with the Realtime API and Twilio, and had two main parts: the webapp, and the websocket-server.

  1. webapp: NextJS app to serve as a frontend for call configuration and transcripts
  2. websocket-server: Express backend that handles connection from Twilio, connects it to the Realtime API, and forwards messages to the frontend
Screenshot 2024-12-20 at 10 32 40 AM

Twilio uses TwiML (a form of XML) to specify how to handle a phone call. When a call comes in we tell Twilio to start a bi-directional stream to our backend, where we forward messages between the call and the Realtime API. ({{WS_URL}} is replaced with our websocket endpoint.)

<!-- TwiML to start a bi-directional stream-->

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>Connected</Say>
  <Connect>
    <Stream url="{{WS_URL}}" />
  </Connect>
  <Say>Disconnected</Say>
</Response>

We use ngrok to make our server reachable by Twilio.

Life of a phone call

Setup

  1. We run ngrok to make our server reachable by Twilio
  2. We set the Twilio webhook to our ngrok address
  3. Frontend connects to the backend (wss://[your_backend]/logs), ready for a call

Call

  1. Call is placed to Twilio-managed number
  2. Twilio queries the webhook (http://[your_backend]/twiml) for TwiML instructions
  3. Twilio opens a bi-directional stream to the backend (wss://[your_backend]/call)
  4. The backend connects to the Realtime API, and starts forwarding messages:
    • between Twilio and the Realtime API
    • between the frontend and the Realtime API

Function Calling

This demo mocks out function calls so you can provide sample responses. In reality you could handle the function call, execute some code, and then supply the response back to the model.

Full Setup

  1. Make sure your auth & env is configured correctly.

  2. Run webapp.

cd webapp
npm install
npm run dev
  1. Run websocket server.
cd websocket-server
npm install
npm run dev

Detailed Auth & Env

OpenAI & Twilio

Set your credentials in webapp/.env and websocket-server - see webapp/.env.example and websocket-server.env.example for reference.

Ngrok

Twilio needs to be able to reach your websocket server. If you're running it locally, your ports are inaccessible by default. ngrok can make them temporarily accessible.

We have set the websocket-server to run on port 8081 by default, so that is the port we will be forwarding.

Make note of the Forwarding URL. (e.g. https://54c5-35-170-32-42.ngrok-free.app)

Websocket URL

Your server should now be accessible at the Forwarding URL when run, so set the PUBLIC_URL in websocket-server/.env. See websocket-server/.env.example for reference.

Additional Notes

This repo isn't polished, and the security practices leave some to be desired. Please only use this as reference, and make sure to audit your app with security and engineering before deploying!