Search
Code4,094
import { OpenAI } from "https://esm.town/v/std/openai";const enc = new TextEncoder(); const payload = await req.json(); const openai = new OpenAI({ // Strongly recommended: store as a Val Town secret, not in code. // apiKey: Deno.env.get("BASETEN_API_KEY")!, }; const openAIResponse = await openai.chat.completions.create(requestArgs); const stream = new ReadableStream<Uint8Array>({ try { for await ( const chunk of openAIResponse as unknown as AsyncIterable<any> ) { // Stop if the client disconnected RECENT_PAGES_LOOKBACK_HOURS: EnvVarConfig; CRONS_DISABLED: EnvVarConfig; OPENAI_API_KEY: EnvVarConfig; };} RECENT_PAGES_LOOKBACK_HOURS: EnvVarConfig; CRONS_DISABLED: EnvVarConfig; OPENAI_API_KEY: EnvVarConfig; };}const REALTIME_BASE_URL = "https://api.openai.com/v1/realtime";const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");if (!OPENAI_API_KEY) { throw new Error("π΄ OpenAI API key not configured");}export function makeHeaders(contentType?: string) { const obj: Record<string, string> = { Authorization: `Bearer ${OPENAI_API_KEY}`, }; if (contentType) obj["Content-Type"] = contentType;sip.post("/", async (c) => { // Verify the webhook. const OPENAI_SIGNING_SECRET = Deno.env.get("OPENAI_SIGNING_SECRET"); if (!OPENAI_SIGNING_SECRET) { console.error("π΄ webhook secret not configured"); return c.text("Internal error", 500); } const webhook = new Webhook(OPENAI_SIGNING_SECRET); const bodyStr = await c.req.text(); let callId: string | undefined;# hello-realtime**Hello Realtime** is a OpenAI Realtime app that supports both WebRTC and SIP(telephone) users. You can access the app via WebRTC at[hello-realtime.val.run](https://hello-realtime.val.run), or via SIP by callingserver-side websocket interface.If you remix the app, you'll just need to pop in your own `OPENAI_API_KEY` (from[platform.openai.com](https://platform.openai.com)), and if you want SIP, the`OPENAI_SIGNING_SECRET`.## Architecture - Browser connects to frontend - creates WebRTC offer - `/rtc` endpoint handles SDP negotiation with OpenAI - observer established to monitor session2. **SIP Flow**: <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>OpenAI Realtime API Voice Agent</title> <style> :root { RECENT_PAGES_LOOKBACK_HOURS: EnvVarConfig; CRONS_DISABLED: EnvVarConfig; OPENAI_API_KEY: EnvVarConfig; }; }; default: false }, OPENAI_API_KEY: { configured: !!Deno.env.get('OPENAI_API_KEY'), required: false, description: "OpenAI API key for AI features (falls back to Val Town shared key with rate limits)" } } RECENT_PAGES_LOOKBACK_HOURS: EnvVarConfig; CRONS_DISABLED: EnvVarConfig; OPENAI_API_KEY: EnvVarConfig; }; }; default: false }, OPENAI_API_KEY: { configured: !!Deno.env.get('OPENAI_API_KEY'), required: false, description: "OpenAI API key for AI features (falls back to Val Town shared key with rate limits)" } }const REALTIME_BASE_URL = "https://api.openai.com/v1/realtime";const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");if (!OPENAI_API_KEY) { throw new Error("π΄ OpenAI API key not configured");}export function makeHeaders(contentType?: string) { const obj: Record<string, string> = { Authorization: `Bearer ${OPENAI_API_KEY}`, }; if (contentType) obj["Content-Type"] = contentType;reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
/**
* Practical Implementation of Collective Content Intelligence
* Bridging advanced AI with collaborative content creation
*/
exp
kwhinnery_openai
lost1991
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
No docs found