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%22Optional%20title%22?q=openai&page=19&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 1771 results for "openai"(695ms)

stevensDemo.cursorrules4 matches

@ytaneja•Updated 1 week 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" },

stevensDemo.cursorrules4 matches

@cduke•Updated 1 week 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" },

translateToEnglishWithOpenAImain.tsx4 matches

@shlmt•Updated 1 week ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function translateToEnglishWithOpenAI(text: string) {
4 const openai = new OpenAI();
5 const completion = await openai.chat.completions.create({
6 messages: [
7 {

confidentWhiteOxmain.tsx3 matches

@orguetta•Updated 1 week ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3const openai = new OpenAI();
4
5const completion = await openai.chat.completions.create({
6 messages: [
7 {

Towniesystem_prompt.txt4 matches

@pomdtr•Updated 1 week 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" },

HHGtoMyDay.cursorrules4 matches

@lm3m•Updated 1 week 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-2512new-file-9861.tsx11 matches

@Get•Updated 1 week ago
11 * and also to upload new resources.
12 * * It utilizes the LLM-Safe Fork of @std/sqlite (adjust import if necessary).
13 * Assumes 'openai' secret is set in Val Town environment variables.
14 * * Last Updated: 2025-05-08 (SQLite refactor, Glassmorphic UI, and Upload Form)
15 */
625export default async function(req: Request) {
626 // --- Dynamic Imports (Inside Handler for Val Town) ---
627 const { OpenAI } = await import("https://esm.town/v/std/openai");
628 const val_fetch = (await import("https://esm.town/v/std/fetch")).fetch;
629 const { PDFExtract } = await import("npm:pdf.js-extract");
653 }
654
655 // --- Helper Function: Call OpenAI API ---
656 async function callOpenAI(
657 openai: OpenAI,
658 systemPrompt: string,
659 userMessage: string,
662 ): Promise<{ role: "assistant" | "system"; content: string | object }> {
663 try {
664 const response = await openai.chat.completions.create({
665 model,
666 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
680 return { role: "assistant", content };
681 } catch (error) {
682 console.error(`OpenAI call failed (ExpectJSON: ${expectJson}):`, error);
683 let msg = "Error communicating with AI.";
684 if (error.message) msg += ` Details: ${error.message}`;
685 if ((error as any).status === 401) msg = "OpenAI Auth Error. Check your 'openai' secret in Val Town.";
686 if ((error as any).status === 429) msg = "OpenAI Rate Limit Exceeded.";
687 return { role: "system", content: msg };
688 }
694 log: LogEntry[],
695 ): Promise<{ finalLog: LogEntry[]; extractedTagsCount: number; documentIdentifier: string | null }> {
696 const openai = new OpenAI();
697 log.push({ agent: "System", type: "step", message: "Workflow started." });
698
805 log.push({ agent: "System", type: "step", message: "Extracting searchable tags with LLM..." });
806 const tagAgent = "Autism Tag Extraction Agent";
807 const llmResponse = await callOpenAI(openai, autismTagExtractionSystemPrompt, textToAnalyze, "gpt-4o", true);
808
809 let extractedTags: string[] = [];

GitHub-trending-summarysummarize-to-email3 matches

@orguetta•Updated 1 week ago
1import { email } from "https://esm.town/v/std/email";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { JSDOM } from "npm:jsdom";
4import { NodeHtmlMarkdown, NodeHtmlMarkdownOptions } from "npm:node-html-markdown";
16);
17
18const openai = new OpenAI();
19console.log(trendingMarkdown);
20
21const completion = await openai.chat.completions.create({
22 messages: [
23 {

untitled-4923main.tsx12 matches

@salon•Updated 1 week ago
10 * * A GET request to this Val will display a UI to view and search stored tags.
11 * * It utilizes the LLM-Safe Fork of @std/sqlite (adjust import if necessary).
12 * Assumes 'openai' secret is set in Val Town environment variables.
13 * * Last Updated: 2025-05-08 (SQLite refactor and Glassmorphic UI)
14 */
472export default async function(req: Request) {
473 // --- Dynamic Imports (Inside Handler for Val Town) ---
474 const { OpenAI } = await import("https://esm.town/v/std/openai");
475 const val_fetch = (await import("https://esm.town/v/std/fetch")).fetch;
476 const { PDFExtract } = await import("npm:pdf.js-extract");
500 }
501
502 // --- Helper Function: Call OpenAI API (Unchanged from previous) ---
503 async function callOpenAI(
504 openai: OpenAI,
505 systemPrompt: string,
506 userMessage: string,
509 ): Promise<{ role: "assistant" | "system"; content: string | object }> {
510 try {
511 const response = await openai.chat.completions.create({
512 model,
513 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
527 return { role: "assistant", content };
528 } catch (error) {
529 console.error(`OpenAI call failed (ExpectJSON: ${expectJson}):`, error);
530 let msg = "Error communicating with AI.";
531 if (error.message) msg += ` Details: ${error.message}`;
532 if ((error as any).status === 401) msg = "OpenAI Auth Error. Check your 'openai' secret in Val Town.";
533 if ((error as any).status === 429) msg = "OpenAI Rate Limit Exceeded.";
534 // Consider more specific error handling or re-throwing
535 return { role: "system", content: msg }; // Or return an actual Error object / throw
542 log: LogEntry[],
543 ): Promise<{ finalLog: LogEntry[]; extractedTagsCount: number; documentIdentifier: string | null }> {
544 const openai = new OpenAI(); // Ensure your OpenAI secret is set in Val Town
545 log.push({ agent: "System", type: "step", message: "Workflow started." });
546
629 log.push({ agent: "System", type: "step", message: "Extracting searchable tags with LLM..." });
630 const tagAgent = "Autism Tag Extraction Agent";
631 const llmResponse = await callOpenAI(openai, autismTagExtractionSystemPrompt, textToAnalyze, "gpt-4o", true);
632
633 let extractedTags: string[] = [];
654 type: "error",
655 message: `LLM call failed or returned unexpected format.`,
656 details: llmResponse.content, // content here will be the error message from callOpenAI
657 });
658 }

stevensDemo.cursorrules4 matches

@talbet•Updated 1 week 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" },

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 1 week ago

testOpenAI1 file match

@stevekrouse•Updated 2 weeks ago
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
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": "*",