ImageGenToolkit
init
- api_key (Optional[str]): The API key for authenticating with the image model service. (default: :obj:
None
) - url (Optional[str]): The url to the image model service. (default: :obj:
None
) - model (Optional[str]): The model to use. (default: :obj:
"dall-e-3"
) - timeout (Optional[float]): The timeout value for API requests in seconds. If None, no timeout is applied. (default: :obj:
None
) size (Optional[Literal[“256x256”, “512x512”, “1024x1024”, “1536x1024”, “1024x1536”, “1792x1024”, “1024x1792”, “auto”]]): The size of the image to generate. (default: :obj:"1024x1024"
) quality (Optional[Literal[“auto”, “low”, “medium”, “high”, “standard”, “hd”]]):The quality of the image to generate. Different models support different values. (default: :obj:"standard"
) - response_format (
Optional[Literal["url", "b64_json"]]
): The format of the response.(default: :obj:"b64_json"
) - background (
Optional[Literal["transparent", "opaque", "auto"]]
): The background of the image.(default: :obj:"auto"
) - style (
Optional[Literal["vivid", "natural"]]
): The style of the image.(default: :obj:None
) - working_directory (Optional[str]): The path to save the generated image.(default: :obj:
"image_save"
)
base64_to_image
- base64_string (str): The base64 encoded string of the image.
_build_base_params
- prompt (str): The text prompt for the image operation.
- n (Optional[int]): The number of images to generate.
_handle_api_response
- response: The response object from image model API.
- image_name (Union[str, List[str]]): Name(s) for the saved image file(s). If str, the same name is used for all images (will cause error for multiple images). If list, must have exactly the same length as the number of images generated.
- operation (str): Operation type for success message (“generated”).
generate_image
__INLINE_CODE_0__
response
formats) or an image URL will be returned (for __INLINE_CODE_1__
response
formats).
Parameters:
- prompt (str): The text prompt to generate the image.
- image_name (Union[str, List[str]]): The name(s) of the image(s) to save. The image name must end with
.png
. If str: same name used for all images (causes error if n > 1). If list: must match the number of images being generated (n parameter). (default: :obj:"image.png"
) - n (int): The number of images to generate. (default: :obj:
1
) (default: 1)
get_grok_credentials
- url (str): The base URL for the Grok API.
- api_key (str): The API key for the Grok API.
get_openai_credentials
- url (str): The base URL for the OpenAI API.
- api_key (str): The API key for the OpenAI API.