Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Get started using OpenAI's chat completion without the need to set your own API keys.
Here's a quick example to get you started with the Val Town OpenAI wrapper:
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const functionExpression = await openai.chat.completions.create({
"messages": [
{ "role": "user", "content": "Say hello in a creative way" },
],
model: "gpt-4",
max_tokens: 30,
});
console.log(functionExpression.choices[0].message.content);