Search
Code3,655
    <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 size  if (req.method === "POST" && url.pathname === "/moderate") {    try {      const { OpenAI } = await import("https://esm.town/v/std/openai");      const openai = new OpenAI();      const body = await req.json();      if (body.type === "text") {        const response = await openai.chat.completions.create({          model: "gpt-4o",          messages: [      } else if (body.type === "image") {        const base64 = body.content.split(",")[1];        const response = await openai.chat.completions.create({          model: "gpt-4o",          messages: [  if (req.method === "POST" && url.pathname === "/moderateDoc") {    try {      const { OpenAI } = await import("https://esm.town/v/std/openai");      const openai = new OpenAI();      const formData = await req.formData();      const file = formData.get("file") as File;      const text = await file.text(); // Extracts text for txt/doc/pdf (works if Val Town supports it)      const response = await openai.chat.completions.create({        model: "gpt-4o",        messages: [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" },
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" },// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// @ts-ignoreimport { blob } from "https://esm.town/v/std/blob?v=11";}const openai = new OpenAI();const INDEX_KEY = "forge_index";    }    const completion = await openai.chat.completions.create({      model: "gpt-4o",      messages: [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 process from "node:process";import { marked } from "npm:marked";import { OpenAI } from "npm:openai";function pm(...lines: string[]): string {  );  const client = new OpenAI({ apiKey: process.env.PERPLEXITY_API_KEY, baseURL: "https://api.perplexity.ai" });  const response = await client.chat.completions.create({    model: "sonar",import { OpenAI } from "https://esm.town/v/std/openai";export default async function(req: Request): Promise<Response> {    });  }  const openai = new OpenAI();  try {  }  const stream = await openai.chat.completions.create(body);  if (!body.stream) {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