magic_hour 0.9.5__py3-none-any.whl → 0.44.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. magic_hour/README.md +34 -0
  2. magic_hour/__init__.py +1 -1
  3. magic_hour/client.py +8 -17
  4. magic_hour/environment.py +13 -1
  5. magic_hour/helpers/__init__.py +4 -0
  6. magic_hour/helpers/download.py +77 -0
  7. magic_hour/helpers/logger.py +8 -0
  8. magic_hour/resources/v1/README.md +32 -0
  9. magic_hour/resources/v1/ai_clothes_changer/README.md +94 -5
  10. magic_hour/resources/v1/ai_clothes_changer/client.py +161 -16
  11. magic_hour/resources/v1/ai_face_editor/README.md +195 -0
  12. magic_hour/resources/v1/ai_face_editor/__init__.py +4 -0
  13. magic_hour/resources/v1/ai_face_editor/client.py +324 -0
  14. magic_hour/resources/v1/ai_gif_generator/README.md +116 -0
  15. magic_hour/resources/v1/ai_gif_generator/__init__.py +4 -0
  16. magic_hour/resources/v1/ai_gif_generator/client.py +257 -0
  17. magic_hour/resources/v1/ai_headshot_generator/README.md +81 -3
  18. magic_hour/resources/v1/ai_headshot_generator/client.py +167 -18
  19. magic_hour/resources/v1/ai_image_editor/README.md +125 -0
  20. magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
  21. magic_hour/resources/v1/ai_image_editor/client.py +290 -0
  22. magic_hour/resources/v1/ai_image_generator/README.md +99 -5
  23. magic_hour/resources/v1/ai_image_generator/client.py +170 -24
  24. magic_hour/resources/v1/ai_image_upscaler/README.md +89 -3
  25. magic_hour/resources/v1/ai_image_upscaler/client.py +173 -20
  26. magic_hour/resources/v1/ai_meme_generator/README.md +129 -0
  27. magic_hour/resources/v1/ai_meme_generator/__init__.py +4 -0
  28. magic_hour/resources/v1/ai_meme_generator/client.py +253 -0
  29. magic_hour/resources/v1/ai_photo_editor/README.md +119 -4
  30. magic_hour/resources/v1/ai_photo_editor/client.py +199 -18
  31. magic_hour/resources/v1/ai_qr_code_generator/README.md +84 -3
  32. magic_hour/resources/v1/ai_qr_code_generator/client.py +140 -18
  33. magic_hour/resources/v1/ai_talking_photo/README.md +137 -0
  34. magic_hour/resources/v1/ai_talking_photo/__init__.py +4 -0
  35. magic_hour/resources/v1/ai_talking_photo/client.py +326 -0
  36. magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
  37. magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
  38. magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
  39. magic_hour/resources/v1/ai_voice_generator/README.md +112 -0
  40. magic_hour/resources/v1/ai_voice_generator/__init__.py +4 -0
  41. magic_hour/resources/v1/ai_voice_generator/client.py +241 -0
  42. magic_hour/resources/v1/animation/README.md +128 -6
  43. magic_hour/resources/v1/animation/client.py +247 -22
  44. magic_hour/resources/v1/audio_projects/README.md +135 -0
  45. magic_hour/resources/v1/audio_projects/__init__.py +12 -0
  46. magic_hour/resources/v1/audio_projects/client.py +310 -0
  47. magic_hour/resources/v1/audio_projects/client_test.py +520 -0
  48. magic_hour/resources/v1/auto_subtitle_generator/README.md +128 -0
  49. magic_hour/resources/v1/auto_subtitle_generator/__init__.py +4 -0
  50. magic_hour/resources/v1/auto_subtitle_generator/client.py +346 -0
  51. magic_hour/resources/v1/client.py +75 -1
  52. magic_hour/resources/v1/face_detection/README.md +157 -0
  53. magic_hour/resources/v1/face_detection/__init__.py +12 -0
  54. magic_hour/resources/v1/face_detection/client.py +380 -0
  55. magic_hour/resources/v1/face_swap/README.md +137 -9
  56. magic_hour/resources/v1/face_swap/client.py +329 -38
  57. magic_hour/resources/v1/face_swap_photo/README.md +118 -3
  58. magic_hour/resources/v1/face_swap_photo/client.py +199 -14
  59. magic_hour/resources/v1/files/README.md +39 -0
  60. magic_hour/resources/v1/files/client.py +351 -1
  61. magic_hour/resources/v1/files/client_test.py +414 -0
  62. magic_hour/resources/v1/files/upload_urls/README.md +38 -17
  63. magic_hour/resources/v1/files/upload_urls/client.py +38 -34
  64. magic_hour/resources/v1/image_background_remover/README.md +96 -5
  65. magic_hour/resources/v1/image_background_remover/client.py +151 -16
  66. magic_hour/resources/v1/image_projects/README.md +82 -10
  67. magic_hour/resources/v1/image_projects/__init__.py +10 -2
  68. magic_hour/resources/v1/image_projects/client.py +154 -16
  69. magic_hour/resources/v1/image_projects/client_test.py +527 -0
  70. magic_hour/resources/v1/image_to_video/README.md +96 -11
  71. magic_hour/resources/v1/image_to_video/client.py +282 -38
  72. magic_hour/resources/v1/lip_sync/README.md +112 -9
  73. magic_hour/resources/v1/lip_sync/client.py +288 -34
  74. magic_hour/resources/v1/photo_colorizer/README.md +107 -0
  75. magic_hour/resources/v1/photo_colorizer/__init__.py +4 -0
  76. magic_hour/resources/v1/photo_colorizer/client.py +248 -0
  77. magic_hour/resources/v1/text_to_video/README.md +96 -7
  78. magic_hour/resources/v1/text_to_video/client.py +204 -18
  79. magic_hour/resources/v1/video_projects/README.md +81 -9
  80. magic_hour/resources/v1/video_projects/__init__.py +10 -2
  81. magic_hour/resources/v1/video_projects/client.py +151 -14
  82. magic_hour/resources/v1/video_projects/client_test.py +527 -0
  83. magic_hour/resources/v1/video_to_video/README.md +119 -15
  84. magic_hour/resources/v1/video_to_video/client.py +299 -46
  85. magic_hour/types/models/__init__.py +92 -56
  86. magic_hour/types/models/v1_ai_clothes_changer_create_response.py +33 -0
  87. magic_hour/types/models/v1_ai_face_editor_create_response.py +33 -0
  88. magic_hour/types/models/v1_ai_gif_generator_create_response.py +33 -0
  89. magic_hour/types/models/v1_ai_headshot_generator_create_response.py +33 -0
  90. magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
  91. magic_hour/types/models/v1_ai_image_generator_create_response.py +33 -0
  92. magic_hour/types/models/v1_ai_image_upscaler_create_response.py +33 -0
  93. magic_hour/types/models/v1_ai_meme_generator_create_response.py +33 -0
  94. magic_hour/types/models/v1_ai_photo_editor_create_response.py +33 -0
  95. magic_hour/types/models/v1_ai_qr_code_generator_create_response.py +33 -0
  96. magic_hour/types/models/v1_ai_talking_photo_create_response.py +35 -0
  97. magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
  98. magic_hour/types/models/v1_ai_voice_generator_create_response.py +27 -0
  99. magic_hour/types/models/v1_animation_create_response.py +35 -0
  100. magic_hour/types/models/v1_audio_projects_get_response.py +72 -0
  101. magic_hour/types/models/v1_audio_projects_get_response_downloads_item.py +19 -0
  102. magic_hour/types/models/{get_v1_image_projects_id_response_error.py → v1_audio_projects_get_response_error.py} +2 -2
  103. magic_hour/types/models/v1_auto_subtitle_generator_create_response.py +35 -0
  104. magic_hour/types/models/v1_face_detection_create_response.py +25 -0
  105. magic_hour/types/models/v1_face_detection_get_response.py +45 -0
  106. magic_hour/types/models/v1_face_detection_get_response_faces_item.py +25 -0
  107. magic_hour/types/models/v1_face_swap_create_response.py +35 -0
  108. magic_hour/types/models/v1_face_swap_photo_create_response.py +33 -0
  109. magic_hour/types/models/v1_files_upload_urls_create_response.py +24 -0
  110. magic_hour/types/models/{post_v1_files_upload_urls_response_items_item.py → v1_files_upload_urls_create_response_items_item.py} +2 -2
  111. magic_hour/types/models/v1_image_background_remover_create_response.py +33 -0
  112. magic_hour/types/models/{get_v1_image_projects_id_response.py → v1_image_projects_get_response.py} +20 -18
  113. magic_hour/types/models/{get_v1_video_projects_id_response_downloads_item.py → v1_image_projects_get_response_downloads_item.py} +1 -1
  114. magic_hour/types/models/{get_v1_video_projects_id_response_error.py → v1_image_projects_get_response_error.py} +2 -2
  115. magic_hour/types/models/v1_image_to_video_create_response.py +35 -0
  116. magic_hour/types/models/v1_lip_sync_create_response.py +35 -0
  117. magic_hour/types/models/v1_photo_colorizer_create_response.py +33 -0
  118. magic_hour/types/models/v1_text_to_video_create_response.py +35 -0
  119. magic_hour/types/models/{get_v1_video_projects_id_response.py → v1_video_projects_get_response.py} +26 -23
  120. magic_hour/types/models/{get_v1_video_projects_id_response_download.py → v1_video_projects_get_response_download.py} +1 -1
  121. magic_hour/types/models/{get_v1_image_projects_id_response_downloads_item.py → v1_video_projects_get_response_downloads_item.py} +1 -1
  122. magic_hour/types/models/v1_video_projects_get_response_error.py +25 -0
  123. magic_hour/types/models/v1_video_to_video_create_response.py +35 -0
  124. magic_hour/types/params/__init__.py +422 -176
  125. magic_hour/types/params/v1_ai_clothes_changer_create_body.py +40 -0
  126. magic_hour/types/params/v1_ai_clothes_changer_create_body_assets.py +58 -0
  127. magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
  128. magic_hour/types/params/v1_ai_face_editor_create_body.py +52 -0
  129. magic_hour/types/params/v1_ai_face_editor_create_body_assets.py +33 -0
  130. magic_hour/types/params/v1_ai_face_editor_create_body_style.py +137 -0
  131. magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
  132. magic_hour/types/params/v1_ai_gif_generator_create_body.py +47 -0
  133. magic_hour/types/params/{post_v1_ai_image_generator_body_style.py → v1_ai_gif_generator_create_body_style.py} +5 -5
  134. magic_hour/types/params/v1_ai_headshot_generator_create_body.py +49 -0
  135. magic_hour/types/params/v1_ai_headshot_generator_create_body_assets.py +33 -0
  136. magic_hour/types/params/v1_ai_headshot_generator_create_body_style.py +27 -0
  137. magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
  138. magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
  139. magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +47 -0
  140. magic_hour/types/params/v1_ai_image_editor_create_body_style.py +41 -0
  141. magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +28 -0
  142. magic_hour/types/params/{post_v1_ai_image_generator_body.py → v1_ai_image_generator_create_body.py} +17 -11
  143. magic_hour/types/params/v1_ai_image_generator_create_body_style.py +127 -0
  144. magic_hour/types/params/v1_ai_image_upscaler_create_body.py +59 -0
  145. magic_hour/types/params/v1_ai_image_upscaler_create_body_assets.py +33 -0
  146. magic_hour/types/params/{post_v1_ai_image_upscaler_body_style.py → v1_ai_image_upscaler_create_body_style.py} +4 -4
  147. magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
  148. magic_hour/types/params/v1_ai_meme_generator_create_body.py +37 -0
  149. magic_hour/types/params/v1_ai_meme_generator_create_body_style.py +73 -0
  150. magic_hour/types/params/{post_v1_ai_photo_editor_body.py → v1_ai_photo_editor_create_body.py} +15 -15
  151. magic_hour/types/params/v1_ai_photo_editor_create_body_assets.py +33 -0
  152. magic_hour/types/params/{post_v1_ai_photo_editor_body_style.py → v1_ai_photo_editor_create_body_style.py} +20 -4
  153. magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
  154. magic_hour/types/params/v1_ai_qr_code_generator_create_body.py +45 -0
  155. magic_hour/types/params/{post_v1_ai_qr_code_generator_body_style.py → v1_ai_qr_code_generator_create_body_style.py} +4 -4
  156. magic_hour/types/params/v1_ai_talking_photo_create_body.py +68 -0
  157. magic_hour/types/params/v1_ai_talking_photo_create_body_assets.py +46 -0
  158. magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +44 -0
  159. magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
  160. magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
  161. magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
  162. magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
  163. magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
  164. magic_hour/types/params/v1_ai_voice_generator_create_body.py +40 -0
  165. magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +440 -0
  166. magic_hour/types/params/{post_v1_animation_body.py → v1_animation_create_body.py} +16 -16
  167. magic_hour/types/params/{post_v1_animation_body_assets.py → v1_animation_create_body_assets.py} +15 -5
  168. magic_hour/types/params/{post_v1_animation_body_style.py → v1_animation_create_body_style.py} +13 -10
  169. magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
  170. magic_hour/types/params/v1_auto_subtitle_generator_create_body.py +78 -0
  171. magic_hour/types/params/v1_auto_subtitle_generator_create_body_assets.py +33 -0
  172. magic_hour/types/params/v1_auto_subtitle_generator_create_body_style.py +56 -0
  173. magic_hour/types/params/v1_auto_subtitle_generator_create_body_style_custom_config.py +86 -0
  174. magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
  175. magic_hour/types/params/v1_face_detection_create_body.py +44 -0
  176. magic_hour/types/params/v1_face_detection_create_body_assets.py +33 -0
  177. magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
  178. magic_hour/types/params/v1_face_swap_create_body.py +92 -0
  179. magic_hour/types/params/v1_face_swap_create_body_assets.py +91 -0
  180. magic_hour/types/params/v1_face_swap_create_body_assets_face_mappings_item.py +44 -0
  181. magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
  182. magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
  183. magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
  184. magic_hour/types/params/v1_face_swap_photo_create_body.py +40 -0
  185. magic_hour/types/params/v1_face_swap_photo_create_body_assets.py +76 -0
  186. magic_hour/types/params/v1_face_swap_photo_create_body_assets_face_mappings_item.py +44 -0
  187. magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
  188. magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
  189. magic_hour/types/params/v1_files_upload_urls_create_body.py +36 -0
  190. magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +38 -0
  191. magic_hour/types/params/v1_image_background_remover_create_body.py +40 -0
  192. magic_hour/types/params/v1_image_background_remover_create_body_assets.py +49 -0
  193. magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
  194. magic_hour/types/params/v1_image_to_video_create_body.py +101 -0
  195. magic_hour/types/params/v1_image_to_video_create_body_assets.py +33 -0
  196. magic_hour/types/params/v1_image_to_video_create_body_style.py +53 -0
  197. magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
  198. magic_hour/types/params/v1_lip_sync_create_body.py +100 -0
  199. magic_hour/types/params/{post_v1_lip_sync_body_assets.py → v1_lip_sync_create_body_assets.py} +15 -5
  200. magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
  201. magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
  202. magic_hour/types/params/v1_photo_colorizer_create_body.py +40 -0
  203. magic_hour/types/params/v1_photo_colorizer_create_body_assets.py +33 -0
  204. magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
  205. magic_hour/types/params/v1_text_to_video_create_body.py +78 -0
  206. magic_hour/types/params/v1_text_to_video_create_body_style.py +43 -0
  207. magic_hour/types/params/v1_video_to_video_create_body.py +101 -0
  208. magic_hour/types/params/{post_v1_video_to_video_body_assets.py → v1_video_to_video_create_body_assets.py} +9 -4
  209. magic_hour/types/params/{post_v1_video_to_video_body_style.py → v1_video_to_video_create_body_style.py} +68 -26
  210. magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
  211. magic_hour-0.44.0.dist-info/METADATA +328 -0
  212. magic_hour-0.44.0.dist-info/RECORD +231 -0
  213. magic_hour/core/__init__.py +0 -52
  214. magic_hour/core/api_error.py +0 -56
  215. magic_hour/core/auth.py +0 -314
  216. magic_hour/core/base_client.py +0 -618
  217. magic_hour/core/binary_response.py +0 -23
  218. magic_hour/core/query.py +0 -106
  219. magic_hour/core/request.py +0 -156
  220. magic_hour/core/response.py +0 -293
  221. magic_hour/core/type_utils.py +0 -28
  222. magic_hour/core/utils.py +0 -55
  223. magic_hour/types/models/post_v1_ai_clothes_changer_response.py +0 -25
  224. magic_hour/types/models/post_v1_ai_headshot_generator_response.py +0 -25
  225. magic_hour/types/models/post_v1_ai_image_generator_response.py +0 -25
  226. magic_hour/types/models/post_v1_ai_image_upscaler_response.py +0 -25
  227. magic_hour/types/models/post_v1_ai_photo_editor_response.py +0 -25
  228. magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +0 -25
  229. magic_hour/types/models/post_v1_animation_response.py +0 -25
  230. magic_hour/types/models/post_v1_face_swap_photo_response.py +0 -25
  231. magic_hour/types/models/post_v1_face_swap_response.py +0 -25
  232. magic_hour/types/models/post_v1_files_upload_urls_response.py +0 -21
  233. magic_hour/types/models/post_v1_image_background_remover_response.py +0 -25
  234. magic_hour/types/models/post_v1_image_to_video_response.py +0 -25
  235. magic_hour/types/models/post_v1_lip_sync_response.py +0 -25
  236. magic_hour/types/models/post_v1_text_to_video_response.py +0 -25
  237. magic_hour/types/models/post_v1_video_to_video_response.py +0 -25
  238. magic_hour/types/params/post_v1_ai_clothes_changer_body.py +0 -40
  239. magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +0 -45
  240. magic_hour/types/params/post_v1_ai_headshot_generator_body.py +0 -40
  241. magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +0 -28
  242. magic_hour/types/params/post_v1_ai_image_upscaler_body.py +0 -57
  243. magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +0 -28
  244. magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +0 -28
  245. magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +0 -45
  246. magic_hour/types/params/post_v1_face_swap_body.py +0 -72
  247. magic_hour/types/params/post_v1_face_swap_body_assets.py +0 -52
  248. magic_hour/types/params/post_v1_face_swap_photo_body.py +0 -40
  249. magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +0 -36
  250. magic_hour/types/params/post_v1_files_upload_urls_body.py +0 -31
  251. magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +0 -38
  252. magic_hour/types/params/post_v1_image_background_remover_body.py +0 -40
  253. magic_hour/types/params/post_v1_image_background_remover_body_assets.py +0 -28
  254. magic_hour/types/params/post_v1_image_to_video_body.py +0 -73
  255. magic_hour/types/params/post_v1_image_to_video_body_assets.py +0 -28
  256. magic_hour/types/params/post_v1_image_to_video_body_style.py +0 -37
  257. magic_hour/types/params/post_v1_lip_sync_body.py +0 -80
  258. magic_hour/types/params/post_v1_text_to_video_body.py +0 -57
  259. magic_hour/types/params/post_v1_text_to_video_body_style.py +0 -28
  260. magic_hour/types/params/post_v1_video_to_video_body.py +0 -93
  261. magic_hour-0.9.5.dist-info/METADATA +0 -133
  262. magic_hour-0.9.5.dist-info/RECORD +0 -132
  263. {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
  264. {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,125 @@
1
+ # v1.ai_image_editor
2
+
3
+ ## Module Functions
4
+
5
+ <!-- CUSTOM DOCS START -->
6
+
7
+ ### Ai Image Editor Generate Workflow <a name="generate"></a>
8
+
9
+ The workflow performs the following action
10
+
11
+ 1. upload local assets to Magic Hour storage. So you can pass in a local path instead of having to upload files yourself
12
+ 2. trigger a generation
13
+ 3. poll for a completion status. This is configurable
14
+ 4. if success, download the output to local directory
15
+
16
+ > [!TIP]
17
+ > This is the recommended way to use the SDK unless you have specific needs where it is necessary to split up the actions.
18
+
19
+ #### Parameters
20
+
21
+ In Additional to the parameters listed in the `.create` section below, `.generate` introduces 3 new parameters:
22
+
23
+ - `wait_for_completion` (bool, default True): Whether to wait for the project to complete.
24
+ - `download_outputs` (bool, default True): Whether to download the generated files
25
+ - `download_directory` (str, optional): Directory to save downloaded files (defaults to current directory)
26
+
27
+ #### Synchronous Client
28
+
29
+ ```python
30
+ from magic_hour import Client
31
+ from os import getenv
32
+
33
+ client = Client(token=getenv("API_TOKEN"))
34
+ res = client.v1.ai_image_editor.generate(
35
+ assets={"image_file_path": "/path/to/1234.png"},
36
+ style={"prompt": "Give me sunglasses"},
37
+ name="Ai Image Editor image",
38
+ wait_for_completion=True,
39
+ download_outputs=True,
40
+ download_directory="outputs"
41
+ )
42
+ ```
43
+
44
+ #### Asynchronous Client
45
+
46
+ ```python
47
+ from magic_hour import AsyncClient
48
+ from os import getenv
49
+
50
+ client = AsyncClient(token=getenv("API_TOKEN"))
51
+ res = await client.v1.ai_image_editor.generate(
52
+ assets={"image_file_path": "/path/to/1234.png"},
53
+ style={"prompt": "Give me sunglasses"},
54
+ name="Ai Image Editor image",
55
+ wait_for_completion=True,
56
+ download_outputs=True,
57
+ download_directory="outputs"
58
+ )
59
+ ```
60
+
61
+ <!-- CUSTOM DOCS END -->
62
+
63
+ ### AI Image Editor <a name="create"></a>
64
+
65
+ Edit images with AI. Each edit costs 50 credits.
66
+
67
+ **API Endpoint**: `POST /v1/ai-image-editor`
68
+
69
+ #### Parameters
70
+
71
+ | Parameter | Required | Description | Example |
72
+ | --------------------- | :------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
73
+ | `assets` | ✓ | Provide the assets for image edit | `{"image_file_path": "api-assets/id/1234.png", "image_file_paths": ["api-assets/id/1234.png", "api-assets/id/1235.png"]}` |
74
+ | `└─ image_file_path` | ✗ | Deprecated: Please use `image_file_paths` instead as edits with multiple images are now supported. The image used in the edit. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/1234.png"` |
75
+ | `└─ image_file_paths` | ✗ | The image(s) used in the edit, maximum of 10 images. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `["api-assets/id/1234.png", "api-assets/id/1235.png"]` |
76
+ | `style` | ✓ | | `{"model": "Nano Banana", "prompt": "Give me sunglasses"}` |
77
+ | `└─ model` | ✗ | The AI model to use for image editing. * `Nano Banana` - Precise, realistic edits with consistent results * `Seedream` - Creative, imaginative images with artistic freedom * `default` - Use the model we recommend, which will change over time. This is recommended unless you need a specific model. This is the default behavior. | `"Nano Banana"` |
78
+ | `└─ prompt` | ✓ | The prompt used to edit the image. | `"Give me sunglasses"` |
79
+ | `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Ai Image Editor image"` |
80
+
81
+ #### Synchronous Client
82
+
83
+ ```python
84
+ from magic_hour import Client
85
+ from os import getenv
86
+
87
+ client = Client(token=getenv("API_TOKEN"))
88
+ res = client.v1.ai_image_editor.create(
89
+ assets={
90
+ "image_file_path": "api-assets/id/1234.png",
91
+ "image_file_paths": ["api-assets/id/1234.png", "api-assets/id/1235.png"],
92
+ },
93
+ style={"model": "Nano Banana", "prompt": "Give me sunglasses"},
94
+ name="Ai Image Editor image",
95
+ )
96
+ ```
97
+
98
+ #### Asynchronous Client
99
+
100
+ ```python
101
+ from magic_hour import AsyncClient
102
+ from os import getenv
103
+
104
+ client = AsyncClient(token=getenv("API_TOKEN"))
105
+ res = await client.v1.ai_image_editor.create(
106
+ assets={
107
+ "image_file_path": "api-assets/id/1234.png",
108
+ "image_file_paths": ["api-assets/id/1234.png", "api-assets/id/1235.png"],
109
+ },
110
+ style={"model": "Nano Banana", "prompt": "Give me sunglasses"},
111
+ name="Ai Image Editor image",
112
+ )
113
+ ```
114
+
115
+ #### Response
116
+
117
+ ##### Type
118
+
119
+ [V1AiImageEditorCreateResponse](/magic_hour/types/models/v1_ai_image_editor_create_response.py)
120
+
121
+ ##### Example
122
+
123
+ ```python
124
+ {"credits_charged": 50, "frame_cost": 50, "id": "cuid-example"}
125
+ ```
@@ -0,0 +1,4 @@
1
+ from .client import AiImageEditorClient, AsyncAiImageEditorClient
2
+
3
+
4
+ __all__ = ["AiImageEditorClient", "AsyncAiImageEditorClient"]
@@ -0,0 +1,290 @@
1
+ import typing
2
+
3
+ from magic_hour.helpers.logger import get_sdk_logger
4
+ from magic_hour.resources.v1.files.client import AsyncFilesClient, FilesClient
5
+ from magic_hour.resources.v1.image_projects.client import (
6
+ AsyncImageProjectsClient,
7
+ ImageProjectsClient,
8
+ )
9
+ from magic_hour.types import models, params
10
+ from make_api_request import (
11
+ AsyncBaseClient,
12
+ RequestOptions,
13
+ SyncBaseClient,
14
+ default_request_options,
15
+ to_encodable,
16
+ type_utils,
17
+ )
18
+
19
+
20
+ logger = get_sdk_logger(__name__)
21
+
22
+
23
+ class AiImageEditorClient:
24
+ def __init__(self, *, base_client: SyncBaseClient):
25
+ self._base_client = base_client
26
+
27
+ def generate(
28
+ self,
29
+ *,
30
+ assets: params.V1AiImageEditorGenerateBodyAssets,
31
+ style: params.V1AiImageEditorCreateBodyStyle,
32
+ name: typing.Union[
33
+ typing.Optional[str], type_utils.NotGiven
34
+ ] = type_utils.NOT_GIVEN,
35
+ wait_for_completion: bool = True,
36
+ download_outputs: bool = True,
37
+ download_directory: typing.Optional[str] = None,
38
+ request_options: typing.Optional[RequestOptions] = None,
39
+ ):
40
+ """
41
+ Generate edited image (alias for create with additional functionality).
42
+
43
+ Edit image using AI. Each edit costs 5 credits.
44
+
45
+ Args:
46
+ name: The name of image. This value is mainly used for your own identification of the image.
47
+ assets: Provide the assets for image editor
48
+ style: Image editing parameters
49
+ wait_for_completion: Whether to wait for the image project to complete
50
+ download_outputs: Whether to download the outputs
51
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
52
+ request_options: Additional options to customize the HTTP request
53
+
54
+ Returns:
55
+ V1ImageProjectsGetResponseWithDownloads: The response from the AI Image Editor API with the downloaded paths if `download_outputs` is True.
56
+
57
+ Examples:
58
+ ```py
59
+ response = client.v1.ai_image_editor.generate(
60
+ assets={"image_file_paths": ["path/to/image.png", "path/to/image2.png"]},
61
+ style={"prompt": "Add a sunset background"},
62
+ name="Edited Image",
63
+ wait_for_completion=True,
64
+ download_outputs=True,
65
+ download_directory="outputs/",
66
+ )
67
+ ```
68
+ """
69
+
70
+ file_client = FilesClient(base_client=self._base_client)
71
+
72
+ if "image_file_path" in assets:
73
+ image_file_path = assets["image_file_path"]
74
+ assets["image_file_path"] = file_client.upload_file(file=image_file_path)
75
+
76
+ if "image_file_paths" in assets:
77
+ for image_file_path in assets["image_file_paths"]:
78
+ assets["image_file_paths"] = [
79
+ file_client.upload_file(file=image_file_path)
80
+ for image_file_path in assets["image_file_paths"]
81
+ ]
82
+
83
+ create_response = self.create(
84
+ assets=assets, style=style, name=name, request_options=request_options
85
+ )
86
+ logger.info(f"AI Image Editor response: {create_response}")
87
+
88
+ image_projects_client = ImageProjectsClient(base_client=self._base_client)
89
+ response = image_projects_client.check_result(
90
+ id=create_response.id,
91
+ wait_for_completion=wait_for_completion,
92
+ download_outputs=download_outputs,
93
+ download_directory=download_directory,
94
+ )
95
+
96
+ return response
97
+
98
+ def create(
99
+ self,
100
+ *,
101
+ assets: params.V1AiImageEditorCreateBodyAssets,
102
+ style: params.V1AiImageEditorCreateBodyStyle,
103
+ name: typing.Union[
104
+ typing.Optional[str], type_utils.NotGiven
105
+ ] = type_utils.NOT_GIVEN,
106
+ request_options: typing.Optional[RequestOptions] = None,
107
+ ) -> models.V1AiImageEditorCreateResponse:
108
+ """
109
+ AI Image Editor
110
+
111
+ Edit images with AI. Each edit costs 50 credits.
112
+
113
+ POST /v1/ai-image-editor
114
+
115
+ Args:
116
+ name: The name of image. This value is mainly used for your own identification of the image.
117
+ assets: Provide the assets for image edit
118
+ style: V1AiImageEditorCreateBodyStyle
119
+ request_options: Additional options to customize the HTTP request
120
+
121
+ Returns:
122
+ Success
123
+
124
+ Raises:
125
+ ApiError: A custom exception class that provides additional context
126
+ for API errors, including the HTTP status code and response body.
127
+
128
+ Examples:
129
+ ```py
130
+ client.v1.ai_image_editor.create(
131
+ assets={
132
+ "image_file_path": "api-assets/id/1234.png",
133
+ "image_file_paths": [
134
+ "api-assets/id/1234.png",
135
+ "api-assets/id/1235.png",
136
+ ],
137
+ },
138
+ style={"model": "Nano Banana", "prompt": "Give me sunglasses"},
139
+ name="Ai Image Editor image",
140
+ )
141
+ ```
142
+ """
143
+ _json = to_encodable(
144
+ item={"name": name, "assets": assets, "style": style},
145
+ dump_with=params._SerializerV1AiImageEditorCreateBody,
146
+ )
147
+ return self._base_client.request(
148
+ method="POST",
149
+ path="/v1/ai-image-editor",
150
+ auth_names=["bearerAuth"],
151
+ json=_json,
152
+ cast_to=models.V1AiImageEditorCreateResponse,
153
+ request_options=request_options or default_request_options(),
154
+ )
155
+
156
+
157
+ class AsyncAiImageEditorClient:
158
+ def __init__(self, *, base_client: AsyncBaseClient):
159
+ self._base_client = base_client
160
+
161
+ async def generate(
162
+ self,
163
+ *,
164
+ assets: params.V1AiImageEditorGenerateBodyAssets,
165
+ style: params.V1AiImageEditorCreateBodyStyle,
166
+ name: typing.Union[
167
+ typing.Optional[str], type_utils.NotGiven
168
+ ] = type_utils.NOT_GIVEN,
169
+ wait_for_completion: bool = True,
170
+ download_outputs: bool = True,
171
+ download_directory: typing.Optional[str] = None,
172
+ request_options: typing.Optional[RequestOptions] = None,
173
+ ):
174
+ """
175
+ Generate edited image (alias for create with additional functionality).
176
+
177
+ Edit image using AI. Each edit costs 5 credits.
178
+
179
+ Args:
180
+ name: The name of image. This value is mainly used for your own identification of the image.
181
+ assets: Provide the assets for image editor
182
+ style: Image editing parameters
183
+ wait_for_completion: Whether to wait for the image project to complete
184
+ download_outputs: Whether to download the outputs
185
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
186
+ request_options: Additional options to customize the HTTP request
187
+
188
+ Returns:
189
+ V1ImageProjectsGetResponseWithDownloads: The response from the AI Image Editor API with the downloaded paths if `download_outputs` is True.
190
+
191
+ Examples:
192
+ ```py
193
+ response = await client.v1.ai_image_editor.generate(
194
+ assets={"image_file_paths": ["path/to/image.png", "path/to/image2.png"]},
195
+ style={"prompt": "Add a sunset background"},
196
+ name="Edited Image",
197
+ wait_for_completion=True,
198
+ download_outputs=True,
199
+ download_directory="outputs/",
200
+ )
201
+ ```
202
+ """
203
+
204
+ file_client = AsyncFilesClient(base_client=self._base_client)
205
+
206
+ if "image_file_path" in assets:
207
+ image_file_path = assets["image_file_path"]
208
+ assets["image_file_path"] = await file_client.upload_file(
209
+ file=image_file_path
210
+ )
211
+
212
+ if "image_file_paths" in assets:
213
+ for image_file_path in assets["image_file_paths"]:
214
+ assets["image_file_paths"] = [
215
+ await file_client.upload_file(file=image_file_path)
216
+ for image_file_path in assets["image_file_paths"]
217
+ ]
218
+
219
+ create_response = await self.create(
220
+ assets=assets, style=style, name=name, request_options=request_options
221
+ )
222
+ logger.info(f"AI Image Editor response: {create_response}")
223
+
224
+ image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
225
+ response = await image_projects_client.check_result(
226
+ id=create_response.id,
227
+ wait_for_completion=wait_for_completion,
228
+ download_outputs=download_outputs,
229
+ download_directory=download_directory,
230
+ )
231
+
232
+ return response
233
+
234
+ async def create(
235
+ self,
236
+ *,
237
+ assets: params.V1AiImageEditorCreateBodyAssets,
238
+ style: params.V1AiImageEditorCreateBodyStyle,
239
+ name: typing.Union[
240
+ typing.Optional[str], type_utils.NotGiven
241
+ ] = type_utils.NOT_GIVEN,
242
+ request_options: typing.Optional[RequestOptions] = None,
243
+ ) -> models.V1AiImageEditorCreateResponse:
244
+ """
245
+ AI Image Editor
246
+
247
+ Edit images with AI. Each edit costs 50 credits.
248
+
249
+ POST /v1/ai-image-editor
250
+
251
+ Args:
252
+ name: The name of image. This value is mainly used for your own identification of the image.
253
+ assets: Provide the assets for image edit
254
+ style: V1AiImageEditorCreateBodyStyle
255
+ request_options: Additional options to customize the HTTP request
256
+
257
+ Returns:
258
+ Success
259
+
260
+ Raises:
261
+ ApiError: A custom exception class that provides additional context
262
+ for API errors, including the HTTP status code and response body.
263
+
264
+ Examples:
265
+ ```py
266
+ await client.v1.ai_image_editor.create(
267
+ assets={
268
+ "image_file_path": "api-assets/id/1234.png",
269
+ "image_file_paths": [
270
+ "api-assets/id/1234.png",
271
+ "api-assets/id/1235.png",
272
+ ],
273
+ },
274
+ style={"model": "Nano Banana", "prompt": "Give me sunglasses"},
275
+ name="Ai Image Editor image",
276
+ )
277
+ ```
278
+ """
279
+ _json = to_encodable(
280
+ item={"name": name, "assets": assets, "style": style},
281
+ dump_with=params._SerializerV1AiImageEditorCreateBody,
282
+ )
283
+ return await self._base_client.request(
284
+ method="POST",
285
+ path="/v1/ai-image-editor",
286
+ auth_names=["bearerAuth"],
287
+ json=_json,
288
+ cast_to=models.V1AiImageEditorCreateResponse,
289
+ request_options=request_options or default_request_options(),
290
+ )
@@ -1,11 +1,85 @@
1
+ # v1.ai_image_generator
1
2
 
2
- ### create <a name="create"></a>
3
- AI Images
3
+ ## Module Functions
4
4
 
5
- Create an AI image. Each image costs 5 frames.
5
+ <!-- CUSTOM DOCS START -->
6
+
7
+ ### Ai Image Generator Generate Workflow <a name="generate"></a>
8
+
9
+ The workflow performs the following action
10
+
11
+ 1. upload local assets to Magic Hour storage. So you can pass in a local path instead of having to upload files yourself
12
+ 2. trigger a generation
13
+ 3. poll for a completion status. This is configurable
14
+ 4. if success, download the output to local directory
15
+
16
+ > [!TIP]
17
+ > This is the recommended way to use the SDK unless you have specific needs where it is necessary to split up the actions.
18
+
19
+ #### Parameters
20
+
21
+ In Additional to the parameters listed in the `.create` section below, `.generate` introduces 3 new parameters:
22
+
23
+ - `wait_for_completion` (bool, default True): Whether to wait for the project to complete.
24
+ - `download_outputs` (bool, default True): Whether to download the generated files
25
+ - `download_directory` (str, optional): Directory to save downloaded files (defaults to current directory)
26
+
27
+ #### Synchronous Client
28
+
29
+ ```python
30
+ from magic_hour import Client
31
+ from os import getenv
32
+
33
+ client = Client(token=getenv("API_TOKEN"))
34
+ res = client.v1.ai_image_generator.generate(
35
+ image_count=1,
36
+ orientation="landscape",
37
+ style={"prompt": "Cool image", "tool": "ai-anime-generator"},
38
+ name="Ai Image image",
39
+ wait_for_completion=True,
40
+ download_outputs=True,
41
+ download_directory="outputs"
42
+ )
43
+ ```
44
+
45
+ #### Asynchronous Client
46
+
47
+ ```python
48
+ from magic_hour import AsyncClient
49
+ from os import getenv
50
+
51
+ client = AsyncClient(token=getenv("API_TOKEN"))
52
+ res = await client.v1.ai_image_generator.generate(
53
+ image_count=1,
54
+ orientation="landscape",
55
+ style={"prompt": "Cool image", "tool": "ai-anime-generator"},
56
+ name="Ai Image image",
57
+ wait_for_completion=True,
58
+ download_outputs=True,
59
+ download_directory="outputs"
60
+ )
61
+ ```
62
+
63
+ <!-- CUSTOM DOCS END -->
64
+
65
+ ### AI Image Generator <a name="create"></a>
66
+
67
+ Create an AI image. Each standard image costs 5 credits. Pro quality images cost 30 credits.
6
68
 
7
69
  **API Endpoint**: `POST /v1/ai-image-generator`
8
70
 
71
+ #### Parameters
72
+
73
+ | Parameter | Required | Description | Example |
74
+ | ----------------- | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
75
+ | `image_count` | ✓ | Number of images to generate. | `1` |
76
+ | `orientation` | ✓ | The orientation of the output image(s). | `"landscape"` |
77
+ | `style` | ✓ | The art style to use for image generation. | `{"prompt": "Cool image", "quality_mode": "standard", "tool": "ai-anime-generator"}` |
78
+ | `└─ prompt` | ✓ | The prompt used for the image(s). | `"Cool image"` |
79
+ | `└─ quality_mode` | ✗ | Controls the quality of the generated image. Defaults to 'standard' if not specified. **Options:** - `standard` - Standard quality generation. Cost: 5 credits per image. - `pro` - Pro quality generation with enhanced details and quality. Cost: 30 credits per image. Note: Pro mode is available for users on Creator, Pro, or Business tier. | `"standard"` |
80
+ | `└─ tool` | ✗ | The art style to use for image generation. Defaults to 'general' if not provided. | `"ai-anime-generator"` |
81
+ | `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Ai Image image"` |
82
+
9
83
  #### Synchronous Client
10
84
 
11
85
  ```python
@@ -16,7 +90,11 @@ client = Client(token=getenv("API_TOKEN"))
16
90
  res = client.v1.ai_image_generator.create(
17
91
  image_count=1,
18
92
  orientation="landscape",
19
- style={"prompt": "Cool image"},
93
+ style={
94
+ "prompt": "Cool image",
95
+ "quality_mode": "standard",
96
+ "tool": "ai-anime-generator",
97
+ },
20
98
  name="Ai Image image",
21
99
  )
22
100
  ```
@@ -31,7 +109,23 @@ client = AsyncClient(token=getenv("API_TOKEN"))
31
109
  res = await client.v1.ai_image_generator.create(
32
110
  image_count=1,
33
111
  orientation="landscape",
34
- style={"prompt": "Cool image"},
112
+ style={
113
+ "prompt": "Cool image",
114
+ "quality_mode": "standard",
115
+ "tool": "ai-anime-generator",
116
+ },
35
117
  name="Ai Image image",
36
118
  )
37
119
  ```
120
+
121
+ #### Response
122
+
123
+ ##### Type
124
+
125
+ [V1AiImageGeneratorCreateResponse](/magic_hour/types/models/v1_ai_image_generator_create_response.py)
126
+
127
+ ##### Example
128
+
129
+ ```python
130
+ {"credits_charged": 5, "frame_cost": 5, "id": "cuid-example"}
131
+ ```