Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/image-url.jpg%20%22Image%20title%22?q=openai&page=124&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=openai

Returns an array of strings in format "username" or "username/projectName"

Found 3227 results for "openai"(6843ms)

ContentGenindex.ts5 matches

@Ermd33s•Updated 3 months ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4
29 }
30
31 const openai = new OpenAI();
32
33 const systemPrompt = `You're a creative content writer working with the Jeropay team on a social media campaign for the month of June. Based on the following topic, generate 5 short, catchy, and audience-friendly captions or content ideas. The tone should be helpful, positive, and aligned with young professionals and creatives. Avoid generic phrases, and focus on engaging hooks or action-oriented copy.`;
35 const userPrompt = `Topic: ${topic}\n\nCaptions:`;
36
37 const completion = await openai.chat.completions.create({
38 model: "gpt-4o-mini",
39 messages: [
64 }
65
66 const openai = new OpenAI();
67
68 const systemPrompt = `You're a creative content writer working with the Jeropay team on a social media campaign for the month of June. Based on the following topic, generate 5 short, catchy, and audience-friendly captions or content ideas. The tone should be helpful, positive, and aligned with young professionals and creatives. Avoid generic phrases, and focus on engaging hooks or action-oriented copy.`;
70 const userPrompt = `Topic: ${topic}\n\nCaptions:`;
71
72 const completion = await openai.chat.completions.create({
73 model: "gpt-4o-mini",
74 messages: [

openaiproxyREADME.md3 matches

@MM05•Updated 3 months ago
1# OpenAI Proxy
2
3This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai
4
5Migrated from folder: openai/openaiproxy

openaiproxymain.tsx8 matches

@MM05•Updated 3 months ago
1import { parseBearerString } from "https://esm.town/v/andreterron/parseBearerString";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { OpenAIUsage } from "https://esm.town/v/std/OpenAIUsage";
4import { RateLimit } from "npm:@rlimit/http";
5const client = new OpenAIUsage();
6
7const allowedPathnames = [
43
44 // Proxy the request
45 const url = new URL("." + pathname, "https://api.openai.com");
46 url.search = search;
47
48 const headers = new Headers(req.headers);
49 headers.set("Host", url.hostname);
50 headers.set("Authorization", `Bearer ${Deno.env.get("OPENAI_API_KEY")}`);
51 headers.set("OpenAI-Organization", Deno.env.get("OPENAI_API_ORG"));
52
53 const modifiedBody = await limitFreeModel(req, user);
64 });
65
66 const openAIRes = await fetch(url, {
67 method: req.method,
68 headers,
72
73 // Remove internal header
74 const res = new Response(openAIRes.body, openAIRes);
75 res.headers.delete("openai-organization");
76 return res;
77}

Valod.cursorrules4 matches

@tigrank•Updated 3 months ago
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },

untitled-4336main.tsx12 matches

@Get•Updated 3 months ago
2// This is your detailed system prompt that instructs the AI on how to identify crux points
3
4import { OpenAI } from "https://esm.town/v/std/openai";
5
6// and structure the output JSON.
802export default async function(req: Request) {
803 // --- Dynamic Imports ---
804 const { OpenAI } = await import("https://esm.town/v/std/openai"); // Updated import path
805 const { z } = await import("npm:zod"); // For input validation
806
807 // --- Helper Function: Call OpenAI API ---
808 async function callOpenAIForCrux(
809 openai: OpenAI, // Instance passed in
810 systemPrompt: string,
811 userMessage: string,
812 ): Promise<object | ErrorResponse> { // Returns parsed JSON object or an ErrorResponse
813 try {
814 const response = await openai.chat.completions.create({
815 model: "gpt-4o", // Or your preferred model
816 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
823 return JSON.parse(content) as CruxAnalysisResponse; // Assume it's the correct type
824 } catch (parseError) {
825 console.error("OpenAI JSON Parse Error:", parseError, "Raw Content:", content);
826 return { error: `AI response was not valid JSON. Raw: ${content.substring(0, 200)}...` };
827 }
828 } catch (error) {
829 console.error("OpenAI API call failed:", error);
830 return { error: "Error communicating with AI model.", details: error.message };
831 }
837 ): Promise<object | ErrorResponse>
838 {
839 const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); // Initialize with key
840
841 console.log(`Analyzing instruction: "${userInstruction}"`);
842 const result = await callOpenAIForCrux(openai, cruxSystemPrompt, userInstruction);
843 // Basic validation of the result structure (can be enhanced with Zod on server side too)
844 if ("error" in result) {
846 }
847 if (!result || typeof result !== "object" || !("original_instruction" in result) || !("crux_points" in result)) {
848 console.error("Invalid structure from OpenAI:", result);
849 return { error: "AI returned an unexpected data structure.", details: result };
850 }
896 return new Response(JSON.stringify(cruxDataOrError), {
897 status: (cruxDataOrError.error.includes("Server configuration error")
898 || cruxDataOrError.error.includes("OpenAI API Key"))
899 ? 500
900 : 400, // Internal or Bad Request

VA-TASK-BRAINindex.ts4 matches

@aishatyy•Updated 3 months ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import type { TaskAnalysis, AnalyzeRequest } from "../shared/types.ts";
11});
12
13const openai = new OpenAI();
14
15// Serve static files
63}`;
64
65 const completion = await openai.chat.completions.create({
66 messages: [
67 { role: "system", content: "You are a helpful virtual assistant consultant who provides clear, actionable advice. Always respond with valid JSON only." },
76 const responseText = completion.choices[0]?.message?.content;
77 if (!responseText) {
78 throw new Error("No response from OpenAI");
79 }
80

ValTownForNotionai-engine.ts4 matches

@canstralian•Updated 3 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import {
3 CodeReviewRequest,
10
11export class AIReviewEngine {
12 private openai: OpenAI;
13
14 constructor() {
15 this.openai = new OpenAI();
16 }
17
25
26 try {
27 const completion = await this.openai.chat.completions.create({
28 model: "gpt-4o-mini",
29 messages: [

Towniesystem_prompt.txt4 matches

@stevekrouse•Updated 3 months ago
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },

Townie.cursorrules4 matches

@stevekrouse•Updated 3 months ago
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },

stevensDemo.cursorrules4 matches

@nacho•Updated 3 months ago
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },

openai-usage1 file match

@nbbaier•Updated 19 hours ago

hello-realtime5 file matches

@jubertioai•Updated 3 days ago
Sample app for the OpenAI Realtime API
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