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.
- magic_hour/README.md +34 -0
- magic_hour/__init__.py +1 -1
- magic_hour/client.py +8 -17
- magic_hour/environment.py +13 -1
- magic_hour/helpers/__init__.py +4 -0
- magic_hour/helpers/download.py +77 -0
- magic_hour/helpers/logger.py +8 -0
- magic_hour/resources/v1/README.md +32 -0
- magic_hour/resources/v1/ai_clothes_changer/README.md +94 -5
- magic_hour/resources/v1/ai_clothes_changer/client.py +161 -16
- magic_hour/resources/v1/ai_face_editor/README.md +195 -0
- magic_hour/resources/v1/ai_face_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_face_editor/client.py +324 -0
- magic_hour/resources/v1/ai_gif_generator/README.md +116 -0
- magic_hour/resources/v1/ai_gif_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_gif_generator/client.py +257 -0
- magic_hour/resources/v1/ai_headshot_generator/README.md +81 -3
- magic_hour/resources/v1/ai_headshot_generator/client.py +167 -18
- magic_hour/resources/v1/ai_image_editor/README.md +125 -0
- magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_image_editor/client.py +290 -0
- magic_hour/resources/v1/ai_image_generator/README.md +99 -5
- magic_hour/resources/v1/ai_image_generator/client.py +170 -24
- magic_hour/resources/v1/ai_image_upscaler/README.md +89 -3
- magic_hour/resources/v1/ai_image_upscaler/client.py +173 -20
- magic_hour/resources/v1/ai_meme_generator/README.md +129 -0
- magic_hour/resources/v1/ai_meme_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_meme_generator/client.py +253 -0
- magic_hour/resources/v1/ai_photo_editor/README.md +119 -4
- magic_hour/resources/v1/ai_photo_editor/client.py +199 -18
- magic_hour/resources/v1/ai_qr_code_generator/README.md +84 -3
- magic_hour/resources/v1/ai_qr_code_generator/client.py +140 -18
- magic_hour/resources/v1/ai_talking_photo/README.md +137 -0
- magic_hour/resources/v1/ai_talking_photo/__init__.py +4 -0
- magic_hour/resources/v1/ai_talking_photo/client.py +326 -0
- magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
- magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
- magic_hour/resources/v1/ai_voice_generator/README.md +112 -0
- magic_hour/resources/v1/ai_voice_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_generator/client.py +241 -0
- magic_hour/resources/v1/animation/README.md +128 -6
- magic_hour/resources/v1/animation/client.py +247 -22
- magic_hour/resources/v1/audio_projects/README.md +135 -0
- magic_hour/resources/v1/audio_projects/__init__.py +12 -0
- magic_hour/resources/v1/audio_projects/client.py +310 -0
- magic_hour/resources/v1/audio_projects/client_test.py +520 -0
- magic_hour/resources/v1/auto_subtitle_generator/README.md +128 -0
- magic_hour/resources/v1/auto_subtitle_generator/__init__.py +4 -0
- magic_hour/resources/v1/auto_subtitle_generator/client.py +346 -0
- magic_hour/resources/v1/client.py +75 -1
- magic_hour/resources/v1/face_detection/README.md +157 -0
- magic_hour/resources/v1/face_detection/__init__.py +12 -0
- magic_hour/resources/v1/face_detection/client.py +380 -0
- magic_hour/resources/v1/face_swap/README.md +137 -9
- magic_hour/resources/v1/face_swap/client.py +329 -38
- magic_hour/resources/v1/face_swap_photo/README.md +118 -3
- magic_hour/resources/v1/face_swap_photo/client.py +199 -14
- magic_hour/resources/v1/files/README.md +39 -0
- magic_hour/resources/v1/files/client.py +351 -1
- magic_hour/resources/v1/files/client_test.py +414 -0
- magic_hour/resources/v1/files/upload_urls/README.md +38 -17
- magic_hour/resources/v1/files/upload_urls/client.py +38 -34
- magic_hour/resources/v1/image_background_remover/README.md +96 -5
- magic_hour/resources/v1/image_background_remover/client.py +151 -16
- magic_hour/resources/v1/image_projects/README.md +82 -10
- magic_hour/resources/v1/image_projects/__init__.py +10 -2
- magic_hour/resources/v1/image_projects/client.py +154 -16
- magic_hour/resources/v1/image_projects/client_test.py +527 -0
- magic_hour/resources/v1/image_to_video/README.md +96 -11
- magic_hour/resources/v1/image_to_video/client.py +282 -38
- magic_hour/resources/v1/lip_sync/README.md +112 -9
- magic_hour/resources/v1/lip_sync/client.py +288 -34
- magic_hour/resources/v1/photo_colorizer/README.md +107 -0
- magic_hour/resources/v1/photo_colorizer/__init__.py +4 -0
- magic_hour/resources/v1/photo_colorizer/client.py +248 -0
- magic_hour/resources/v1/text_to_video/README.md +96 -7
- magic_hour/resources/v1/text_to_video/client.py +204 -18
- magic_hour/resources/v1/video_projects/README.md +81 -9
- magic_hour/resources/v1/video_projects/__init__.py +10 -2
- magic_hour/resources/v1/video_projects/client.py +151 -14
- magic_hour/resources/v1/video_projects/client_test.py +527 -0
- magic_hour/resources/v1/video_to_video/README.md +119 -15
- magic_hour/resources/v1/video_to_video/client.py +299 -46
- magic_hour/types/models/__init__.py +92 -56
- magic_hour/types/models/v1_ai_clothes_changer_create_response.py +33 -0
- magic_hour/types/models/v1_ai_face_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_gif_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_headshot_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_upscaler_create_response.py +33 -0
- magic_hour/types/models/v1_ai_meme_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_photo_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_qr_code_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_talking_photo_create_response.py +35 -0
- magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
- magic_hour/types/models/v1_ai_voice_generator_create_response.py +27 -0
- magic_hour/types/models/v1_animation_create_response.py +35 -0
- magic_hour/types/models/v1_audio_projects_get_response.py +72 -0
- magic_hour/types/models/v1_audio_projects_get_response_downloads_item.py +19 -0
- magic_hour/types/models/{get_v1_image_projects_id_response_error.py → v1_audio_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_auto_subtitle_generator_create_response.py +35 -0
- magic_hour/types/models/v1_face_detection_create_response.py +25 -0
- magic_hour/types/models/v1_face_detection_get_response.py +45 -0
- magic_hour/types/models/v1_face_detection_get_response_faces_item.py +25 -0
- magic_hour/types/models/v1_face_swap_create_response.py +35 -0
- magic_hour/types/models/v1_face_swap_photo_create_response.py +33 -0
- magic_hour/types/models/v1_files_upload_urls_create_response.py +24 -0
- magic_hour/types/models/{post_v1_files_upload_urls_response_items_item.py → v1_files_upload_urls_create_response_items_item.py} +2 -2
- magic_hour/types/models/v1_image_background_remover_create_response.py +33 -0
- magic_hour/types/models/{get_v1_image_projects_id_response.py → v1_image_projects_get_response.py} +20 -18
- magic_hour/types/models/{get_v1_video_projects_id_response_downloads_item.py → v1_image_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/{get_v1_video_projects_id_response_error.py → v1_image_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_image_to_video_create_response.py +35 -0
- magic_hour/types/models/v1_lip_sync_create_response.py +35 -0
- magic_hour/types/models/v1_photo_colorizer_create_response.py +33 -0
- magic_hour/types/models/v1_text_to_video_create_response.py +35 -0
- magic_hour/types/models/{get_v1_video_projects_id_response.py → v1_video_projects_get_response.py} +26 -23
- magic_hour/types/models/{get_v1_video_projects_id_response_download.py → v1_video_projects_get_response_download.py} +1 -1
- magic_hour/types/models/{get_v1_image_projects_id_response_downloads_item.py → v1_video_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/v1_video_projects_get_response_error.py +25 -0
- magic_hour/types/models/v1_video_to_video_create_response.py +35 -0
- magic_hour/types/params/__init__.py +422 -176
- magic_hour/types/params/v1_ai_clothes_changer_create_body.py +40 -0
- magic_hour/types/params/v1_ai_clothes_changer_create_body_assets.py +58 -0
- magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body.py +52 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_style.py +137 -0
- magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_gif_generator_create_body.py +47 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body_style.py → v1_ai_gif_generator_create_body_style.py} +5 -5
- magic_hour/types/params/v1_ai_headshot_generator_create_body.py +49 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_style.py +27 -0
- magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +47 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_style.py +41 -0
- magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +28 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body.py → v1_ai_image_generator_create_body.py} +17 -11
- magic_hour/types/params/v1_ai_image_generator_create_body_style.py +127 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body.py +59 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_image_upscaler_body_style.py → v1_ai_image_upscaler_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body.py +37 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body_style.py +73 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body.py → v1_ai_photo_editor_create_body.py} +15 -15
- magic_hour/types/params/v1_ai_photo_editor_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body_style.py → v1_ai_photo_editor_create_body_style.py} +20 -4
- magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_qr_code_generator_create_body.py +45 -0
- magic_hour/types/params/{post_v1_ai_qr_code_generator_body_style.py → v1_ai_qr_code_generator_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_talking_photo_create_body.py +68 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_assets.py +46 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +44 -0
- magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
- magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body.py +40 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +440 -0
- magic_hour/types/params/{post_v1_animation_body.py → v1_animation_create_body.py} +16 -16
- magic_hour/types/params/{post_v1_animation_body_assets.py → v1_animation_create_body_assets.py} +15 -5
- magic_hour/types/params/{post_v1_animation_body_style.py → v1_animation_create_body_style.py} +13 -10
- magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body.py +78 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style.py +56 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style_custom_config.py +86 -0
- magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_detection_create_body.py +44 -0
- magic_hour/types/params/v1_face_detection_create_body_assets.py +33 -0
- magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_swap_create_body.py +92 -0
- magic_hour/types/params/v1_face_swap_create_body_assets.py +91 -0
- magic_hour/types/params/v1_face_swap_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_face_swap_photo_create_body.py +40 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets.py +76 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_files_upload_urls_create_body.py +36 -0
- magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +38 -0
- magic_hour/types/params/v1_image_background_remover_create_body.py +40 -0
- magic_hour/types/params/v1_image_background_remover_create_body_assets.py +49 -0
- magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
- magic_hour/types/params/v1_image_to_video_create_body.py +101 -0
- magic_hour/types/params/v1_image_to_video_create_body_assets.py +33 -0
- magic_hour/types/params/v1_image_to_video_create_body_style.py +53 -0
- magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_lip_sync_create_body.py +100 -0
- magic_hour/types/params/{post_v1_lip_sync_body_assets.py → v1_lip_sync_create_body_assets.py} +15 -5
- magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
- magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
- magic_hour/types/params/v1_photo_colorizer_create_body.py +40 -0
- magic_hour/types/params/v1_photo_colorizer_create_body_assets.py +33 -0
- magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_text_to_video_create_body.py +78 -0
- magic_hour/types/params/v1_text_to_video_create_body_style.py +43 -0
- magic_hour/types/params/v1_video_to_video_create_body.py +101 -0
- magic_hour/types/params/{post_v1_video_to_video_body_assets.py → v1_video_to_video_create_body_assets.py} +9 -4
- magic_hour/types/params/{post_v1_video_to_video_body_style.py → v1_video_to_video_create_body_style.py} +68 -26
- magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
- magic_hour-0.44.0.dist-info/METADATA +328 -0
- magic_hour-0.44.0.dist-info/RECORD +231 -0
- magic_hour/core/__init__.py +0 -52
- magic_hour/core/api_error.py +0 -56
- magic_hour/core/auth.py +0 -314
- magic_hour/core/base_client.py +0 -618
- magic_hour/core/binary_response.py +0 -23
- magic_hour/core/query.py +0 -106
- magic_hour/core/request.py +0 -156
- magic_hour/core/response.py +0 -293
- magic_hour/core/type_utils.py +0 -28
- magic_hour/core/utils.py +0 -55
- magic_hour/types/models/post_v1_ai_clothes_changer_response.py +0 -25
- magic_hour/types/models/post_v1_ai_headshot_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_upscaler_response.py +0 -25
- magic_hour/types/models/post_v1_ai_photo_editor_response.py +0 -25
- magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +0 -25
- magic_hour/types/models/post_v1_animation_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_photo_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_response.py +0 -25
- magic_hour/types/models/post_v1_files_upload_urls_response.py +0 -21
- magic_hour/types/models/post_v1_image_background_remover_response.py +0 -25
- magic_hour/types/models/post_v1_image_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_lip_sync_response.py +0 -25
- magic_hour/types/models/post_v1_text_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_video_to_video_response.py +0 -25
- magic_hour/types/params/post_v1_ai_clothes_changer_body.py +0 -40
- magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +0 -45
- magic_hour/types/params/post_v1_ai_headshot_generator_body.py +0 -40
- magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_image_upscaler_body.py +0 -57
- magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +0 -45
- magic_hour/types/params/post_v1_face_swap_body.py +0 -72
- magic_hour/types/params/post_v1_face_swap_body_assets.py +0 -52
- magic_hour/types/params/post_v1_face_swap_photo_body.py +0 -40
- magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +0 -36
- magic_hour/types/params/post_v1_files_upload_urls_body.py +0 -31
- magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +0 -38
- magic_hour/types/params/post_v1_image_background_remover_body.py +0 -40
- magic_hour/types/params/post_v1_image_background_remover_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body.py +0 -73
- magic_hour/types/params/post_v1_image_to_video_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body_style.py +0 -37
- magic_hour/types/params/post_v1_lip_sync_body.py +0 -80
- magic_hour/types/params/post_v1_text_to_video_body.py +0 -57
- magic_hour/types/params/post_v1_text_to_video_body_style.py +0 -28
- magic_hour/types/params/post_v1_video_to_video_body.py +0 -93
- magic_hour-0.9.5.dist-info/METADATA +0 -133
- magic_hour-0.9.5.dist-info/RECORD +0 -132
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
import typing_extensions
|
|
3
|
+
|
|
4
|
+
from magic_hour.helpers.logger import get_sdk_logger
|
|
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 AiGifGeneratorClient:
|
|
24
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
25
|
+
self._base_client = base_client
|
|
26
|
+
|
|
27
|
+
def generate(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
style: params.V1AiGifGeneratorCreateBodyStyle,
|
|
31
|
+
name: typing.Union[
|
|
32
|
+
typing.Optional[str], type_utils.NotGiven
|
|
33
|
+
] = type_utils.NOT_GIVEN,
|
|
34
|
+
output_format: typing.Union[
|
|
35
|
+
typing.Optional[typing_extensions.Literal["gif", "mp4", "webm"]],
|
|
36
|
+
type_utils.NotGiven,
|
|
37
|
+
] = type_utils.NOT_GIVEN,
|
|
38
|
+
wait_for_completion: bool = True,
|
|
39
|
+
download_outputs: bool = True,
|
|
40
|
+
download_directory: typing.Optional[str] = None,
|
|
41
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
42
|
+
):
|
|
43
|
+
"""
|
|
44
|
+
Generate GIF (alias for create with additional functionality).
|
|
45
|
+
|
|
46
|
+
Create an AI GIF. Each GIF costs 5 credits.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
50
|
+
style: The art style to use for GIF generation
|
|
51
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
52
|
+
download_outputs: Whether to download the outputs
|
|
53
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
54
|
+
request_options: Additional options to customize the HTTP request
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI GIF Generator API with the downloaded paths if `download_outputs` is True.
|
|
58
|
+
|
|
59
|
+
Examples:
|
|
60
|
+
```py
|
|
61
|
+
response = client.v1.ai_gif_generator.generate(
|
|
62
|
+
style={"prompt": "Cute dancing cat, pixel art"},
|
|
63
|
+
name="Dancing Cat GIF",
|
|
64
|
+
wait_for_completion=True,
|
|
65
|
+
download_outputs=True,
|
|
66
|
+
download_directory="outputs/",
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
create_response = self.create(
|
|
72
|
+
style=style,
|
|
73
|
+
name=name,
|
|
74
|
+
output_format=output_format,
|
|
75
|
+
request_options=request_options,
|
|
76
|
+
)
|
|
77
|
+
logger.info(f"AI GIF Generator response: {create_response}")
|
|
78
|
+
|
|
79
|
+
image_projects_client = ImageProjectsClient(base_client=self._base_client)
|
|
80
|
+
response = image_projects_client.check_result(
|
|
81
|
+
id=create_response.id,
|
|
82
|
+
wait_for_completion=wait_for_completion,
|
|
83
|
+
download_outputs=download_outputs,
|
|
84
|
+
download_directory=download_directory,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return response
|
|
88
|
+
|
|
89
|
+
def create(
|
|
90
|
+
self,
|
|
91
|
+
*,
|
|
92
|
+
style: params.V1AiGifGeneratorCreateBodyStyle,
|
|
93
|
+
name: typing.Union[
|
|
94
|
+
typing.Optional[str], type_utils.NotGiven
|
|
95
|
+
] = type_utils.NOT_GIVEN,
|
|
96
|
+
output_format: typing.Union[
|
|
97
|
+
typing.Optional[typing_extensions.Literal["gif", "mp4", "webm"]],
|
|
98
|
+
type_utils.NotGiven,
|
|
99
|
+
] = type_utils.NOT_GIVEN,
|
|
100
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
101
|
+
) -> models.V1AiGifGeneratorCreateResponse:
|
|
102
|
+
"""
|
|
103
|
+
AI GIF Generator
|
|
104
|
+
|
|
105
|
+
Create an AI GIF. Each GIF costs 50 credits.
|
|
106
|
+
|
|
107
|
+
POST /v1/ai-gif-generator
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
name: The name of gif. This value is mainly used for your own identification of the gif.
|
|
111
|
+
output_format: The output file format for the generated animation.
|
|
112
|
+
style: V1AiGifGeneratorCreateBodyStyle
|
|
113
|
+
request_options: Additional options to customize the HTTP request
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Success
|
|
117
|
+
|
|
118
|
+
Raises:
|
|
119
|
+
ApiError: A custom exception class that provides additional context
|
|
120
|
+
for API errors, including the HTTP status code and response body.
|
|
121
|
+
|
|
122
|
+
Examples:
|
|
123
|
+
```py
|
|
124
|
+
client.v1.ai_gif_generator.create(
|
|
125
|
+
style={"prompt": "Cute dancing cat, pixel art"},
|
|
126
|
+
name="Ai Gif gif",
|
|
127
|
+
output_format="gif",
|
|
128
|
+
)
|
|
129
|
+
```
|
|
130
|
+
"""
|
|
131
|
+
_json = to_encodable(
|
|
132
|
+
item={"name": name, "output_format": output_format, "style": style},
|
|
133
|
+
dump_with=params._SerializerV1AiGifGeneratorCreateBody,
|
|
134
|
+
)
|
|
135
|
+
return self._base_client.request(
|
|
136
|
+
method="POST",
|
|
137
|
+
path="/v1/ai-gif-generator",
|
|
138
|
+
auth_names=["bearerAuth"],
|
|
139
|
+
json=_json,
|
|
140
|
+
cast_to=models.V1AiGifGeneratorCreateResponse,
|
|
141
|
+
request_options=request_options or default_request_options(),
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class AsyncAiGifGeneratorClient:
|
|
146
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
147
|
+
self._base_client = base_client
|
|
148
|
+
|
|
149
|
+
async def generate(
|
|
150
|
+
self,
|
|
151
|
+
*,
|
|
152
|
+
style: params.V1AiGifGeneratorCreateBodyStyle,
|
|
153
|
+
name: typing.Union[
|
|
154
|
+
typing.Optional[str], type_utils.NotGiven
|
|
155
|
+
] = type_utils.NOT_GIVEN,
|
|
156
|
+
wait_for_completion: bool = True,
|
|
157
|
+
download_outputs: bool = True,
|
|
158
|
+
download_directory: typing.Optional[str] = None,
|
|
159
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
160
|
+
):
|
|
161
|
+
"""
|
|
162
|
+
Generate GIF (alias for create with additional functionality).
|
|
163
|
+
|
|
164
|
+
Create an AI GIF. Each GIF costs 5 credits.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
168
|
+
style: The art style to use for GIF generation
|
|
169
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
170
|
+
download_outputs: Whether to download the outputs
|
|
171
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
172
|
+
request_options: Additional options to customize the HTTP request
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI GIF Generator API with the downloaded paths if `download_outputs` is True.
|
|
176
|
+
|
|
177
|
+
Examples:
|
|
178
|
+
```py
|
|
179
|
+
response = await client.v1.ai_gif_generator.generate(
|
|
180
|
+
style={"prompt": "Cute dancing cat, pixel art"},
|
|
181
|
+
name="Dancing Cat GIF",
|
|
182
|
+
wait_for_completion=True,
|
|
183
|
+
download_outputs=True,
|
|
184
|
+
download_directory="outputs/",
|
|
185
|
+
)
|
|
186
|
+
```
|
|
187
|
+
"""
|
|
188
|
+
|
|
189
|
+
create_response = await self.create(
|
|
190
|
+
style=style, name=name, request_options=request_options
|
|
191
|
+
)
|
|
192
|
+
logger.info(f"AI GIF Generator response: {create_response}")
|
|
193
|
+
|
|
194
|
+
image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
|
|
195
|
+
response = await image_projects_client.check_result(
|
|
196
|
+
id=create_response.id,
|
|
197
|
+
wait_for_completion=wait_for_completion,
|
|
198
|
+
download_outputs=download_outputs,
|
|
199
|
+
download_directory=download_directory,
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
return response
|
|
203
|
+
|
|
204
|
+
async def create(
|
|
205
|
+
self,
|
|
206
|
+
*,
|
|
207
|
+
style: params.V1AiGifGeneratorCreateBodyStyle,
|
|
208
|
+
name: typing.Union[
|
|
209
|
+
typing.Optional[str], type_utils.NotGiven
|
|
210
|
+
] = type_utils.NOT_GIVEN,
|
|
211
|
+
output_format: typing.Union[
|
|
212
|
+
typing.Optional[typing_extensions.Literal["gif", "mp4", "webm"]],
|
|
213
|
+
type_utils.NotGiven,
|
|
214
|
+
] = type_utils.NOT_GIVEN,
|
|
215
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
216
|
+
) -> models.V1AiGifGeneratorCreateResponse:
|
|
217
|
+
"""
|
|
218
|
+
AI GIF Generator
|
|
219
|
+
|
|
220
|
+
Create an AI GIF. Each GIF costs 50 credits.
|
|
221
|
+
|
|
222
|
+
POST /v1/ai-gif-generator
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
name: The name of gif. This value is mainly used for your own identification of the gif.
|
|
226
|
+
output_format: The output file format for the generated animation.
|
|
227
|
+
style: V1AiGifGeneratorCreateBodyStyle
|
|
228
|
+
request_options: Additional options to customize the HTTP request
|
|
229
|
+
|
|
230
|
+
Returns:
|
|
231
|
+
Success
|
|
232
|
+
|
|
233
|
+
Raises:
|
|
234
|
+
ApiError: A custom exception class that provides additional context
|
|
235
|
+
for API errors, including the HTTP status code and response body.
|
|
236
|
+
|
|
237
|
+
Examples:
|
|
238
|
+
```py
|
|
239
|
+
await client.v1.ai_gif_generator.create(
|
|
240
|
+
style={"prompt": "Cute dancing cat, pixel art"},
|
|
241
|
+
name="Ai Gif gif",
|
|
242
|
+
output_format="gif",
|
|
243
|
+
)
|
|
244
|
+
```
|
|
245
|
+
"""
|
|
246
|
+
_json = to_encodable(
|
|
247
|
+
item={"name": name, "output_format": output_format, "style": style},
|
|
248
|
+
dump_with=params._SerializerV1AiGifGeneratorCreateBody,
|
|
249
|
+
)
|
|
250
|
+
return await self._base_client.request(
|
|
251
|
+
method="POST",
|
|
252
|
+
path="/v1/ai-gif-generator",
|
|
253
|
+
auth_names=["bearerAuth"],
|
|
254
|
+
json=_json,
|
|
255
|
+
cast_to=models.V1AiGifGeneratorCreateResponse,
|
|
256
|
+
request_options=request_options or default_request_options(),
|
|
257
|
+
)
|
|
@@ -1,11 +1,77 @@
|
|
|
1
|
+
# v1.ai_headshot_generator
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
AI Headshots
|
|
3
|
+
## Module Functions
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<!-- CUSTOM DOCS START -->
|
|
6
|
+
|
|
7
|
+
### Ai Headshot 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_headshot_generator.generate(
|
|
35
|
+
assets={"image_file_path": "/path/to/1234.png"}, name="Ai Headshot image"
|
|
36
|
+
wait_for_completion=True,
|
|
37
|
+
download_outputs=True,
|
|
38
|
+
download_directory="outputs"
|
|
39
|
+
)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Asynchronous Client
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from magic_hour import AsyncClient
|
|
46
|
+
from os import getenv
|
|
47
|
+
|
|
48
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
49
|
+
res = await client.v1.ai_headshot_generator.generate(
|
|
50
|
+
assets={"image_file_path": "/path/to/1234.png"}, name="Ai Headshot image"
|
|
51
|
+
wait_for_completion=True,
|
|
52
|
+
download_outputs=True,
|
|
53
|
+
download_directory="outputs"
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
<!-- CUSTOM DOCS END -->
|
|
58
|
+
|
|
59
|
+
### AI Headshot Generator <a name="create"></a>
|
|
60
|
+
|
|
61
|
+
Create an AI headshot. Each headshot costs 50 credits.
|
|
6
62
|
|
|
7
63
|
**API Endpoint**: `POST /v1/ai-headshot-generator`
|
|
8
64
|
|
|
65
|
+
#### Parameters
|
|
66
|
+
|
|
67
|
+
| Parameter | Required | Description | Example |
|
|
68
|
+
| -------------------- | :------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
69
|
+
| `assets` | ✓ | Provide the assets for headshot photo | `{"image_file_path": "api-assets/id/1234.png"}` |
|
|
70
|
+
| `└─ image_file_path` | ✓ | The image used to generate the headshot. This image must contain one detectable face. 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"` |
|
|
71
|
+
| `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Ai Headshot image"` |
|
|
72
|
+
| `style` | ✗ | | `{}` |
|
|
73
|
+
| `└─ prompt` | ✗ | Prompt used to guide the style of your headshot. We recommend omitting the prompt unless you want to customize your headshot. You can visit [AI headshot generator](https://magichour.ai/create/ai-headshot-generator) to view an example of a good prompt used for our 'Professional' style. | `"string"` |
|
|
74
|
+
|
|
9
75
|
#### Synchronous Client
|
|
10
76
|
|
|
11
77
|
```python
|
|
@@ -29,3 +95,15 @@ res = await client.v1.ai_headshot_generator.create(
|
|
|
29
95
|
assets={"image_file_path": "api-assets/id/1234.png"}, name="Ai Headshot image"
|
|
30
96
|
)
|
|
31
97
|
```
|
|
98
|
+
|
|
99
|
+
#### Response
|
|
100
|
+
|
|
101
|
+
##### Type
|
|
102
|
+
|
|
103
|
+
[V1AiHeadshotGeneratorCreateResponse](/magic_hour/types/models/v1_ai_headshot_generator_create_response.py)
|
|
104
|
+
|
|
105
|
+
##### Example
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
{"credits_charged": 50, "frame_cost": 50, "id": "cuid-example"}
|
|
109
|
+
```
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import typing
|
|
2
2
|
|
|
3
|
-
from magic_hour.
|
|
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 (
|
|
4
11
|
AsyncBaseClient,
|
|
5
12
|
RequestOptions,
|
|
6
13
|
SyncBaseClient,
|
|
@@ -8,31 +15,103 @@ from magic_hour.core import (
|
|
|
8
15
|
to_encodable,
|
|
9
16
|
type_utils,
|
|
10
17
|
)
|
|
11
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
logger = get_sdk_logger(__name__)
|
|
12
21
|
|
|
13
22
|
|
|
14
23
|
class AiHeadshotGeneratorClient:
|
|
15
24
|
def __init__(self, *, base_client: SyncBaseClient):
|
|
16
25
|
self._base_client = base_client
|
|
17
26
|
|
|
27
|
+
def generate(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
assets: params.V1AiHeadshotGeneratorGenerateBodyAssets,
|
|
31
|
+
name: typing.Union[
|
|
32
|
+
typing.Optional[str], type_utils.NotGiven
|
|
33
|
+
] = type_utils.NOT_GIVEN,
|
|
34
|
+
style: typing.Union[
|
|
35
|
+
typing.Optional[params.V1AiHeadshotGeneratorCreateBodyStyle],
|
|
36
|
+
type_utils.NotGiven,
|
|
37
|
+
] = type_utils.NOT_GIVEN,
|
|
38
|
+
wait_for_completion: bool = True,
|
|
39
|
+
download_outputs: bool = True,
|
|
40
|
+
download_directory: typing.Optional[str] = None,
|
|
41
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
42
|
+
):
|
|
43
|
+
"""
|
|
44
|
+
Generate headshot (alias for create with additional functionality).
|
|
45
|
+
|
|
46
|
+
Generate professional headshots using AI. Each headshot costs 5 credits.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
50
|
+
assets: Provide the assets for headshot generation
|
|
51
|
+
style: Headshot generation parameters
|
|
52
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
53
|
+
download_outputs: Whether to download the outputs
|
|
54
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
55
|
+
request_options: Additional options to customize the HTTP request
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI Headshot Generator API with the downloaded paths if `download_outputs` is True.
|
|
59
|
+
|
|
60
|
+
Examples:
|
|
61
|
+
```py
|
|
62
|
+
response = client.v1.ai_headshot_generator.generate(
|
|
63
|
+
assets={"image_file_path": "path/to/person.jpg"},
|
|
64
|
+
name="Professional Headshot",
|
|
65
|
+
wait_for_completion=True,
|
|
66
|
+
download_outputs=True,
|
|
67
|
+
download_directory="outputs/",
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
file_client = FilesClient(base_client=self._base_client)
|
|
73
|
+
|
|
74
|
+
image_file_path = assets["image_file_path"]
|
|
75
|
+
assets["image_file_path"] = file_client.upload_file(file=image_file_path)
|
|
76
|
+
|
|
77
|
+
create_response = self.create(
|
|
78
|
+
assets=assets, style=style, name=name, request_options=request_options
|
|
79
|
+
)
|
|
80
|
+
logger.info(f"AI Headshot Generator response: {create_response}")
|
|
81
|
+
|
|
82
|
+
image_projects_client = ImageProjectsClient(base_client=self._base_client)
|
|
83
|
+
response = image_projects_client.check_result(
|
|
84
|
+
id=create_response.id,
|
|
85
|
+
wait_for_completion=wait_for_completion,
|
|
86
|
+
download_outputs=download_outputs,
|
|
87
|
+
download_directory=download_directory,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return response
|
|
91
|
+
|
|
18
92
|
def create(
|
|
19
93
|
self,
|
|
20
94
|
*,
|
|
21
|
-
assets: params.
|
|
95
|
+
assets: params.V1AiHeadshotGeneratorCreateBodyAssets,
|
|
22
96
|
name: typing.Union[
|
|
23
97
|
typing.Optional[str], type_utils.NotGiven
|
|
24
98
|
] = type_utils.NOT_GIVEN,
|
|
99
|
+
style: typing.Union[
|
|
100
|
+
typing.Optional[params.V1AiHeadshotGeneratorCreateBodyStyle],
|
|
101
|
+
type_utils.NotGiven,
|
|
102
|
+
] = type_utils.NOT_GIVEN,
|
|
25
103
|
request_options: typing.Optional[RequestOptions] = None,
|
|
26
|
-
) -> models.
|
|
104
|
+
) -> models.V1AiHeadshotGeneratorCreateResponse:
|
|
27
105
|
"""
|
|
28
|
-
AI
|
|
106
|
+
AI Headshot Generator
|
|
29
107
|
|
|
30
|
-
Create an AI headshot. Each headshot costs 50
|
|
108
|
+
Create an AI headshot. Each headshot costs 50 credits.
|
|
31
109
|
|
|
32
110
|
POST /v1/ai-headshot-generator
|
|
33
111
|
|
|
34
112
|
Args:
|
|
35
|
-
name: The name of image
|
|
113
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
114
|
+
style: V1AiHeadshotGeneratorCreateBodyStyle
|
|
36
115
|
assets: Provide the assets for headshot photo
|
|
37
116
|
request_options: Additional options to customize the HTTP request
|
|
38
117
|
|
|
@@ -52,15 +131,15 @@ class AiHeadshotGeneratorClient:
|
|
|
52
131
|
```
|
|
53
132
|
"""
|
|
54
133
|
_json = to_encodable(
|
|
55
|
-
item={"name": name, "assets": assets},
|
|
56
|
-
dump_with=params.
|
|
134
|
+
item={"name": name, "style": style, "assets": assets},
|
|
135
|
+
dump_with=params._SerializerV1AiHeadshotGeneratorCreateBody,
|
|
57
136
|
)
|
|
58
137
|
return self._base_client.request(
|
|
59
138
|
method="POST",
|
|
60
139
|
path="/v1/ai-headshot-generator",
|
|
61
140
|
auth_names=["bearerAuth"],
|
|
62
141
|
json=_json,
|
|
63
|
-
cast_to=models.
|
|
142
|
+
cast_to=models.V1AiHeadshotGeneratorCreateResponse,
|
|
64
143
|
request_options=request_options or default_request_options(),
|
|
65
144
|
)
|
|
66
145
|
|
|
@@ -69,24 +148,94 @@ class AsyncAiHeadshotGeneratorClient:
|
|
|
69
148
|
def __init__(self, *, base_client: AsyncBaseClient):
|
|
70
149
|
self._base_client = base_client
|
|
71
150
|
|
|
151
|
+
async def generate(
|
|
152
|
+
self,
|
|
153
|
+
*,
|
|
154
|
+
assets: params.V1AiHeadshotGeneratorGenerateBodyAssets,
|
|
155
|
+
name: typing.Union[
|
|
156
|
+
typing.Optional[str], type_utils.NotGiven
|
|
157
|
+
] = type_utils.NOT_GIVEN,
|
|
158
|
+
style: typing.Union[
|
|
159
|
+
typing.Optional[params.V1AiHeadshotGeneratorCreateBodyStyle],
|
|
160
|
+
type_utils.NotGiven,
|
|
161
|
+
] = type_utils.NOT_GIVEN,
|
|
162
|
+
wait_for_completion: bool = True,
|
|
163
|
+
download_outputs: bool = True,
|
|
164
|
+
download_directory: typing.Optional[str] = None,
|
|
165
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
166
|
+
):
|
|
167
|
+
"""
|
|
168
|
+
Generate headshot (alias for create with additional functionality).
|
|
169
|
+
|
|
170
|
+
Generate professional headshots using AI. Each headshot costs 5 credits.
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
174
|
+
assets: Provide the assets for headshot generation
|
|
175
|
+
style: Headshot generation parameters
|
|
176
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
177
|
+
download_outputs: Whether to download the outputs
|
|
178
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
179
|
+
request_options: Additional options to customize the HTTP request
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI Headshot Generator API with the downloaded paths if `download_outputs` is True.
|
|
183
|
+
|
|
184
|
+
Examples:
|
|
185
|
+
```py
|
|
186
|
+
response = await client.v1.ai_headshot_generator.generate(
|
|
187
|
+
assets={"image_file_path": "path/to/person.jpg"},
|
|
188
|
+
name="Professional Headshot",
|
|
189
|
+
wait_for_completion=True,
|
|
190
|
+
download_outputs=True,
|
|
191
|
+
download_directory="outputs/",
|
|
192
|
+
)
|
|
193
|
+
```
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
file_client = AsyncFilesClient(base_client=self._base_client)
|
|
197
|
+
|
|
198
|
+
image_file_path = assets["image_file_path"]
|
|
199
|
+
assets["image_file_path"] = await file_client.upload_file(file=image_file_path)
|
|
200
|
+
|
|
201
|
+
create_response = await self.create(
|
|
202
|
+
assets=assets, style=style, name=name, request_options=request_options
|
|
203
|
+
)
|
|
204
|
+
logger.info(f"AI Headshot Generator response: {create_response}")
|
|
205
|
+
|
|
206
|
+
image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
|
|
207
|
+
response = await image_projects_client.check_result(
|
|
208
|
+
id=create_response.id,
|
|
209
|
+
wait_for_completion=wait_for_completion,
|
|
210
|
+
download_outputs=download_outputs,
|
|
211
|
+
download_directory=download_directory,
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
return response
|
|
215
|
+
|
|
72
216
|
async def create(
|
|
73
217
|
self,
|
|
74
218
|
*,
|
|
75
|
-
assets: params.
|
|
219
|
+
assets: params.V1AiHeadshotGeneratorCreateBodyAssets,
|
|
76
220
|
name: typing.Union[
|
|
77
221
|
typing.Optional[str], type_utils.NotGiven
|
|
78
222
|
] = type_utils.NOT_GIVEN,
|
|
223
|
+
style: typing.Union[
|
|
224
|
+
typing.Optional[params.V1AiHeadshotGeneratorCreateBodyStyle],
|
|
225
|
+
type_utils.NotGiven,
|
|
226
|
+
] = type_utils.NOT_GIVEN,
|
|
79
227
|
request_options: typing.Optional[RequestOptions] = None,
|
|
80
|
-
) -> models.
|
|
228
|
+
) -> models.V1AiHeadshotGeneratorCreateResponse:
|
|
81
229
|
"""
|
|
82
|
-
AI
|
|
230
|
+
AI Headshot Generator
|
|
83
231
|
|
|
84
|
-
Create an AI headshot. Each headshot costs 50
|
|
232
|
+
Create an AI headshot. Each headshot costs 50 credits.
|
|
85
233
|
|
|
86
234
|
POST /v1/ai-headshot-generator
|
|
87
235
|
|
|
88
236
|
Args:
|
|
89
|
-
name: The name of image
|
|
237
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
238
|
+
style: V1AiHeadshotGeneratorCreateBodyStyle
|
|
90
239
|
assets: Provide the assets for headshot photo
|
|
91
240
|
request_options: Additional options to customize the HTTP request
|
|
92
241
|
|
|
@@ -106,14 +255,14 @@ class AsyncAiHeadshotGeneratorClient:
|
|
|
106
255
|
```
|
|
107
256
|
"""
|
|
108
257
|
_json = to_encodable(
|
|
109
|
-
item={"name": name, "assets": assets},
|
|
110
|
-
dump_with=params.
|
|
258
|
+
item={"name": name, "style": style, "assets": assets},
|
|
259
|
+
dump_with=params._SerializerV1AiHeadshotGeneratorCreateBody,
|
|
111
260
|
)
|
|
112
261
|
return await self._base_client.request(
|
|
113
262
|
method="POST",
|
|
114
263
|
path="/v1/ai-headshot-generator",
|
|
115
264
|
auth_names=["bearerAuth"],
|
|
116
265
|
json=_json,
|
|
117
|
-
cast_to=models.
|
|
266
|
+
cast_to=models.V1AiHeadshotGeneratorCreateResponse,
|
|
118
267
|
request_options=request_options or default_request_options(),
|
|
119
268
|
)
|