Search

4,004 results found for openai (6209ms)

Code
3,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-ignore
import { 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-ignore
import { 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.",
volt/grasp/main.ts
4 matches
// @ts-ignore
import { 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-
<h1 class="text-4xl font-bold mb-4">✨ AI & Gesture Controlled Robotic Arm ✨</h1>
his demo uses your webcam for real-time hand tracking and OpenAI for autonomous control. Please
<button id="start-camera-btn" class="px-8 py-4 bg-pink-600 text-white font-bold rounded-
<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-video
Hello Realtime is a complete OpenAI Realtime application that supports WebRTC
users. You can access the app via WebRTC at
https://hello-realtime-video.val.run.
websocket interface.
If you remix the app, you'll just need to pop in your own OPENAI_API_KEY (from
platform.openai.com).