Readme

GPT4 Example

This uses the brand new gpt-4-1106-preview.

To use this, set OPENAI_API_KEY in your Val Town Secrets.

1
2
3
4
5
6
7
8
9
10
11
12
import { OpenAI } from "npm:openai";
const openai = new OpenAI();
let chatCompletion = await openai.chat.completions.create({
messages: [{
role: "user",
content: "Teach me about a super rare word",
}],
model: "gpt-4-1106-preview",
max_tokens: 30,
});
export let gpt4Example = chatCompletion.choices[0].message.content;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
November 7, 2023