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=69&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 1630 results for "openai"(1291ms)

Chatterymain.tsx3 matches

@srijanb69Updated 2 months ago
98export default async function server(request: Request): Promise<Response> {
99 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
100 const { OpenAI } = await import("https://esm.town/v/std/openai");
101 const openai = new OpenAI();
102
103 const { messages } = await request.json();
104
105 const stream = await openai.chat.completions.create({
106 model: "gpt-o1",
107 messages: messages,

videoVisionAnalysismain.tsx4 matches

@RuthvikBandariUpdated 2 months ago
144 if (request.method === 'POST') {
145 try {
146 const { OpenAI } = await import("https://esm.town/v/std/openai");
147 const openai = new OpenAI();
148
149 // Parse the JSON payload
158 const base64Image = frameDataUrl.split(',')[1];
159
160 // Use OpenAI Vision to analyze the image frame
161 const completion = await openai.chat.completions.create({
162 model: "gpt-4o",
163 messages: [

ecstaticSalmonOrangutanmain.tsx1 match

@kevalUpdated 2 months ago
110 >
111 <option value="fallback">Fallback Model</option>
112 <option value="openai">OpenAI-like</option>
113 </select>
114 <button onClick={toggleTheme} className="theme-toggle">

resourcefulPurpleBobolinkmain.tsx3 matches

@harsha_5870Updated 2 months ago
179export default async function server(request: Request): Promise<Response> {
180 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
181 const { OpenAI } = await import("https://esm.town/v/std/openai");
182
183 const KEY = "resourcefulPurpleBobolink";
205 if (request.method === "POST") {
206 const { query } = await request.json();
207 const openai = new OpenAI();
208
209 // Retrieve previous conversation context
220 ).join("\n");
221
222 const completion = await openai.chat.completions.create({
223 messages: [
224 {

incredibleBrownEarwigmain.tsx3 matches

@HTKhan7Updated 2 months ago
277export default async function server(request: Request): Promise<Response> {
278 if (request.method === "POST") {
279 const { OpenAI } = await import("https://esm.town/v/std/openai");
280 const openai = new OpenAI();
281
282 const body = await request.json();
290 : "You are Thunder, an intelligent and helpful AI assistant created by Team HTKhan. You are skilled in conversing about various topics, answering questions, and providing assistance. and HTKhan refers to Huzaifa Taif Khan,Provide friendly, clear, and helpful responses.";
291
292 const completion = await openai.chat.completions.create({
293 messages: [
294 { role: "system", content: systemPrompt },

AkhilAimain.tsx3 matches

@Akhil_23Updated 2 months ago
155export default async function server(request: Request): Promise<Response> {
156 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
157 const { OpenAI } = await import("https://esm.town/v/std/openai");
158 const openai = new OpenAI();
159
160 try {
205 ];
206
207 const completion = await openai.chat.completions.create({
208 messages: completionMessages,
209 model: "gpt-4o-mini",

OpenAImain.tsx10 matches

@mjoshimanharUpdated 2 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("OPENAI_API_KEY"),
25 organization: null,
26 });
28
29 get chat() {
30 return this.rawOpenAIClient.chat;
31 }
32
33 get beta() {
34 return {
35 chat: this.rawOpenAIClient.beta.chat,
36 };
37 }

OpenAIREADME.md13 matches

@mjoshimanharUpdated 2 months ago
1# OpenAI - [Docs ↗](https://docs.val.town/std/openai)
2
3Use OpenAI's chat completion API with [`std/openai`](https://www.val.town/v/std/openai). This integration enables access to OpenAI's language models without needing to acquire API keys.
4
5For free Val Town users, [all calls are sent to `gpt-4o-mini`](https://www.val.town/v/std/openaiproxy?v=12#L85).
6
7## Basic Usage
8
9```ts title="Example" val
10import { OpenAI } from "https://esm.town/v/std/openai";
11
12const openai = new OpenAI();
13
14const completion = await openai.chat.completions.create({
15 messages: [
16 { role: "user", content: "Say hello in a creative way" },
58## Limits
59
60While our wrapper simplifies the integration of OpenAI, there are a few limitations to keep in mind:
61
62* **Usage Quota**: We limit each user to 10 requests per minute.
65If these limits are too low, let us know! You can also get around the limitation by using your own keys:
66
671. Create your own API key on [OpenAI's website](https://platform.openai.com/api-keys)
682. Create an [environment variable](https://www.val.town/settings/environment-variables?adding=true) named `OPENAI_API_KEY`
693. Use the `OpenAI` client from `npm:openai`:
70
71```ts title="Example" val
72import { OpenAI } from "npm:openai";
73
74const openai = new OpenAI();
75```
76
77
78[📝 Edit docs](https://github.com/val-town/val-town-docs/edit/main/src/content/docs/std/openai.mdx)

translatorWebsitemain.tsx3 matches

@HarmonyChideraUpdated 2 months ago
147export default async function server(request: Request): Promise<Response> {
148 if (request.method === 'POST' && new URL(request.url).pathname === '/translate') {
149 const { OpenAI } = await import("https://esm.town/v/std/openai");
150 const openai = new OpenAI();
151
152 const { text, sourceLanguage, targetLanguage } = await request.json();
153
154 const completion = await openai.chat.completions.create({
155 messages: [
156 {

researchAgentemailHandler2 matches

@wasauceUpdated 2 months ago
2import process from "node:process";
3import { marked } from "npm:marked";
4import { OpenAI } from "npm:openai";
5
6function pm(...lines: string[]): string {
16 );
17
18 const client = new OpenAI({ apiKey: process.env.PERPLEXITY_API_KEY, baseURL: "https://api.perplexity.ai" });
19 const response = await client.chat.completions.create({
20 model: "sonar",

translateToEnglishWithOpenAI1 file match

@shlmtUpdated 5 days ago

testOpenAI1 file match

@stevekrouseUpdated 1 week 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": "*",