Search
Code4,004
<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" },import axios from "npm:axios";const secret = Deno.env.get("OPENAI_API_KEY");const model = "text-embedding-ada-002";async function embed(text: string) { const response = await axios.post( "https://api.openai.com/v1/embeddings", { model, input: text }, {// Simple HTTP val to test OpenAI Responses API (gpt-5-nano)import { OpenAI } from "npm:openai";const apiKey = Deno.env.get("OPENAI_API_KEY");if (!apiKey) { throw new Error("Missing OPENAI_API_KEY");}const openai = new OpenAI({ apiKey });const MODEL = "gpt-5-nano";const POLL_DELAY_MS = 1200; <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>OpenAI Responses Test</title> <style> body { font-family: system-ui, sans-serif; margin: 32px; } </head> <body> <h1>OpenAI Responses Test</h1> <div class="row"> <button id="run">Run</button> }); let response = await openai.responses.create({ model: MODEL, input: [ polls += 1; await new Promise((resolve) => setTimeout(resolve, POLL_DELAY_MS)); response = await openai.responses.retrieve(response.id); if (response.status === "completed") { break;// Simple HTTP val to test OpenAI Responses API (gpt-5-nano)import { OpenAI } from "https://esm.sh/openai@6.15.0";const apiKey = Deno.env.get("OPENAI_API_KEY");if (!apiKey) { throw new Error("Missing OPENAI_API_KEY");}const openai = new OpenAI({ apiKey });const MODEL = "gpt-5-nano";const POLL_DELAY_MS = 1200; <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>OpenAI Responses Test</title> <style> body { font-family: system-ui, sans-serif; margin: 32px; } </head> <body> <h1>OpenAI Responses Test</h1> <div class="row"> <button id="run">Run</button> }); let response = await openai.responses.create({ model: MODEL, input: [ polls += 1; await new Promise((resolve) => setTimeout(resolve, POLL_DELAY_MS)); response = await openai.responses.retrieve(response.id); if (response.status === "completed") { break;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" }, const defaultURLs: Record<AIProvider, string> = { openrouter: "https://openrouter.ai/api/v1", groq: "https://api.groq.com/openai/v1", straico: "https://api.straico.com/v1", };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" },## Features- **Multi-Model Comparison**: Compare responses from OpenAI, Anthropic, and Google models side-by-side- **Real-Time Streaming**: Watch responses stream in as they're generated- **Configurable Parameters**: Adjust temperature and max tokens per model## Supported Models### OpenAI- GPT-5.2- o3 (Reasoning)| Key | Description ||-----|-------------|| `OPENAI_API_KEY` | Your OpenAI API key || `ANTHROPIC_API_KEY` | Your Anthropic API key || `GOOGLE_GENERATIVE_AI_API_KEY` | Your Google AI API key | inputPlaceholder: "Enter your prompt to compare responses...", defaultColumns: [ { provider: "openai", model: "gpt-5.2" }, { provider: "anthropic", model: "claude-opus-4-5-20251101" }, { provider: "google", model: "gemini-3-pro-preview" },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