Search
Code3,900
} const apiKey = __secrets['OPENAI_API_KEY']; if (!apiKey) { return Response.json( { error: 'OpenAI API key not configured' }, { status: 500 } ); } // Call OpenAI API to generate poem const openaiResponse = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { }); if (!openaiResponse.ok) { const error = await openaiResponse.text(); console.error('OpenAI API error:', error); return Response.json( { error: 'Failed to generate poem' }, } const data = await openaiResponse.json(); const poemContent = data.choices[0].message.content; // Generate a title based on the first line or keywords const titleResponse = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: {import { email } from "https://esm.town/v/std/email";import { extractValInfo } from "https://esm.town/v/stevekrouse/extractValInfo";import { OpenAI } from "npm:openai";function stripHtmlBackticks(html: string): string {export default async function(e: Email) { const openai = new OpenAI(); console.log(`from: ${e.from} to: ${e.to} subject: ${e.subject}, cc: ${e.cc}, bcc: ${e.bcc}`); } const summary = await openai.chat.completions.create({ messages: [ {- [SQLite: Store and retrieve structured data](/reference/std/sqlite)- [Blob: Store and retrieve any data](/reference/std/blob)- [OpenAI: Use the OpenAI API](/reference/std/openai)- [Email: Send emails](/reference/std/email) } const apiKey = __secrets['openai_api_key']; if (!apiKey) { return Response.json( { error: "OpenAI API key not configured" }, { status: 500 } ); } // Call OpenAI API to generate both poem and title in one request 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); // Provide more specific error messages// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";import { Hono } from "npm:hono@4.4.12"; // @ts-ignore const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } } catch (error) { console.error("OpenAI API Error:", error); return c.json({ error: "An error occurred while communicating with the AI designer.",// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";import { Hono } from "npm:hono@4.4.12"; // @ts-ignore const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } } catch (error) { console.error("OpenAI API Error:", error); return c.json({ error: "An error occurred while communicating with the AI designer.",// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- TYPE DEFINITIONS --- <div id="start-overlay" class="fixed inset-0 bg-gray-900/80 backdrop-blur-sm z-20 flex flex-col justify-center items-center text-center p-8"> <h1 class="text-4xl font-bold mb-4">✨ AI & Gesture Controlled Robotic Arm ✨</h1> <p class="text-lg text-gray-300 max-w-2xl mb-8">This demo uses your webcam for real-time hand tracking and OpenAI for autonomous control. Please grant camera permissions to begin.</p> <button id="start-camera-btn" class="px-8 py-4 bg-pink-600 text-white font-bold rounded-lg hover:bg-pink-700 transition-transform transform hover:scale-105 shadow-lg">Start Camera & Control</button> <p class="text-sm text-gray-500 mt-6">Powered by Val Town, Three.js & MediaPipe</p> if (req.method === "POST" && action === "choreograph") { try { const openai = new OpenAI(); const body = await req.json(); const goal = body.goal; ]; const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: messages,const VOICE = "marin";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; // Create the call. const url = "https://api.openai.com/v1/realtime/calls"; const headers = makeHeaders(); const fd = new FormData();# hello-realtime-videoHello Realtime is a complete OpenAI Realtime application that supports WebRTCusers. You can access the app via WebRTC athttps://hello-realtime-video.val.run.websocket interface.If you remix the app, you'll just need to pop in your own OPENAI_API_KEY (fromplatform.openai.com).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