66from typing import List , Union
77from ._config import ClientConfig
88
9+
910class AdvanceConfig (TypedDict ):
1011 negative_prompt : NotRequired [str ]
1112 guidance : NotRequired [int ]
1213 seed : NotRequired [int ]
1314
15+
1416class ImageGenerationParams (TypedDict ):
1517 prompt : Required [str ]
1618 """
1719 The text to generate the image from.
1820 """
19- aspect_ratio : NotRequired [Literal ["1:1" , "16:9" , "21:9" , "3:2" , "2:3" , "4:5" , "5:4" , "3:4" , "4:3" , "9:16" , "9:21" ]]
21+ aspect_ratio : NotRequired [
22+ Literal [
23+ "1:1" ,
24+ "16:9" ,
25+ "21:9" ,
26+ "3:2" ,
27+ "2:3" ,
28+ "4:5" ,
29+ "5:4" ,
30+ "3:4" ,
31+ "4:3" ,
32+ "9:16" ,
33+ "9:21" ,
34+ ]
35+ ]
2036 """
2137 The aspect ratio of the image. The default is 1:1.
2238 """
@@ -55,6 +71,7 @@ class ImageGenerationParams(TypedDict):
5571
5672 return_type : NotRequired [Literal ["url" , "binary" , "base64" ]]
5773
74+
5875class ImageGenerationResponse (TypedDict ):
5976 success : bool
6077 """
@@ -65,6 +82,7 @@ class ImageGenerationResponse(TypedDict):
6582 The generated image as a blob.
6683 """
6784
85+
6886class ImageGeneration (ClientConfig ):
6987 config : RequestConfig
7088
@@ -74,23 +92,28 @@ def __init__(
7492 api_url : str ,
7593 disable_request_logging : Union [bool , None ] = False ,
7694 ):
77- super ().__init__ (api_key , api_url , disable_request_logging = disable_request_logging )
95+ super ().__init__ (
96+ api_key , api_url , disable_request_logging = disable_request_logging
97+ )
7898 self .config = RequestConfig (
7999 api_url = api_url ,
80100 api_key = api_key ,
81101 disable_request_logging = disable_request_logging ,
82102 )
83103
84- def image_generation (self , params : ImageGenerationParams ) -> ImageGenerationResponse :
104+ def image_generation (
105+ self , params : ImageGenerationParams
106+ ) -> ImageGenerationResponse :
85107 path = "/ai/image_generation"
86108 resp = Request (
87109 config = self .config ,
88110 path = path ,
89- params = cast (Dict [Any , Any ], params ), # type: ignore
111+ params = cast (Dict [Any , Any ], params ), # type: ignore
90112 verb = "post" ,
91113 ).perform ()
92114 return resp
93-
115+
116+
94117class AsyncImageGeneration (ClientConfig ):
95118 config : RequestConfig
96119
@@ -100,23 +123,23 @@ def __init__(
100123 api_url : str ,
101124 disable_request_logging : Union [bool , None ] = False ,
102125 ):
103- super ().__init__ (api_key , api_url , disable_request_logging = disable_request_logging )
126+ super ().__init__ (
127+ api_key , api_url , disable_request_logging = disable_request_logging
128+ )
104129 self .config = RequestConfig (
105130 api_url = api_url ,
106131 api_key = api_key ,
107132 disable_request_logging = disable_request_logging ,
108133 )
109134
110- async def image_generation (self , params : ImageGenerationParams ) -> ImageGenerationResponse :
135+ async def image_generation (
136+ self , params : ImageGenerationParams
137+ ) -> ImageGenerationResponse :
111138 path = "/ai/image_generation"
112139 resp = await AsyncRequest (
113140 config = self .config ,
114141 path = path ,
115- params = cast (Dict [Any , Any ], params ), # type: ignore
142+ params = cast (Dict [Any , Any ], params ), # type: ignore
116143 verb = "post" ,
117144 ).perform ()
118145 return resp
119-
120-
121-
122-
0 commit comments