Search

4,002 results found for openai (6478ms)

Code
3,898

<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 = `
the user in English and tell them that they're using the OpenAI Realtime API, powered by the {{
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
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { 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 NR_TYPE = "near_field";
const INSTRUCTIONS = `
the user in English and tell them that they're using the OpenAI Realtime API, powered by the {{
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
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES ---
async function handleApiDispatch(req: Request): Promise<Response> {
try {
const openai = new OpenAI();
const body = await req.json();
}`;
const completion = await openai.chat.completions.create({
model: "gpt-4o", // Using a powerful model for complex logic
messages: [
volt/bms/main.ts
3 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES ---
if (req.method === "POST" && action === "getDispatchPlan") {
try {
const openai = new OpenAI();
const ctx = await req.json();
const userMessage = "Generate dispatch plan for: " + JSON.stringify(ctx);
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
import { OpenAI } from "https://esm.town/v/std/openai";
import { StoryOptions, generateCuteAnimalName } from "../../shared/types.ts";
const openai = new OpenAI();
export async function generateStory(options: StoryOptions): Promise<{ title: string; content: st
`;
// Generate the story using OpenAI
const completion = await openai.chat.completions.create({
messages: [
{ role: "system", content: "You are a creative children's storyteller who creates engaging
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { 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" },
volt/frfr/main.ts
5 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { Hono } from "npm:hono@4.4.12";
</button>
</form>
<p class="text-sm text-gray-500 mt-6">Powered by Val Town & OpenAI</p>
</div>
<div id="start-overlay" class="fixed inset-0 bg-gray-900/80 backdrop-blur-sm z-20 flex flex-
}
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.",
}
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
},
body: JSON.stringify({
if (!response.ok) {
throw new Error(`OpenAI API error: ${response.status}`);
}