Are you ready to unleash your creativity and generate captivating prompts for your AI art projects? With our Simple Prompt Generator API based on the powerful FredZhang7 distilgpt2-stable-diffusion-v2 model, you can transform a simple idea into rich, detailed prompts that can enhance your artistic outputs. In this guide, we’ll walk you through the installation, usage, and some troubleshooting tips to get you started!
Installation and Usage
To begin your journey with the Prompt Generator API, follow these simple steps:
- Install the necessary dependencies:
pip install --upgrade torch transformers flask flask_restful flask_limiter - Clone the repository:
git clone https://github.com/jordipprompt-generator-api.git - Run the main application:
python3 main.py - Send a POST request to the API:
curl http://127.0.0.1:5000/generate -H "Content-Type: application/json" -d '{"prompt": "cat with sunglasses"}' -X POST
Understanding the Code with an Analogy
Think of the Prompt Generator API as a creative chef in a kitchen. You provide the chef (the API) with a basic ingredient list (the initial prompt), for instance, “cat with sunglasses.” The chef then utilizes his experience and secret spices (the power of the distilgpt2 AI model) to create a gourmet dish (a detailed prompt). Just like chefs may modify their recipes based on preferences and available ingredients, you can customize the prompts by adjusting optional parameters.
Required and Optional Arguments
Required argument:
- prompt: The beginning of your prompt.
Optional arguments:
- temperature: Controls the diversity of the output. A higher temperature yields varied results but might compromise coherence. Default is
0.9. - top_k: Determines the number of tokens sampled at each step. Default is
80. - max_length: Sets the maximum token count for the output. Default is
80. - repetition_penalty: The penalty for repeating tokens. Default is
1.2. - num_return_sequences: The number of results the API will generate. Default is
5.
Features
The API boasts several useful features, including:
- Blacklist: Customize your outputs by listing words you want to exclude in
blacklist.txt. Simply add one term per line. - Usage Limits: The API limits requests to prevent overload by a single user, ensuring smoother performance.
Troubleshooting Tips
If you encounter issues during your setup or usage, consider the following troubleshooting ideas:
- Ensure that all dependencies are correctly installed and are the latest versions.
- Check if the API is running; you should see console logs when you execute
python3 main.py. - Ensure that the POST request is formatted correctly, with proper headers and JSON data.
- Double-check the port number in your request; by default, it runs on
5000.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

