RecipeForge AI – Custom Recipe Generator
/* — CSS SEPARATION START — */
@import url(‘https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap’);
@import url(‘https://fonts.googleapis.com/css2?family=Pacifico&display=swap’);:root {
–primary: #F97316; /* Orange-500 */
–bg-dark: #111827;
}body {
font-family: ‘Inter’, sans-serif;
transition: background-color 0.3s, color 0.3s;
}/* Recipe Header Font */
.header-font {
font-family: ‘Pacifico’, cursive;
}/* Loading Spinner */
.loader {
border: 3px solid #f3f3f3;
border-radius: 50%;
border-top: 3px solid var(–primary);
width: 20px;
height: 20px;
animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }/* Custom List Markers */
#recipe-instructions ol {
counter-reset: step-counter;
list-style: none;
padding-left: 0;
}
#recipe-instructions li {
counter-increment: step-counter;
margin-bottom: 0.75rem;
display: flex;
align-items: flex-start;
}
#recipe-instructions li::before {
content: counter(step-counter);
background-color: var(–primary);
color: white;
font-weight: bold;
border-radius: 50%;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.875rem;
margin-right: 0.75rem;
flex-shrink: 0;
}
/* Dark Mode */
.dark body { background-color: var(–bg-dark); color: #F9FAFB; }
.dark .card { background-color: #1F2937; border-color: #374151; }
.dark input, .dark select, .dark textarea { background-color: #374151; color: white; border-color: #4B5563; }
/* — CSS SEPARATION END — */
tailwind.config = {
darkMode: ‘class’,
theme: {
extend: {
colors: {
primary: ‘#F97316’,
}
}
}
}
Generate unique recipes based on ingredients you have, cuisine preference, and dietary needs.
Recipe Criteria
Ingredients I Have (List them)
Cuisine / Style
Difficulty
Easy (Quick)
Medium
Hard (Advanced)
Meal Type
Dinner / Main
Breakfast
Lunch
Dessert
Dietary Restrictions (Optional)
Forge Recipe
Please list at least two ingredients.
Your custom recipe will be forged here.
The AI chef is preparing your custom dish…
Print / Save as PDF
// — JAVASCRIPT SEPARATION START —// API Key for Gemini
const apiKey = “”;// DOM Elements
const ingredientsInput = document.getElementById(‘ingredients-input’);
const cuisineInput = document.getElementById(‘cuisine-input’);
const difficultySelect = document.getElementById(‘difficulty-select’);
const mealSelect = document.getElementById(‘meal-select’);
const restrictionsInput = document.getElementById(‘restrictions-input’);
const btnGenerate = document.getElementById(‘btn-generate’);
const btnText = document.getElementById(‘btn-text’);
const btnLoader = document.getElementById(‘btn-loader’);
const errorMsg = document.getElementById(‘error-msg’);
const recipeCard = document.getElementById(‘recipe-card’);
const loadingDots = document.getElementById(‘loading-dots’);
const btnPrint = document.getElementById(‘btn-print’);let isDarkMode = false;
let lastGeneratedRecipe = null;// — Functions —async function generateRecipe() {
const ingredients = ingredientsInput.value.trim();
const cuisine = cuisineInput.value.trim();
const difficulty = difficultySelect.value;
const mealType = mealSelect.value;
const restrictions = restrictionsInput.value.trim();if (ingredients.split(‘,’).filter(s => s.trim().length > 0).length < 2) {
errorMsg.innerText = "Please list at least two ingredients you have.";
errorMsg.classList.remove('hidden');
return;
}
errorMsg.classList.add('hidden');// UI Loading State
btnGenerate.disabled = true;
btnText.innerText = 'Forging Recipe…';
btnLoader.classList.remove('hidden');
recipeCard.innerHTML = '';
loadingDots.classList.remove('hidden');
btnPrint.classList.add('hidden');try {
const prompt = `Create a unique recipe for a ${mealType} meal. The recipe must predominantly use these ingredients: ${ingredients}. Cuisine/Style: ${cuisine || 'General'}. Difficulty: ${difficulty}. Dietary Notes: ${restrictions || 'None'}.`;const systemPrompt = "You are an AI chef and structured JSON generator. Generate a single, unique recipe based on the user's criteria. Provide the response ONLY in the specified JSON format.";const apiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-09-2025:generateContent?key=${apiKey}`;const payload = {
contents: [{ parts: [{ text: prompt }] }],
systemInstruction: { parts: [{ text: systemPrompt }] },
generationConfig: {
responseMimeType: "application/json",
responseSchema: {
type: "OBJECT",
properties: {
name: { type: "STRING", description: "Creative and descriptive recipe name." },
description: { type: "STRING", description: "Brief (2-3 sentence) summary of the dish." },
prep_time: { type: "STRING", description: "Estimated preparation time (e.g., 15 mins)." },
cook_time: { type: "STRING", description: "Estimated cooking time (e.g., 30 mins)." },
servings: { type: "STRING", description: "Number of servings (e.g., 4 servings)." },
ingredients: { type: "ARRAY", items: { type: "STRING" }, description: "A list of all ingredients with specific quantities." },
instructions: { type: "ARRAY", items: { type: "STRING" }, description: "Step-by-step instructions for cooking." }
},
required: ["name", "description", "prep_time", "cook_time", "servings", "ingredients", "instructions"]
}
}
};const response = await fetch(apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});const data = await response.json();
const jsonText = data.candidates?.[0]?.content?.parts?.[0]?.text;if (!jsonText) {
throw new Error("AI output was empty.");
}
const recipe = JSON.parse(jsonText);
lastGeneratedRecipe = recipe;
renderRecipeCard(recipe);
btnPrint.classList.remove('hidden');} catch (error) {
console.error('API Error:', error);
recipeCard.innerHTML = `
Error generating recipe. Please check your inputs and try again.
`;
lastGeneratedRecipe = null;
} finally {
btnGenerate.disabled = false;
btnText.innerText = ‘Forge Recipe’;
btnLoader.classList.add(‘hidden’);
loadingDots.classList.add(‘hidden’);
}
}function renderRecipeCard(recipe) {
const recipeHtml = `
Servings
${recipe.servings}
Ingredients
${recipe.ingredients.map(item => `${item} `).join(”)} Instructions
${recipe.instructions.map(step => `${step} `).join(”)}
`;
recipeCard.innerHTML = recipeHtml;
}function printRecipe() {
if (!lastGeneratedRecipe) {
alert(“No recipe generated yet.”);
return;
}// Use html2pdf for robust PDF generation
const element = document.getElementById(‘recipe-card’);
const filename = lastGeneratedRecipe.name.replace(/[^a-zA-Z0-9\s]/g, ”).replace(/\s/g, ‘_’) + ‘.pdf’;const opt = {
margin: 10,
filename: filename,
image: { type: ‘jpeg’, quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: ‘mm’, format: ‘a4’, orientation: ‘portrait’ }
};html2pdf().set(opt).from(element).save();
}function toggleDarkMode() {
document.documentElement.classList.toggle(‘dark’);
}// — JAVASCRIPT SEPARATION END —
Service status: This AI-powered tool currently has an unconfigured API connection and may not generate results. We are reviewing its integration. Please do not rely on its output until functionality is verified.
Recipeย Generator: Overview and Usage Tips Recipe Generator is designed to suggest cooking ideas based on ingredients and preferences entered by the user. Generated recipes, when available, should be reviewed for ingredient quantities, cooking temperatures, food allergies and safe preparation. The AI service is currently unconfigured, as noted above.
Steps to get started Enter ingredients you have available and any dietary preferences supported by the form. Choose the available recipe settings and request a suggestion. If a recipe is generated, verify measurements, cooking times, allergen information and safe cooking temperatures before following it. Related resources Try Meta Tags Analyzer or Word to PDF for another document or digital task.