Skip to main content

Image generation

To create a detailed prompt from a single concept, we utilize ChatGPT's advanced language processing capabilities. First, we define the core idea or theme, ensuring it's clear and focused. ChatGPT then employs its extensive knowledge base and language skills to elaborate on this concept, adding relevant details, descriptions, and context to form a comprehensive and vivid prompt. This enriched prompt, crafted with precision and creativity, is subsequently passed to Dall-E. Dall-E, equipped with its own powerful image generation technology, interprets the detailed prompt to produce a corresponding image. This synergy between ChatGPT's linguistic prowess and Dall-E's visual creativity allows for the transformation of a simple concept into a visually compelling and intricate image.

const API_KEY = "API_KEY_HERE";
const TENANT_ID = "TENANT_ID_HERE";

const callPromptPrivacy = async (prompt, model) => {
const call = await fetch("https://apigateway.promptprivacy.com", {
method: "POST",
headers: {
"Content-Type": "application/json",
"api-key": API_KEY,
},
body: JSON.stringify({
tenant_id: TENANT_ID,
model: model || "chatgpt_3_5",
prompts: [{
role: "user",
content: prompt,
}],
}),
});
const res = await call.json();
if(res.success === false) {
throw new Error(res.message);
}
const answer = res.response.choices[0].message;
return answer;
};

const generateImage = async (topic) => {
try {
const intiialPrompt = await callPromptPrivacy(
`Generate a prompt for Dall-e 3 that creates a stunning image about ${topic}`,
"chatgpt_4"
);
const dalleCall = await callPromptPrivacy(
intiialPrompt.content,
"dalle"
);
console.log(dalleCall);
} catch (e) {
console.error(e.message);
}
};

generateImage("Dancing Cheeseburgers");