88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },
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" },
219
220export default async function server(request: Request): Promise<Response> {
221 const { OpenAI } = await import("https://esm.town/v/std/openai");
222 const openai = new OpenAI();
223
224 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
228 async start(controller) {
229 try {
230 const chatCompletion = await openai.chat.completions.create({
231 model: "gpt-4o",
232 messages: [
249 }
250 } catch (error) {
251 console.error("OpenAI Error:", error);
252 controller.enqueue(
253 new TextEncoder().encode(
219
220export default async function server(request: Request): Promise<Response> {
221 const { OpenAI } = await import("https://esm.town/v/std/openai");
222 const openai = new OpenAI();
223
224 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
228 async start(controller) {
229 try {
230 const chatCompletion = await openai.chat.completions.create({
231 model: "gpt-4o",
232 messages: [
249 }
250 } catch (error) {
251 console.error("OpenAI Error:", error);
252 controller.enqueue(
253 new TextEncoder().encode(
219
220export default async function server(request: Request): Promise<Response> {
221 const { OpenAI } = await import("https://esm.town/v/std/openai");
222 const openai = new OpenAI();
223
224 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
228 async start(controller) {
229 try {
230 const chatCompletion = await openai.chat.completions.create({
231 model: "gpt-4o",
232 messages: [
249 }
250 } catch (error) {
251 console.error("OpenAI Error:", error);
252 controller.enqueue(
253 new TextEncoder().encode(
219
220export default async function server(request: Request): Promise<Response> {
221 const { OpenAI } = await import("https://esm.town/v/std/openai");
222 const openai = new OpenAI();
223
224 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
228 async start(controller) {
229 try {
230 const chatCompletion = await openai.chat.completions.create({
231 model: "gpt-4o",
232 messages: [
249 }
250 } catch (error) {
251 console.error("OpenAI Error:", error);
252 controller.enqueue(
253 new TextEncoder().encode(
219
220export default async function server(request: Request): Promise<Response> {
221 const { OpenAI } = await import("https://esm.town/v/std/openai");
222 const openai = new OpenAI();
223
224 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
228 async start(controller) {
229 try {
230 const chatCompletion = await openai.chat.completions.create({
231 model: "gpt-4o",
232 messages: [
249 }
250 } catch (error) {
251 console.error("OpenAI Error:", error);
252 controller.enqueue(
253 new TextEncoder().encode(
219
220export default async function server(request: Request): Promise<Response> {
221 const { OpenAI } = await import("https://esm.town/v/std/openai");
222 const openai = new OpenAI();
223
224 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
228 async start(controller) {
229 try {
230 const chatCompletion = await openai.chat.completions.create({
231 model: "gpt-4o",
232 messages: [
249 }
250 } catch (error) {
251 console.error("OpenAI Error:", error);
252 controller.enqueue(
253 new TextEncoder().encode(
219
220export default async function server(request: Request): Promise<Response> {
221 const { OpenAI } = await import("https://esm.town/v/std/openai");
222 const openai = new OpenAI();
223
224 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
228 async start(controller) {
229 try {
230 const chatCompletion = await openai.chat.completions.create({
231 model: "gpt-4o",
232 messages: [
249 }
250 } catch (error) {
251 console.error("OpenAI Error:", error);
252 controller.enqueue(
253 new TextEncoder().encode(
219
220export default async function server(request: Request): Promise<Response> {
221 const { OpenAI } = await import("https://esm.town/v/std/openai");
222 const openai = new OpenAI();
223
224 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
228 async start(controller) {
229 try {
230 const chatCompletion = await openai.chat.completions.create({
231 model: "gpt-4o",
232 messages: [
249 }
250 } catch (error) {
251 console.error("OpenAI Error:", error);
252 controller.enqueue(
253 new TextEncoder().encode(