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/$%7Bart_info.art.src%7D?q=openai&page=94&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 1605 results for "openai"(909ms)

exaltedAmethystAntelopemain.tsx8 matches

@dcm31•Updated 5 months ago
3import { Hono } from "npm:hono@3";
4import { html } from "npm:hono@3/html";
5import { OpenAI } from "npm:openai";
6
7const app = new Hono();
8const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY_VOICE"));
9
10class TranscriptionService {
11 async transcribeAudio(audioFile) {
12 try {
13 const transcription = await openai.audio.transcriptions.create({
14 file: audioFile,
15 model: "whisper-1",
19 return transcription;
20 } catch (error) {
21 console.error("OpenAI API error:", error);
22 throw error;
23 }
405
406 try {
407 const response = await openai.chat.completions.create({
408 model: "gpt-3.5-turbo",
409 messages: [
423 return c.text(translation);
424 } catch (error) {
425 console.error("OpenAI API error:", error);
426 return c.text("Error occurred during translation", 500);
427 }
438
439 try {
440 const mp3 = await openai.audio.speech.create({
441 model: "tts-1",
442 voice: voice,
450 });
451 } catch (error) {
452 console.error("OpenAI API error:", error);
453 return c.text("Error occurred during speech generation", 500);
454 }

translatorREADME.md1 match

@dcm31•Updated 5 months ago
3The app is set up so you can easily have a conversation between two people. The app will translate between the two selected languages, in each voice, as the speakers talk.
4
5Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.

translatormain.tsx8 matches

@dcm31•Updated 5 months ago
2import { html } from "npm:hono@3/html";
3import { cors } from 'npm:hono/cors';
4import { OpenAI } from "npm:openai";
5
6const app = new Hono();
7const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY_VOICE"));
8
9class TranscriptionService {
10 async transcribeAudio(audioFile) {
11 try {
12 const transcription = await openai.audio.transcriptions.create({
13 file: audioFile,
14 model: "whisper-1",
18 return transcription;
19 } catch (error) {
20 console.error('OpenAI API error:', error);
21 throw error;
22 }
350
351 try {
352 const response = await openai.chat.completions.create({
353 model: "gpt-3.5-turbo",
354 messages: [
368 return c.text(translation);
369 } catch (error) {
370 console.error('OpenAI API error:', error);
371 return c.text('Error occurred during translation', 500);
372 }
383
384 try {
385 const mp3 = await openai.audio.speech.create({
386 model: "tts-1",
387 voice: voice,
395 });
396 } catch (error) {
397 console.error('OpenAI API error:', error);
398 return c.text('Error occurred during speech generation', 500);
399 }

MicroSaasIdeaRoulettemain.tsx3 matches

@heltonteixeira•Updated 5 months ago
114 if (new URL(request.url).pathname === '/generate-idea') {
115 try {
116 const { OpenAI } = await import("https://esm.town/v/std/openai");
117 const openai = new OpenAI();
118
119 const completion = await openai.chat.completions.create({
120 messages: [
121 {

ThankYouNoteGeneratormain.tsx3 matches

@willthereader•Updated 5 months ago
303 console.log(`Received ${request.method} request to ${request.url}`);
304
305 const { OpenAI } = await import("https://esm.town/v/std/openai");
306 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
307 const openai = new OpenAI();
308 const url = new URL(request.url);
309
334 console.log("Generated prompt:", prompt);
335
336 const completion = await openai.chat.completions.create({
337 messages: [{ role: "user", content: prompt }],
338 model: "gpt-4o-mini",

summariseNewsmain.tsx5 matches

@piyushbeli•Updated 5 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(request: Request) {
41 }
42
43 const openai = new OpenAI();
44
45 const summaryPrompt = "This is a news link: " + inputUrl
54
55 try {
56 // Get the article summary from OpenAI
57 const summaryResponse = await openai.chat.completions.create({
58 model: "gpt-4o-mini",
59 response_format: { type: "json_object" },
75 return new Response(
76 JSON.stringify({
77 error: `OpenAI processing failed: ${error.message}`,
78 errorStack: error.stack,
79 }),

dailyThoughtPromptREADME.md1 match

@chrisputnam9•Updated 5 months ago
1Uses OpenAI to generate a thought-provoking statement and emails it to you at whatever interval you set.
2
3Clone/fork this, set the interval you want (eg. every 1 days) and hit run to test it.

Storyweavermain.tsx4 matches

@aioe0x417a•Updated 5 months ago
168 );
169
170 const { OpenAI } = await import("https://esm.town/v/std/openai");
171 const openai = new OpenAI();
172
173 try {
174 const imageAnalysis = await withTimeout(openai.chat.completions.create({
175 model: "gpt-4o",
176 messages: [
199 : '';
200
201 const story = await withTimeout(openai.chat.completions.create({
202 model: "gpt-4o-mini",
203 messages: [

katakanaWordApimain.tsx3 matches

@jdan•Updated 5 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(request: Request): Promise<Response> {
4 try {
5 const openai = new OpenAI();
6
7 const completion = await openai.chat.completions.create({
8 messages: [
9 {

telegramWebhookEchoMessagemain.tsx3 matches

@dcm31•Updated 5 months ago
2
3import { telegramSendMessage } from "https://esm.town/v/vtdocs/telegramSendMessage?v=5";
4import { OpenAI } from "https://esm.town/v/std/openai";
5import { blob } from "https://esm.town/v/std/blob";
6
7const openai = new OpenAI();
8
9// Task structure
98 `;
99
100 const completion = await openai.chat.completions.create({
101 messages: [{ role: "user", content: prompt }],
102 model: "gpt-4o-mini",

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 2 days ago

testOpenAI1 file match

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