Search
Code3,657
const NR_TYPE = "near_field";const INSTRUCTIONS = `  Greet the user in English and tell them that they're using the OpenAI Realtime API, powered by the {{model}} model.  Give them a very brief summary of the benefits of the Realtime API based on the headline below,  and then ask if they have any questions.  - higher audio quality  - improved handling of alphanumerics (eg, properly understanding credit card and phone numbers)  - support for the OpenAI Prompts API  - support for MCP-based tools  - auto-truncation to reduce context sizeconst 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 {const NR_TYPE = "near_field";const INSTRUCTIONS = `  Greet the user in English and tell them that they're using the OpenAI Realtime API, powered by the {{model}} model.  Give them a very brief summary of the benefits of the Realtime API based on the headline below,  and then ask if they have any questions.  - higher audio quality  - improved handling of alphanumerics (eg, properly understanding credit card and phone numbers)  - support for the OpenAI Prompts API  - support for MCP-based tools  - auto-truncation to reduce context sizeNote: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({  messages: [    { role: "user", content: "Say hello in a creative way" },Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({  messages: [    { role: "user", content: "Say hello in a creative way" },import { generateOpenGraphTags, OpenGraphData } from "https://esm.town/v/dthyresson/generateOpenGraphTags";import { ValTownLink } from "https://esm.town/v/dthyresson/viewOnValTownComponent";import { chat } from "https://esm.town/v/stevekrouse/openai";import * as fal from "npm:@fal-ai/serverless-client";    const { message, topic, position, sessionContext } = await req.json();        const apiKey = __secrets['OPENAI_API_KEY'];    if (!apiKey) {      return Response.json({ error: 'OpenAI API key not configured' }, { status: 500 });    }Be professional but challenging. Push them to think critically and defend their positions with sound legal reasoning. Ask follow-up questions when arguments are unclear or insufficiently supported.`;    // Call OpenAI API    const response = await fetch('https://api.openai.com/v1/chat/completions', {      method: 'POST',      headers: {    if (!response.ok) {      const error = await response.text();      console.error('OpenAI API error:', error);      return Response.json({ error: 'Failed to get AI response' }, { status: 500 });    }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