scrimba
AI Engineering
Intro to AI Engineering
Creating Images with the DALL·E 3 API
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

To see this lesson you need to be logged in. Joining Scrimba is free and gives you access to 20+ courses.Sign up
Creating Images with the DALL·E 3 API
AboutCommentsNotes
Creating Images with the DALL·E 3 API
Expand for more info
index.js
run
preview
console
import { OpenAI } from "openai"

const outputImg = document.getElementById('output-img')

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

document.getElementById("submit-btn").addEventListener("click", () => {
const prompt = document.getElementById("instruction").value
generateImage(prompt)
})

async function generateImage(prompt) {

console.log(response)
outputImg.innerHTML = `<img src="" alt="The Image API Failed">`
}
Console
/index.html
-10:53