9sip.post("/", async (c) => {
10 // Verify the webhook.
11 const OPENAI_SIGNING_SECRET = Deno.env.get("OPENAI_SIGNING_SECRET");
12 if (!OPENAI_SIGNING_SECRET) {
13 console.error("🔴 webhook secret not configured");
14 return c.text("Internal error", 500);
15 }
16 const webhook = new Webhook(OPENAI_SIGNING_SECRET);
17 const bodyStr = await c.req.text();
18 let callId: string | undefined;
1# hello-realtime
2
3**Hello Realtime** is a OpenAI Realtime app that supports both WebRTC and SIP
4(telephone) users. You can access the app via WebRTC at
5[hello-realtime.val.run](https://hello-realtime.val.run), or via SIP by calling
9server-side websocket interface.
10
11If you remix the app, you'll just need to pop in your own `OPENAI_API_KEY` (from
12[platform.openai.com](https://platform.openai.com)), and if you want SIP, the
13`OPENAI_SIGNING_SECRET`.
14
15## Architecture
18 - Browser connects to frontend
19 - creates WebRTC offer
20 - `/rtc` endpoint handles SDP negotiation with OpenAI
21 - observer established to monitor session
222. **SIP Flow**:
4 <meta charset="utf-8" />
5 <meta name="viewport" content="width=device-width, initial-scale=1" />
6 <title>OpenAI Realtime API Voice Agent</title>
7 <style>
8 :root {
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },
15 provider: "groq",
16 model: "qwen3-coder",
17 endpoint: "https://api.groq.com/openai/v1/chat/completions",
18 headers: {
19 "Authorization": `Bearer ${process.env.GROQ_API_KEY}`,
1import { blob } from "https://esm.town/v/std/blob?v=11";
2import { OpenAI } from "https://esm.town/v/std/openai?v=4";
3
4// --- TYPE DEFINITIONS ---
271 }
272
273 const openai = new OpenAI();
274 const completion = await openai.chat.completions.create({
275 model: "gpt-4o",
276 messages: [
57 provider: "groq",
58 model: "compound",
59 endpoint: "https://api.groq.com/openai/v1/chat/completions",
60 headers: {
61 "Authorization": `Bearer ${process.env.GROQ_API_KEY}`,
15 provider: "groq",
16 model: "qwen3-coder",
17 endpoint: "https://api.groq.com/openai/v1/chat/completions",
18 headers: {
19 "Authorization": `Bearer ${process.env.GROQ_API_KEY}`,
31 try {
32 response = await fetch(
33 "https://api.groq.com/openai/v1/chat/completions",
34 {
35 method: "POST",