A convenient console tool for generating images based on a text description (promt) in Python using the g4f library. It supports several models: Bing, DeepAI, Flux and Pollinations.

-
Choosing a generation model
- Bing (recommended)
- DeepAI
- Flux
- Pollinations
-
The main cycle
-
User input of promt
-
Commands:
exit
,выход
,quit
— terminate the script/model
— change the model without restarting
-
-
Result generation and output
-
API request:
response = client.images.generate( model=model, prompt=prompt, response_format="url" ) image_url = response.data[0].url
-
Auto-copying of the link to the clipboard (
pyperclip.copy
) -
Beep on successful generation (
winsound.MessageBeep
)
-
-
Error handling
-
Interception of exceptions and message output:
Generation error: <error text>
-
- Python 3.7+
- Windows (for
winsound
operation)
g4f
pyperclip
winsound
(included in the Windows standard library)
-
Clone the repository:
git clone https://github.com/KiriVoll/AI-Picture-Generator.git cd AI-Picture-Generator
-
Install the dependencies:
pip install g4f pyperclip
-
Run the script with the command:
python AIpictureGenerator.py
-
At the first launch, select the generation model (1-4).
-
Enter the promt in the console and press Enter.
-
After generation:
- The link to the image will be copied to the clipboard.
- You will hear a beep.
-
To change the model, enter the command
/model
. -
Use
quit
,exit
orвыход
to exit.
The script intercepts all exceptions that occur when accessing the API and outputs them in a clear format. This allows you to continue working after an unsuccessful request.
- Response formats: add support for
base64
or byte data - GUI: implement a graphical interface with the
tkinter
orPyQt
libraries - Logging: save the history of requests and responses to a file
- Parallel queries: implement batch generation of promts
If you find this useful, feel free to star ⭐ the repo or share your improvements!