griptape_cloud_image_generation_driver
ALLOWED_IMAGE_SIZES = ('1024x1024', '1536x1024', '1024x1536')
module-attribute
DEFAULT_MODEL = 'gpt-image-1-mini'
module-attribute
SUPPORTED_MODELS = (DEFAULT_MODEL, 'gpt-image-1.5')
module-attribute
GriptapeCloudImageGenerationDriver
Bases: BaseImageGenerationDriver
Driver for the OpenAI image generation API.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
str
|
Image generation model. Supported values: 'gpt-image-1-mini', 'gpt-image-1.5'. Defaults to 'gpt-image-1-mini'. |
base_url |
str
|
Griptape Cloud API URL. |
api_key |
str
|
Griptape Cloud API Key. |
headers |
dict
|
Headers for Griptape Cloud request. Overwrites api_key. |
image_size |
Optional[Literal['1024x1024', '1536x1024', '1024x1536']]
|
Size of the generated image. Must be one of: 1024x1024, 1024x1536, 1536x1024. |
quality |
Optional[Literal['low', 'medium', 'high']]
|
Optional quality level. Accepts 'low', 'medium', 'high'. |
background |
Optional[Literal['transparent', 'opaque', 'auto']]
|
Optional background setting. Can be either 'transparent', 'opaque', or 'auto'. |
moderation |
Optional[Literal['low', 'auto']]
|
Optional moderation level. Can be either 'low' or 'auto'. |
output_compression |
Optional[int]
|
Optional compression level. Can be an integer between 0 and 100. |
output_format |
Optional[Literal['png', 'jpeg']]
|
Optional output format. Can be either 'png' or 'jpeg'. |
Source code in griptape/drivers/image_generation/griptape_cloud_image_generation_driver.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
api_key = field(default=Factory(lambda: os.environ['GT_CLOUD_API_KEY']))
class-attribute
instance-attribute
background = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
base_url = field(default=Factory(lambda: os.getenv('GT_CLOUD_BASE_URL', 'https://cloud.griptape.ai')))
class-attribute
instance-attribute
headers = field(default=Factory(lambda self: {'Authorization': f'Bearer {self.api_key}'}, takes_self=True), kw_only=True)
class-attribute
instance-attribute
image_size = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
model = field(default=DEFAULT_MODEL, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
moderation = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
output_compression = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
output_format = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
quality = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
_build_driver_configuration()
Builds parameters while considering field metadata and None values.
Field will be added to the params dictionary if all conditions are met
- The field value is not None
- The model_allowlist is None or the model is in the allowlist
Source code in griptape/drivers/image_generation/griptape_cloud_image_generation_driver.py
try_image_inpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/griptape_cloud_image_generation_driver.py
try_image_outpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/griptape_cloud_image_generation_driver.py
try_image_variation(prompts, image, negative_prompts=None)
Source code in griptape/drivers/image_generation/griptape_cloud_image_generation_driver.py
try_text_to_image(prompts, negative_prompts=None)
Source code in griptape/drivers/image_generation/griptape_cloud_image_generation_driver.py
validate_image_size(attribute, value)
Validates the image size.
Must be one of 1024x1024, 1536x1024 (landscape), or 1024x1536 (portrait).