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/$1?q=openai&page=15&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 1970 results for "openai"(8977ms)

autonomous-valREADME.md1 match

@all•Updated 1 week ago
7Configure the following variables in your environment:
8- `AGENT_API_KEY` (This is a secure token that you choose to secure the agent.tsx POST endpoint)
9- `OPENAI_API_KEY` (An OpenAI API Key)
10- `EXA_API_KEY` (Optional, though needed if you use the web search tool)
11

autonomous-valagent.tsx2 matches

@all•Updated 1 week ago
1import { anthropic } from "npm:@ai-sdk/anthropic";
2import { openai } from "npm:@ai-sdk/openai";
3import { generateText, streamText } from "npm:ai";
4import { getSystemPrompt } from "./prompt.tsx";
34 const maxSteps = 10;
35
36 const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
37
38 const options = {

autonomous-valagent.tsx2 matches

@abrinz•Updated 1 week ago
1import { anthropic } from "npm:@ai-sdk/anthropic";
2import { openai } from "npm:@ai-sdk/openai";
3import { generateText, streamText } from "npm:ai";
4import { getSystemPrompt } from "./prompt.tsx";
34 const maxSteps = 10;
35
36 const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
37
38 const options = {

untitled-7748telegram-image-bot.ts7 matches

@Rajparbat01•Updated 1 week ago
1// Telegram Bot that uses OpenAI's DALL-E to generate images
2import { OpenAI } from "https://esm.town/v/std/openai";
3
4// Initialize OpenAI client
5const openai = new OpenAI();
6
7// Telegram Bot API types
91}
92
93// Function to generate an image using OpenAI's DALL-E
94async function generateImage(prompt: string) {
95 try {
96 const response = await openai.images.generate({
97 model: "dall-e-3",
98 prompt: prompt,
123 chatId,
124 "👋 Welcome to the Image Generation Bot!\n\n" +
125 "I can generate images based on your descriptions using OpenAI's DALL-E model.\n\n" +
126 "Simply send me a description of the image you want to create, and I'll generate it for you.\n\n" +
127 "For example: *A serene lake surrounded by mountains at sunset*"
Hubspot-Research

Hubspot-Research.cursorrules4 matches

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

nightwatchmain.tsx16 matches

@join•Updated 1 week ago
1// Val Town Narrative Engine with Integrated Test UI
2// =============================================================================
3import { OpenAI } from "https://esm.town/v/std/openai"; // Val Town's OpenAI integration
4// import { Env } from "https://esm.town/v/std/env"; // Not needed if OpenAI() handles API key
5
6// --- Configuration & Constants ---
7const OPENAI_MODEL = "gpt-4o";
8const MAX_TOKENS_RESPONSE = 700;
9
127}
128
129// --- OpenAI System Prompt (same as before) ---
130const SYSTEM_PROMPT = `
131You are a Rick and Morty-styled transdimensional narrative engine, probably cobbled together by Rick in a drunken stupor. Your primary role is to generate hilariously chaotic, compelling, and atmospherically bizarre narrative turns for an epic journey to save the multiverse (or, you know, whatever Rick feels like doing).
549 } = ensureDefaultsAndInferStates(inputContext);
550
551 const contextForOpenAI = {
552 ...processedContext,
553 _inferred_states_for_your_convenience: {
558 };
559 const userMessage = `Input Context JSON (with inferred states for your reference):\n${
560 JSON.stringify(contextForOpenAI, null, 2)
561 }`;
562
563 try {
564 const openai = new OpenAI();
565 const completion = await openai.chat.completions.create({
566 model: OPENAI_MODEL,
567 response_format: { type: "json_object" },
568 messages: [
576 const rawContent = completion.choices[0]?.message?.content;
577 if (!rawContent) {
578 console.error("OpenAI returned an empty response message.");
579 return new Response(
580 JSON.stringify(
581 getFallbackOutput("OpenAI empty response.", processedContext),
582 ),
583 { status: 500, headers: { "Content-Type": "application/json" } },
595 ) {
596 console.error(
597 "OpenAI response missing critical fields or incorrect structure.",
598 JSON.stringify(generatedJson, null, 2),
599 );
602 JSON.stringify(
603 getFallbackOutput(
604 "OpenAI response schema validation failed after generation.",
605 processedContext,
606 ),
618 });
619 } catch (error) {
620 console.error("Error during OpenAI API call or processing:", error);
621 let errorMessage = "Internal server error";
622 if (error.response && error.response.data && error.response.data.error) { // More specific OpenAI error
623 errorMessage = `OpenAI API Error: ${error.response.data.error.message}`;
624 } else if (error.message) {
625 errorMessage = error.message;

usmain.ts10 matches

@join•Updated 1 week ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { z } from "npm:zod";
4
524}
525
526async function callOpenAI(sysP: string, userP: string, mid: string, tid: string, log: LogFn): Promise<string | null> {
527 log("DB", "OpenAI", `Call tid=${tid}`, { sL: sysP.length, uL: userP.length }, mid, tid);
528 try { // @ts-ignore
529 const oai = new OpenAI();
530 const comp = await oai.chat.completions.create({
531 model: "gpt-4o-mini",
537 const usg = comp.usage;
538 if (!resT) {
539 log("WN", "OpenAI", `No text tid=${tid}.`, { usg, fin: comp.choices[0]?.finish_reason }, mid, tid);
540 return null;
541 }
542 log("IN", "OpenAI", `OK tid=${tid}`, { rL: resT.length, usg, fin: comp.choices[0]?.finish_reason }, mid, tid);
543 return resT.trim();
544 } catch (err: any) {
552 st: err.status,
553 };
554 log("ER", "OpenAI", `Fail tid=${tid}:${err.message}`, { e: eD }, mid, tid);
555 throw new Error(
556 `OpenAI Fail: ${err.message}` + (err.code ? `(C:${err.code},S:${err.status})` : `(S:${err.status})`),
557 );
558 }
785 return { mid, cid: tid, p: {} as TOD, e: `${aC.name} fail:PromptGenErr.` };
786 }
787 const rOR = await callOpenAI(sP, uP, mid, tid, l);
788 if (!rOR) {
789 l("WN", aC.name, `OpenAI no content tid=${tid}.`, 0, mid, tid);
790 return { mid, cid: tid, p: {} as TOD, e: `${aC.name} fail:AI no content.` };
791 }

FlexCalformatting.ts3 matches

@malcolmocean•Updated 1 week ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3// Interface for formatting rules
123export async function extractFlightInfoWithAI(event: any): Promise<string> {
124 try {
125 const openai = new OpenAI();
126
127 const prompt = `
135 `;
136
137 const completion = await openai.chat.completions.create({
138 messages: [
139 { role: "system", content: "You extract airport codes from flight information." },
vtProjectSearch

vtProjectSearchcomponents.tsx2 matches

@maxm•Updated 1 week ago
1246 <a href="?q=function" className="example-link">function</a>
1247 <a href="?q=discord" className="example-link">discord</a>
1248 <a href="?q=openai" className="example-link">openai</a>
1249 <a href="?q=react" className="example-link">react</a>
1250 </div>
1400 <a href="?q=function" className="example-link">function</a>
1401 <a href="?q=discord" className="example-link">discord</a>
1402 <a href="?q=openai" className="example-link">openai</a>
1403 <a href="?q=react" className="example-link">react</a>
1404 </div>

val-town-blogget-old-posts.ts5 matches

@pomdtr•Updated 1 week ago
198 },
199 {
200 "title": "An Introduction to OpenAI fine-tuning",
201 "slug": "an-introduction-to-openai-fine-tuning",
202 "link": "/blog/an-introduction-to-openai-fine-tuning",
203 "description": "How to customize OpenAI to your liking",
204 "pubDate": "Fri, 25 Aug 2023 00:00:00 GMT",
205 "author": "Steve Krouse",
417 "slug": "val-town-newsletter-16",
418 "link": "/blog/val-town-newsletter-16",
419 "description": "Our seed round, growing team, Codeium completions, @std/openai, and more",
420 "pubDate": "Mon, 22 Apr 2024 00:00:00 GMT",
421 "author": "Steve Krouse",

openaiproxy2 file matches

@skutaans•Updated 4 days ago

token-server1 file match

@kwhinnery_openai•Updated 5 days ago
Mint tokens to use with the OpenAI Realtime API for WebRTC
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