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=104&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 1602 results for "openai"(1794ms)

telegrambotmain.tsx3 matches

@begoonUpdated 7 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

@l2046aUpdated 7 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

@mjweaver01Updated 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

@ubykUpdated 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

@blurUpdated 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

@hash0000ffUpdated 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 };

OpenAIREADME.md13 matches

@hash0000ffUpdated 8 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## 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" },
25## Limits
26
27While our wrapper simplifies the integration of OpenAI, there are a few limitations to keep in mind:
28
29* **Usage Quota**: We limit each user to 10 requests per minute.
32If these limits are too low, let us know! You can also get around the limitation by using your own keys:
33
341. Create your own API key on [OpenAI's website](https://platform.openai.com/api-keys)
352. Create an [environment variable](https://www.val.town/settings/environment-variables?adding=true) named `OPENAI_API_KEY`
363. Use the `OpenAI` client from `npm:openai`:
37
38```ts title="Example" val
39import { OpenAI } from "npm:openai";
40
41const openai = new OpenAI();
42```
43
44
45[📝 Edit docs](https://github.com/val-town/val-town-docs/edit/main/src/content/docs/std/openai.mdx)

OpenAIREADME.md13 matches

@arthrodUpdated 8 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## 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" },
25## Limits
26
27While our wrapper simplifies the integration of OpenAI, there are a few limitations to keep in mind:
28
29* **Usage Quota**: We limit each user to 10 requests per minute.
32If these limits are too low, let us know! You can also get around the limitation by using your own keys:
33
341. Create your own API key on [OpenAI's website](https://platform.openai.com/api-keys)
352. Create an [environment variable](https://www.val.town/settings/environment-variables?adding=true) named `OPENAI_API_KEY`
363. Use the `OpenAI` client from `npm:openai`:
37
38```ts title="Example" val
39import { OpenAI } from "npm:openai";
40
41const openai = new OpenAI();
42```
43
44
45[📝 Edit docs](https://github.com/val-town/val-town-docs/edit/main/src/content/docs/std/openai.mdx)

OpenAImain.tsx10 matches

@arthrodUpdated 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 }

extremePlumCariboumain.tsx4 matches

@ejfoxUpdated 8 months ago
199 }
200
201 // Generate new emoji using OpenAI
202 const { OpenAI } = await import("https://esm.town/v/std/openai");
203 const openai = new OpenAI();
204 const completion = await openai.chat.completions.create({
205 messages: [{ role: "user", content: `Generate a single emoji that best represents "${name}". Respond with only the emoji, nothing else.` }],
206 model: "gpt-4o-mini",

translateToEnglishWithOpenAI1 file match

@shlmtUpdated 1 day ago

testOpenAI1 file match

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