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=105&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 1616 results for "openai"(545ms)

openai_structured_output_demoREADME.md4 matches

@stevekrouse•Updated 8 months ago
1# OpenAI Structured Output Demo
2
3Ensure responses follow JSON Schema for structured outputs
5The following demo uses zod to describe and parse the response to JSON.
6
7Learn more in the [OpenAI Structured outputs
8 docs](https://platform.openai.com/docs/guides/structured-outputs/introduction).
9
10
11Migrated from folder: Archive/openai_structured_output_demo

telegramDalleBotmain.tsx1 match

@adjacent•Updated 8 months ago
27 try {
28 const imageURL = (await textToImageDalle(
29 process.env.openai,
30 text,
31 1,

telegramDalleBotREADME.md1 match

@adjacent•Updated 8 months ago
1# Telegram DALLE Bot
2
3A personal telegram bot you can message to create images with OpenAI's [DALLE](https://openai.com/dall-e-2) ✨
4
5![DALLE: A Macintosh II sitting on a desk, painted by Picasso in his blue period.](https://i.imgur.com/uJrP5mE.png)

jsonToDalleFormmain.tsx9 matches

@weaverwhale•Updated 8 months ago
1/** @jsxImportSource https://esm.sh/react */
2import OpenAI from "https://esm.sh/openai";
3import React, { useState } from "https://esm.sh/react";
4import { createRoot } from "https://esm.sh/react-dom/client";
6import { systemPrompt } from "https://esm.town/v/weaverwhale/jtdPrompt";
7
8// Move OpenAI initialization to server function
9let openai;
10
11function App() {
139 const url = new URL(request.url);
140
141 // Initialize OpenAI here to avoid issues with Deno.env in browser context
142 if (!openai) {
143 const apiKey = Deno.env.get("OPENAI_API_KEY");
144 openai = new OpenAI({ apiKey });
145 }
146
150
151 // Generate DALL-E prompt using GPT
152 const completion = await openai.chat.completions.create({
153 messages: [
154 {
168
169 // Generate DALL-E image
170 const response = await openai.images.generate({
171 model: "dall-e-3",
172 prompt: dallePrompt,

telegrambotmain.tsx3 matches

@begoon•Updated 8 months ago
10const { endpoint } = VAL;
11
12import { OpenAI } from "https://esm.town/v/std/openai";
13
14const openai = new OpenAI();
15
16async function POST(cmd: string, data: { [key: string]: string }) {
67 const q = text.split(" ").slice(1).join(" ");
68 console.log("q", q);
69 const completion = await openai.chat.completions.create({
70 messages: [
71 { role: "user", content: q },

oddTanRoundwormmain.tsx3 matches

@l2046a•Updated 8 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
11 });
12 }
13 const openai = new OpenAI();
14
15 try {
28 }
29
30 const stream = await openai.chat.completions.create(body);
31
32 if (!body.stream) {

FindFraudTrendsUsingGPTmain.tsx3 matches

@mjweaver01•Updated 8 months ago
3
4import { Hono } from "npm:hono";
5import { OpenAI } from "npm:openai";
6
7const trendGPT = async (data, onData) => {
8 const openai = new OpenAI();
9
10 const chatStream = await openai.chat.completions.create({
11 messages: [
12 { role: "system", content: prompt.replaceAll("\n", "") },

VALLErunmain.tsx2 matches

@ubyk•Updated 8 months ago
9import { sleep } from "https://esm.town/v/stevekrouse/sleep?v=1";
10import { anthropic } from "npm:@ai-sdk/anthropic";
11import { openai } from "npm:@ai-sdk/openai";
12import ValTown from "npm:@valtown/sdk";
13import { StreamingTextResponse, streamText } from "npm:ai";
1104 let vercelModel;
1105 if (model.includes("gpt")) {
1106 vercelModel = openai(model);
1107 } else {
1108 vercelModel = anthropic(model);

oraclemain.tsx3 matches

@blur•Updated 8 months ago
2import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
3import { AttachmentData, email } from "https://esm.town/v/std/email?v=13";
4import { OpenAI } from "https://esm.town/v/std/openai";
5
6const { author, name } = extractValInfo(import.meta.url);
7
8export async function main(e: Email) {
9 const openai = new OpenAI();
10
11 let attachments: AttachmentData[] = [];
19 }
20
21 const completion = await openai.chat.completions.create({
22 messages: [
23 {

OpenAImain.tsx10 matches

@hash0000ff•Updated 8 months ago
1import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
2
3/**
4 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
5 */
6export class OpenAI {
7 private rawOpenAIClient: RawOpenAI;
8
9 /**
10 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
11 *
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
19 */
20 constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
21 this.rawOpenAIClient = new RawOpenAI({
22 ...options,
23 baseURL: "https://std-openaiproxy.web.val.run/v1",
24 apiKey: Deno.env.get("valtown"),
25 organization: null,
28
29 get chat() {
30 return this.rawOpenAIClient.chat;
31 }
32
33 readonly beta = {
34 get chat(): RawOpenAI["beta"]["chat"] {
35 return this.rawOpenAIClient.beta.chat;
36 },
37 };

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 4 days ago

testOpenAI1 file match

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