scrimba
AI Engineering
Intro to AI Engineering
Stop Sequence
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
Stop Sequence
Expand for more info
index.js
run
preview
console
import OpenAI from 'openai'

const openai = new OpenAI({
dangerouslyAllowBrowser: true
})

const messages = [
{
role: 'system',
content: 'You are a helpful assistant that knows a lot about books.'
},
{
role: 'user',
content: 'Recommend me some books about learning to code.'
}
]

const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: messages,
})

console.log(response.choices[0].message.content)
Console
/index.html
-3:03