A responsive web application that helps users create well-structured prompts for AI image generation tools such as DALL-E, Midjourney, Stable Diffusion, etc. Built with Next.js, TypeScript, and Tailwind CSS.
Clone the repository:
git clone https://github.com/AjinND/image-prompt-generator.git
cd image-prompt-generator
Install dependencies:
npm install
# or
yarn install
Set up environment variables:
Create a .env.local
file in the root directory with:
HUGGINGFACE_API_KEY=your_huggingface_api_key
Run the development server:
npm run dev
# or
yarn dev
Open http://localhost:3000 in your browser to see the application.
image-prompt-generator/
├── components/
│ ├── PromptBuilder.tsx # Main component for building prompts
│ ├── PromptDisplay.tsx # Component to display and copy prompts
│ └── PromptHistory.tsx # Component for showing prompt history
├── pages/
│ ├── _app.tsx # Next.js application wrapper
│ └── index.tsx # Main page of the application
├── app/
│ └── api/
│ └── generate-prompt/
│ └── route.ts # API route for AI prompt enhancement
├── public/ # Static assets
├── styles/ # CSS styles
├── next.config.js # Next.js configuration
├── tailwind.config.js # Tailwind CSS configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Project dependencies
The application uses Hugging Face's Gustavosta/MagicPrompt-Stable-Diffusion
model to enhance your base prompts. When you click "Generate Prompt":
/api/generate-prompt
npm run build
# or
yarn build
This will create an optimized production build in the .next
folder.
This application can be deployed to various platforms:
npm install -g vercel
vercel
Make sure to set the HUGGINGFACE_API_KEY
environment variable in your Vercel project settings.
Configure your netlify.toml
file or deploy through the Netlify UI. Add the required environment variables in the Netlify dashboard.
npm run build
npm run start
Modify the promptCategories
array in PromptBuilder.tsx
to add new categories or options:
const promptCategories: PromptCategory[] = [
// Existing categories...
{
id: 'newCategory',
label: 'New Category Name',
multiSelect: true, // or false
options: [
{ id: 'option1', label: 'Option 1', examples: ['example1', 'example2'] },
// More options...
]
}
];
To change how prompts are generated, modify the generatePrompt
function in PromptBuilder.tsx
.
To adjust how the AI enhances prompts, modify the parameters in the route.ts
file:
parameters: {
max_length: 150, // Adjust for longer or shorter outputs
temperature: 0.7, // Higher for more creative, lower for more predictable
top_p: 0.9, // Controls diversity of outputs
do_sample: true, // Enables sampling
repetition_penalty: 1.2, // Prevents repetitive text
}
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.