Search
Code3,285
```### OpenAI Integration```typescriptimport { 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" }],model: "gpt-4o-mini",
<library>## OpenAIVal Town includes a free, proxied 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" },```OpenAI only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:`const { OpenAI } = await import "https://esm.town/v/std/openai");`</library>
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 "npm:openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({messages: [{ role: "user", content: "Say hello in a creative way" },
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" },
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 = {
export default async function server(request) { const { OpenAI } = await import("https://esm.town/v/std/openai"); const corsHeaders = { "Access-Control-Allow-Origin": "*", if (request.method === "POST" && new URL(request.url).pathname === "/grade-card") { try { const openai = new OpenAI(); const { frontImageBase64, backImageBase64 } = await request.json();`; const response = await openai.chat.completions.create({ model: modelChoice, response_format: { type: "json_object" }, const jsonString = response.choices[0]?.message?.content; if (!jsonString) { throw new Error("OpenAI returned an empty response."); }
import { OpenAI } from "https://esm.town/v/std/openai";import { PDFExtract } from "npm:pdf.js-extract"; const action = url.searchParams.get("action"); const sourceUrl = `https://${url.hostname}${url.pathname}`; const openai = new OpenAI(); const MAX_TEXT_ANALYZE = 30000; const jsonResponse = (body: object, status: number) => async function callAI(prompt: string, userMessage: string, isJson: boolean = true) { const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: prompt }, { role: "user", content: userMessage }], conversation.unshift(contextMessage); } const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [systemMessage, ...conversation],
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" },
import { END, MemorySaver, MessagesAnnotation, START, StateGraph } from "https://esm.sh/@langchain/langgraph@0.3.3";import { ToolNode } from "https://esm.sh/@langchain/langgraph@0.3.3/prebuilt";import { ChatOpenAI } from "https://esm.sh/@langchain/openai@0.5.11";import { globalRateLimitingTool } from "https://esm.town/v/cricks_unmixed4u/openai-client/langchain.tsx";import { sqlite } from "https://esm.town/v/stevekrouse/sqlite?v=13"; // Initialize LangChain components const chatModel = new ChatOpenAI({ modelName: "gpt-4o-mini", temperature: 0.7,
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