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.
- Node
- Python
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");
import requests
import json
API_KEY = "API_KEY_HERE"
TENANT_ID = "TENANT_ID_HERE"
def call_prompt_privacy(prompt, model="chatgpt_3_5"):
response = requests.post(
"https://apigateway.promptprivacy.com",
headers={
"Content-Type": "application/json",
"api-key": API_KEY
},
json={
"tenant_id": TENANT_ID,
"model": model,
"prompts": [{
"role": "user",
"content": prompt
}]
}
)
res = response.json()
if not res.get('success', False):
raise Exception(res.get('message', 'Unknown error'))
answer = res['response']['choices'][0]['message']
return answer
def generate_image(topic):
try:
initial_prompt = call_prompt_privacy(
f"Generate a prompt for Dall-e 3 that creates a stunning image about {topic}",
"chatgpt_4"
)
dalle_call = call_prompt_privacy(
initial_prompt,
"dalle"
)
print(dalle_call)
except Exception as e:
print(f"Error: {str(e)}")
generate_image("Dancing Cheeseburgers")