Search

4,005 results found for openai (8765ms)

Code
3,901

"a cinematic portrait of a creator in a neon studio";
const apiKey = Deno.env.get("OPENAI_API_KEY");
if (!apiKey) {
return new Response("Missing OPENAI_API_KEY", { status: 500 });
}
const openaiRes = await fetch(
"https://api.openai.com/v1/images/generations",
{
method: "POST",
);
if (!openaiRes.ok) {
const text = await openaiRes.text();
console.error("OpenAI error:", text);
return new Response("OpenAI error", { status: 500 });
}
const data = await openaiRes.json();
const imageUrl = data.data?.[0]?.url;
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" },
try {
// VIOLATION 3: Using process.env instead of Deno.env
const apiKey = process.env.OPENAI_API_KEY;
// VIOLATION 4: No input validation
_2 or _3) to create a fresh table.
### 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" },
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" },
getActionIcon(actionType) {
if (actionType.includes("openai") || actionType.includes("call")) return "🤖";
if (actionType.includes("search") || actionType.includes("web")) return "🔍";
if (actionType.includes("human_input")) return "👤";
} else if (step.endpoint) {
this.log("INFO", stepComponent, \`Calling endpoint: \${step.endpoint}\`);
const isStreaming = (step.endpoint === "/api/tools/openai_call" || step.endpoint === "/api
const response = await fetch(new URL(step.endpoint, sourceApiUrl), {
method: 'POST',
_2 or _3) to create a fresh table.
### 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" },
      // --- CRITICAL: You MUST include EITHER 'action' OR 'endpoint' ---
      "action": "client:action_name", // Use for client tools (human_input, transform)
      "endpoint": "/api/tools/tool_name", // Use for backend tools (openai_call, http_fetch)
      // --- A step CANNOT have both or neither. ---
Every single step in the \`steps\` array **MUST** have exactly one of the following properties:
* \`"action"\`: Use this **only** for client-side tools listed in the manifest (e.g., \`"client:
backend tools listed in the manifest (e.g., \`"/api/tools/openai_call"\`, \`"/api/tools/http_fet
**A step will fail if it has NEITHER or BOTH.** The error you just saw (\`Step must have 'action
  "id": "process_data",
  "run_if": "this.check_for_error.apiFailed !== true",
  "endpoint": "/api/tools/openai_call",
  "inputs": { "messages": [...] },
  "outputs": { "summary": "payload.choices[0].message.content" }
This is how you create a draft, evaluate it, and then refine it.
1.  **'write_draft'**: (openai_call) -> outputs 'draft_text'
2.  **'evaluate_draft'**: (qa_evaluation)
    -   inputs: { "briefing": "...", "first_draft": "{{write_draft.draft_text}}" }
},
{
tool: "openai_call",
endpoint: "/api/tools/openai_call",
description:
"Calls an OpenAI model for analysis, generation, or extraction.",
inputs: {
messages: "array (e.g., [{role: 'user', content: '...'}])",
response_format: "object (optional, e.g., {type: 'json_object'})",
},
outputs: "payload (OpenAI completion object)",
},
{
stream: "boolean (optional, default false)",
},
outputs: "payload (OpenAI completion object or stream)",
},
// --- *** NEW YAHOO FINANCE TOOL DEFINITION *** ---
- **Blob Storage**: `import { blob } from "https://esm.town/v/std/blob"`
- **SQLite**: Use Drizzle ORM instead of raw SQL
- **OpenAI**: `import { OpenAI } from "https://esm.town/v/std/openai"`
- **Email**: `import { email } from "https://esm.town/v/std/email"`
- **Blob Storage**: `import { blob } from "https://esm.town/v/std/blob"`
- **SQLite**: Use Drizzle ORM instead of raw SQL
- **OpenAI**: `import { OpenAI } from "https://esm.town/v/std/openai"`
- **Email**: `import { email } from "https://esm.town/v/std/email"`