@@ -328,5 +328,81 @@ internal Dictionary<string, object> ToJson()
328328 }
329329 }
330330
331+ /// <summary>
332+ /// Configuration options for generating images with Gemini models.
333+ /// </summary>
334+ public readonly struct ImageConfig
335+ {
336+ /// <summary>
337+ /// The aspect ratio of generated images.
338+ /// </summary>
339+ public readonly struct AspectRatio
340+ {
341+ public string Value { get ; }
342+
343+ /// <summary>
344+ /// Constructs a custom AspectRatio, instead of one of the presets.
345+ /// Note that the backend model needs to support the requested ratio.
346+ /// </summary>
347+ public AspectRatio ( string value ) { Value = value ; }
348+
349+ public static readonly AspectRatio Square1x1 = new ( "1:1" ) ;
350+ public static readonly AspectRatio Portrait9x16 = new ( "9:16" ) ;
351+ public static readonly AspectRatio Landscape16x9 = new ( "16:9" ) ;
352+ public static readonly AspectRatio Portrait3x4 = new ( "3:4" ) ;
353+ public static readonly AspectRatio Landscape4x3 = new ( "4:3" ) ;
354+ public static readonly AspectRatio Portrait2x3 = new ( "2:3" ) ;
355+ public static readonly AspectRatio Landscape3x2 = new ( "3:2" ) ;
356+ public static readonly AspectRatio Portrait4x5 = new ( "4:5" ) ;
357+ public static readonly AspectRatio Landscape5x4 = new ( "5:4" ) ;
358+ public static readonly AspectRatio Portrait1x4 = new ( "1:4" ) ;
359+ public static readonly AspectRatio Landscape4x1 = new ( "4:1" ) ;
360+ public static readonly AspectRatio Portrait1x8 = new ( "1:8" ) ;
361+ public static readonly AspectRatio Landscape8x1 = new ( "8:1" ) ;
362+ public static readonly AspectRatio Ultrawide21x9 = new ( "21:9" ) ;
363+
364+ public override string ToString ( ) => Value ;
365+ }
366+
367+ /// <summary>
368+ /// The size of images to generate.
369+ /// </summary>
370+ public readonly struct ImageSize
371+ {
372+ public string Value { get ; }
373+
374+ /// <summary>
375+ /// Constructs a custom ImageSize, instead of one of the presets.
376+ /// Note that the backend model needs to support the requested size.
377+ /// </summary>
378+ public ImageSize ( string value ) { Value = value ; }
379+
380+ public static readonly ImageSize Size512 = new ( "512" ) ;
381+ public static readonly ImageSize Size1K = new ( "1K" ) ;
382+ public static readonly ImageSize Size2K = new ( "2K" ) ;
383+ public static readonly ImageSize Size4K = new ( "4K" ) ;
384+
385+ public override string ToString ( ) => Value ;
386+ }
331387
388+ public AspectRatio ? Ratio { get ; }
389+ public ImageSize ? Size { get ; }
390+
391+ /// <summary>
392+ /// Creates a new `ImageConfig` with the given settings.
393+ /// </summary>
394+ public ImageConfig ( AspectRatio ? aspectRatio = null , ImageSize ? imageSize = null )
395+ {
396+ Ratio = aspectRatio ;
397+ Size = imageSize ;
398+ }
399+
400+ internal Dictionary < string , object > ToJson ( )
401+ {
402+ Dictionary < string , object > jsonDict = new ( ) ;
403+ if ( Ratio ? . Value is string aspectRatio ) jsonDict [ "aspectRatio" ] = aspectRatio ;
404+ if ( Size ? . Value is string imageSize ) jsonDict [ "imageSize" ] = imageSize ;
405+ return jsonDict ;
406+ }
407+ }
332408}
0 commit comments