KandinskyLib
A library for interacting with the Kandinsky AI image generation API.
Installation
You can install the library using pip:
pip install kandinskylib
Usage
Generator
from kandinskylib import Kandinsky
api_key = 'your_api_key'
secret_key = 'your_secret_key'
client = Kandinsky(api_key, secret_key)
# Generate an image
response = client.generate_image(
prompt="A cat in sunglasses",
scale="3:2",
style="UHD",
negative_prompt="Bright colors, neon colors",
path="./image/generated_image.jpg"
)
print(response)
Available Styles
from kandinskylib import styles
# List available styles
styles_response = styles()
print(styles_response)
Documentation
class Kandinsky
__init__(self, api_key, secret_key)
Initializes the client for API interaction.
-
api_key(str): Your API key. -
secret_key(str): Your secret key.get_model(self)Fetches the model ID for image generation. -
Returns:
str- The model ID orNonein case of an error.generate_image(self, prompt, scale='1:1', style='UHD', negative_prompt="Яркие цвета, кислотные цвета", path='./image/generated_image.jpg')Generates an image based on a text prompt. -
prompt(str): Text prompt for image generation. The length should be less than 1000 characters. -
scale(str): Aspect ratio of the image in the format 'w '. Default is '1:1'. -
style(str): Image style. Default is 'UHD'. -
negative_prompt(str): Negative text prompt to exclude unwanted elements. -
path(str): Path to save the generated image. Default is './image/generated_image.jpg'. -
Returns:
str- Message about the result of the generation._check_generation(self, request_id, attempts=10, delay=10)
Checks the status of image generation.
request_id(str): Generation request ID.attempts(int): Number of status check attempts. Default is 10.delay(int): Delay between status check attempts in seconds. Default is 10.- Returns:
list- List of generated images in base64 format or raises an exception in case of an error.
_get_max_resolution(self, scale)
Determines the maximum resolution of the image based on the aspect ratio.
scale(str): Aspect ratio in the format 'w'.- Returns:
tuple- Width and height of the image.
_save_image(self, base64_str, output_file)
Saves the image to a file.
base64_str(str): Base64 string of the image.output_file(str): Path to save the image.
def styles()
Fetches the list of available styles for image generation.
- Returns:
list- List of available styles.
License
This project is licensed under the terms of the MIT License - see the LICENSE file for details.
Metadata
Release files for kandinskylib 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kandinskylib-0.1.4.tar.gz | 5.1 kB | Without provenance | Details for kandinskylib-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kandinskylib-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for kandinskylib-0.1.4-py3-none-any.whl |
Total release size: 10.5 kB
Release files / kandinskylib-0.1.4.tar.gz
| Download URL | kandinskylib-0.1.4.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2c25c8522399e660c5e5e295b27fbedcdccdeac09ab882c96a2801d3004b47b
|
|
BLAKE2b-256 checksum How to use checksums |
68a6754475a74481538ec4c4e56c87f626eb6f2aca8eec672b7e9dd573d5b74b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Release files / kandinskylib-0.1.4-py3-none-any.whl
| Download URL | kandinskylib-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7dca842ab3ef1c9d86b9629b9c4856933f465b92d682cda24369f0820ff19435
|
|
BLAKE2b-256 checksum How to use checksums |
462d0ded617102c3194bfa5ffcb271111750c438897f072caed3faa46bc9a0fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Security for kandinskylib 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.