scrimba
Dall-E & GPT Vision
Image variations
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
Image variations
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.createVariation({
image: await fetch("images/bike.png"),
response_format: "b64_json",
size: "256x256"
});


document.body.innerHTML = `
<img src="data:image/png;base64,${image.data[0].b64_json}" alt="AI-generated image">
`;
Console
/index.html
-4:26