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=123&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"(3244ms)

Appindex.ts3 matches

@Yvnn24•Updated 3 months ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import { OpenAI } from "https://esm.town/v/std/openai";
4import type { AITextRequest, AITextResponse, MemeTemplate } from "../shared/types.ts";
5
80 try {
81 const request: AITextRequest = await c.req.json();
82 const openai = new OpenAI();
83
84 const prompt = `Generate funny meme text for a "${request.templateName}" meme template.
96Return ONLY a JSON object with "topText" and "bottomText" fields. No other text.`;
97
98 const completion = await openai.chat.completions.create({
99 messages: [
100 { role: "system", content: "You are a hilarious meme generator that creates viral-worthy meme text. Always respond with valid JSON only." },

AppREADME.md1 match

@Yvnn24•Updated 3 months ago
40- **Backend**: Hono (TypeScript API framework)
41- **Frontend**: React with TypeScript
42- **AI**: OpenAI GPT for funny text generation
43- **Styling**: TailwindCSS
44- **Canvas**: HTML5 Canvas for meme generation

Syphrose1990system_prompt.txt4 matches

@Syphrose1990•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" },

Syphrose1990.cursorrules4 matches

@Syphrose1990•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" },

Towniesystem_prompt.txt4 matches

@Syphrose1990•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

@Syphrose1990•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" },

untitled-7672main.tsx11 matches

@join•Updated 3 months ago
922export default async function(req: Request) {
923 // --- Dynamic Imports ---
924 const { OpenAI } = await import("https://esm.town/v/std/openai"); // Updated import path
925 const { z } = await import("npm:zod"); // For input validation
926
927 // --- Helper Function: Call OpenAI API ---
928 async function callOpenAIForCrux(
929 openai: OpenAI, // Instance passed in
930 systemPrompt: string,
931 userMessage: string,
932 ): Promise<object | ErrorResponse> { // Returns parsed JSON object or an ErrorResponse
933 try {
934 const response = await openai.chat.completions.create({
935 model: "gpt-4o", // Or your preferred model
936 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
943 return JSON.parse(content) as CruxAnalysisResponse; // Assume it's the correct type
944 } catch (parseError) {
945 console.error("OpenAI JSON Parse Error:", parseError, "Raw Content:", content);
946 return { error: `AI response was not valid JSON. Raw: ${content.substring(0, 200)}...` };
947 }
948 } catch (error) {
949 console.error("OpenAI API call failed:", error);
950 return { error: "Error communicating with AI model.", details: error.message };
951 }
956 userInstruction: string,
957 ): Promise<object | ErrorResponse> {
958 const openai = new OpenAI(); // Initialize with key
959
960 console.log(`Analyzing instruction: "${userInstruction}"`);
961 const result = await callOpenAIForCrux(openai, cruxSystemPrompt, userInstruction);
962 // Basic validation of the result structure (can be enhanced with Zod on server side too)
963 if ("error" in result) {
965 }
966 if (!result || typeof result !== "object" || !("original_instruction" in result) || !("crux_points" in result)) {
967 console.error("Invalid structure from OpenAI:", result);
968 return { error: "AI returned an unexpected data structure.", details: result };
969 }
1015 return new Response(JSON.stringify(cruxDataOrError), {
1016 status: (cruxDataOrError.error.includes("Server configuration error")
1017 || cruxDataOrError.error.includes("OpenAI API Key"))
1018 ? 500
1019 : 400, // Internal or Bad Request

ffffindex.ts4 matches

@hard•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 { PoemRequest, PoemResponse } from "../shared/types.ts";
30 }
31
32 const openai = new OpenAI();
33
34 // Create a detailed prompt for poem generation
45 Format your response as JSON with "title" and "poem" fields.`;
46
47 const completion = await openai.chat.completions.create({
48 messages: [
49 {
60 const content = completion.choices[0]?.message?.content;
61 if (!content) {
62 throw new Error("No response from OpenAI");
63 }
64

ffffREADME.md2 matches

@hard•Updated 3 months ago
5## Features
6
7- AI-powered poem generation using OpenAI
8- Subtle abstract art backgrounds that complement the text
9- Responsive design with elegant typography
28## Environment Variables
29
30- `OPENAI_API_KEY` - Required for poem generation

ContentGenREADME.md2 matches

@Ermd33s•Updated 3 months ago
1# Jeropay Social Media Caption Generator
2
3A beautiful web application that generates creative social media captions for the Jeropay team using OpenAI's GPT-4o-mini model.
4
5## Features
66
67- **Frontend**: React 18.2.0 with TypeScript
68- **Backend**: Hono framework with OpenAI integration
69- **Styling**: TailwindCSS with custom glass morphism effects
70- **AI Model**: GPT-4o-mini (free tier)

openai-usage1 file match

@nbbaier•Updated 17 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