Search
Code3,977
import { OpenAI } from "https://esm.town/v/std/openai?v=4";// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ } const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: AI_CONFIG.model, temperature: AI_CONFIG.temperature,- **Auth env key**: `FATEBOOK_API_KEY`### With OpenAI Responses API```typescriptconst response = await openai.responses.create({ model: "gpt-4o-mini", input: "Create a prediction: Will I finish my project by Friday? 70% confident, resolve by 2024-12-20",- **URL**: `https://dicemcp.val.run`### With OpenAI Responses API```typescriptconst response = await openai.responses.create({ model: "gpt-4o-mini", input: "Roll 3 dice for me",## Quick Start1. **Add your OpenAI API key** in Environment Variables: - Key: `OPENAI_API_KEY` - Value: Your OpenAI API key2. **Open the app** and click "New Chat"This MCP server works with any MCP-compatible client:- **OpenAI Responses API** - Add as an MCP tool- **Claude Desktop** - Add to your MCP config- **MCP Chat** - Add via the settings UI### Example with OpenAI```typescriptconst response = await openai.responses.create({ model: "gpt-4o-mini", input: "Roll 3 dice for me",export function renderApp({ chats, servers, currentChat, messages }: AppProps) { const hasApiKey = !!Deno.env.get("OPENAI_API_KEY"); return ( {!hasApiKey && ( <div class="bg-amber-50 border-b border-amber-200 px-4 py-2 text-sm text-amber-800"> ⚠️ Add <code class="bg-amber-100 px-1 rounded">OPENAI_API_KEY</code> in Environment Variables to enable chat </div> )}import { Hono } from "npm:hono@4";import OpenAI from "npm:openai";import { createChat, } const apiKey = Deno.env.get("OPENAI_API_KEY"); if (!apiKey) { return c.json({ error: "Add OPENAI_API_KEY in Environment Variables" }, 503); } } // Call OpenAI const openai = new OpenAI({ apiKey }); try { const response = await openai.responses.create({ model: "gpt-4o-mini", input: conversationMessages, // Auto-title on first exchange if (history.length === 1) { const titleResponse = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [ return c.json({ reply }); } catch (err) { console.error("OpenAI error:", err); return c.json({ error: err instanceof Error ? err.message : "AI error" }, 500); }Configure the following variables in your environment: - `AGENT_API_KEY` (This is a secure token that you choose to secure the agent.tsx POST endpoint)- `OPENAI_API_KEY` (An OpenAI API Key)- `EXA_API_KEY` (Optional, though needed if you use the web search tool)import { anthropic } from "npm:@ai-sdk/anthropic";import { openai } from "npm:@ai-sdk/openai";import { generateText, streamText } from "npm:ai";import { getSystemPrompt } from "./prompt.tsx"; const maxSteps = 10; const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1"); const options = {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" },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