Asynchronous AI image generation library with proxy support.
Project description
ImageGenToolKit
ImageGenToolKit is a Python library for asynchronous AI image generation with built-in proxy support. This library uses the MagicHour AI platform and handles proxies automatically, making it ideal for generating images in environments with restricted or rate-limited access.
Features
- Asynchronous: Fully async operations for speed and scalability.
- Proxy Support: Automatically fetches and rotates HTTP proxies.
- Customizable: Allows prompt-based image generation with configurable orientation.
Installation
Install the library using pip:
pip install ImageGenToolKit
Usage
Here’s how to use the library to generate AI-generated images.
Basic Example
import asyncio from ImageGenToolKit import AIImageGeneratorAsyncasync def main(): # Initialize the image generator gen = AIImageGeneratorAsync()
# Generate an image prompt = "A futuristic cityscape with glowing neon lights" urls = await gen.generate_image(prompt, orientation="landscape") # Print the image URLs print("Generated Image URLs:", urls)Run the async function
asyncio.run(main())
Output Example
Generated Image URLs: [
"https://example.com/image1.png",
"https://example.com/image2.png"
]
Customizing Orientation
You can specify the orientation as "portrait", "landscape", or "square":
urls = await gen.generate_image("A serene mountain lake", orientation="portrait")
Advanced Features
Handling Proxies
The library automatically fetches and uses proxies. You can also fetch proxies manually if needed:
await gen.fetch_proxies()
print(gen.proxy_list) # List of fetched proxies
Error Handling
Make sure to handle exceptions in case of network issues or invalid proxies:
try:
urls = await gen.generate_image("A fantasy dragon in flight")
print(urls)
except Exception as e:
print("Error generating image:", e)
Contributing
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name. - Commit your changes:
git commit -m "Add new feature". - Push to the branch:
git push origin feature-name. - Submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to reach out with any questions or suggestions! рџљЂ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ImageGenToolKit-0.1.1.tar.gz.
File metadata
- Download URL: ImageGenToolKit-0.1.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0dacaed5804d9a77f1d2efdca998789caea0b2446e0c6eb53e7c208327ff2ab
|
|
| MD5 |
54f8aa0c96e25580ada82fd23cd6dd7d
|
|
| BLAKE2b-256 |
8d3fcec43e662f482c58002eae3984738fbb959c0b820bf6618fc5591e2bf382
|
File details
Details for the file ImageGenToolKit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ImageGenToolKit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9da3448713aebcf8b81717fa8591bbcf6f04a99e1f0c52d0cdb5cadaaf2ac6fc
|
|
| MD5 |
a4f4b36ce8392663e51c8da5bce3d8d9
|
|
| BLAKE2b-256 |
77b490248f7d47c873d2c54750fbb7aa6050679a17a0f27236318a6c8c281b57
|