@@ -187,6 +187,27 @@ def define_schema(cls):
187187 tooltip = "Seed to determine if node should re-run; "
188188 "actual results are nondeterministic regardless of seed." ,
189189 ),
190+ IO .Combo .Input (
191+ "aspect_ratio" ,
192+ options = [
193+ "auto" ,
194+ "1:1" ,
195+ "2:3" ,
196+ "3:2" ,
197+ "3:4" ,
198+ "4:3" ,
199+ "9:16" ,
200+ "16:9" ,
201+ "9:19.5" ,
202+ "19.5:9" ,
203+ "9:20" ,
204+ "20:9" ,
205+ "1:2" ,
206+ "2:1" ,
207+ ],
208+ optional = True ,
209+ tooltip = "Only allowed when multiple images are connected to the image input." ,
210+ ),
190211 ],
191212 outputs = [
192213 IO .Image .Output (),
@@ -217,13 +238,18 @@ async def execute(
217238 resolution : str ,
218239 number_of_images : int ,
219240 seed : int ,
241+ aspect_ratio : str = "auto" ,
220242 ) -> IO .NodeOutput :
221243 validate_string (prompt , strip_whitespace = True , min_length = 1 )
222244 if model == "grok-imagine-image-pro" :
223245 if get_number_of_images (image ) > 1 :
224246 raise ValueError ("The pro model supports only 1 input image." )
225247 elif get_number_of_images (image ) > 3 :
226248 raise ValueError ("A maximum of 3 input images is supported." )
249+ if aspect_ratio != "auto" and get_number_of_images (image ) == 1 :
250+ raise ValueError (
251+ "Custom aspect ratio is only allowed when multiple images are connected to the image input."
252+ )
227253 response = await sync_op (
228254 cls ,
229255 ApiEndpoint (path = "/proxy/xai/v1/images/edits" , method = "POST" ),
@@ -234,6 +260,7 @@ async def execute(
234260 resolution = resolution .lower (),
235261 n = number_of_images ,
236262 seed = seed ,
263+ aspect_ratio = None if aspect_ratio == "auto" else aspect_ratio ,
237264 ),
238265 response_model = ImageGenerationResponse ,
239266 price_extractor = _extract_grok_price ,
0 commit comments