86Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
87
88### OpenAI
89
90```ts
91import { OpenAI } from "https://esm.town/v/std/openai";
92const openai = new OpenAI();
93const completion = await openai.chat.completions.create({
94 messages: [
95 { role: "user", content: "Say hello in a creative way" },
71```
72
73### OpenAI Integration
74```typescript
75import { OpenAI } from "https://esm.town/v/std/openai";
76const openai = new OpenAI();
77const completion = await openai.chat.completions.create({
78 messages: [{ role: "user", content: "Say hello" }],
79 model: "gpt-4o-mini",
83
84 <library>
85 ## OpenAI
86
87 Val Town includes a free, proxied OpenAI:
88
89 ```ts
90 import { OpenAI } from "https://esm.town/v/std/openai";
91 const openai = new OpenAI();
92 const completion = await openai.chat.completions.create({
93 messages: [
94 { role: "user", content: "Say hello in a creative way" },
99 ```
100
101 OpenAI only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
102 `const { OpenAI } = await import "https://esm.town/v/std/openai");`
103 </library>
104
143Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
144
145### OpenAI
146```ts
147import { OpenAI } from "npm:openai";
148const openai = new OpenAI();
149const completion = await openai.chat.completions.create({
150 messages: [
151 { role: "user", content: "Say hello in a creative way" },
2
3import process from "node:process";
4import { OpenAI } from "npm:openai";
5const IMAGE_COST = 500;
6
28].filter(Boolean);
29
30function createPoeClient(apiKey: string): OpenAI {
31 return new OpenAI({
32 apiKey: apiKey || "YOUR_POE_API_KEY",
33 baseURL: "https://api.poe.com/v1",
2
3import process from "node:process";
4import { OpenAI } from "npm:openai";
5const IMAGE_COST = 500;
6
28].filter(Boolean);
29
30function createPoeClient(apiKey: string): OpenAI {
31 return new OpenAI({
32 apiKey: apiKey || "YOUR_POE_API_KEY",
33 baseURL: "https://api.poe.com/v1",
1import process from "node:process";
2import { OpenAI } from "npm:openai";
3
4const IMAGE_COST = 400;
110}
111
112function createPoeClient(apiKey: string): OpenAI {
113 return new OpenAI({
114 apiKey: apiKey || "YOUR_POE_API_KEY",
115 baseURL: "https://api.poe.com/v1",
1import process from "node:process";
2import { OpenAI } from "npm:openai";
3
4const IMAGE_COST = 400;
110}
111
112function createPoeClient(apiKey: string): OpenAI {
113 return new OpenAI({
114 apiKey: apiKey || "YOUR_POE_API_KEY",
115 baseURL: "https://api.poe.com/v1",
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" },
37 language,
38 offset = 0,
39 model = 'openai/gpt-oss-120b',
40 reasoning_effort = 'medium',
41 tools,
54 }
55
56 const isGptOss = typeof model === 'string' && model.startsWith('openai/gpt-oss');
57 const supportsReasoning = isGptOss;
58 const supportsTools = isGptOss;