scrimba
Dall-E & GPT Vision
Prompting for image generation
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

Prompting for image generation
AboutCommentsNotes
Prompting for image generation
Expand for more info
index.js
run
preview
console
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
dangerouslyAllowBrowser: true,
});

const image = await openai.images.generate({
model: "dall-e-3",
prompt: "A futuristic city floating in the clouds of Venus, with aerodynamic buildings and airships navigating through a peaceful misty atmosphere"
});
console.log(image.data);

document.body.innerHTML = `<img src="${image.data[0].url}" alt="AI-generated image">`;
Console
[
{revised_prompt:
"Imagine a vision of the future, set on the second planet from the Sun, Venus. The city floats serenely among the dense cloudy atmosphere of the planet. Artistic inspiration can be drawn from the thought-provoking architectural designs of the late 1800s, featuring many aerodynamic buildings. Navigating through this peaceful misty setting are numerous airships, their streamlined shapes perfectly suited for traversal in this atmospheric condition. The overall setting hints at a serene future where humanity has managed to colonize other planets and continue its growth."
, url:
"https://oaidalleapiprodscus.blob.core.windows.net/private/org-hILmMJhWE2V3rB3oGuJuRWMy/user-D2ZUX8laI3rwHivJHNEA41mW/img-n5q7Qufmg6sDqIWyZwy1jMXZ.png?st=2024-04-01T15%3A33%3A11Z&se=2024-04-01T17%3A33%3A11Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-04-01T01%3A27%3A36Z&ske=2024-04-02T01%3A27%3A36Z&sks=b&skv=2021-08-06&sig=B19ZLEThKVWu9EN5O3ssK5Bku78x48aOBFf4ootkMYI%3D"
}
]
,
/index.html
-8:30