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
|
@@ -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,19 +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 AiPhotoEditorClient:
|
|
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.V1AiPhotoEditorGenerateBodyAssets,
|
|
31
|
+
resolution: int,
|
|
32
|
+
style: params.V1AiPhotoEditorCreateBodyStyle,
|
|
33
|
+
name: typing.Union[
|
|
34
|
+
typing.Optional[str], type_utils.NotGiven
|
|
35
|
+
] = type_utils.NOT_GIVEN,
|
|
36
|
+
steps: typing.Union[
|
|
37
|
+
typing.Optional[int], type_utils.NotGiven
|
|
38
|
+
] = type_utils.NOT_GIVEN,
|
|
39
|
+
wait_for_completion: bool = True,
|
|
40
|
+
download_outputs: bool = True,
|
|
41
|
+
download_directory: typing.Optional[str] = None,
|
|
42
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
43
|
+
):
|
|
44
|
+
"""
|
|
45
|
+
Generate edited photo (alias for create with additional functionality).
|
|
46
|
+
|
|
47
|
+
Edit photo using AI. Each edit costs 5 credits.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
51
|
+
assets: Provide the assets for photo editor
|
|
52
|
+
style: Photo editing parameters
|
|
53
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
54
|
+
download_outputs: Whether to download the outputs
|
|
55
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
56
|
+
request_options: Additional options to customize the HTTP request
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI Photo Editor API with the downloaded paths if `download_outputs` is True.
|
|
60
|
+
|
|
61
|
+
Examples:
|
|
62
|
+
```py
|
|
63
|
+
response = client.v1.ai_photo_editor.generate(
|
|
64
|
+
assets={"image_file_path": "path/to/photo.jpg"},
|
|
65
|
+
resolution=768,
|
|
66
|
+
style={
|
|
67
|
+
"image_description": "A photo of a person",
|
|
68
|
+
"likeness_strength": 5.2,
|
|
69
|
+
"negative_prompt": "painting, cartoon, sketch",
|
|
70
|
+
"prompt": "A photo portrait of a person wearing a hat",
|
|
71
|
+
"prompt_strength": 3.75,
|
|
72
|
+
"steps": 4,
|
|
73
|
+
"upscale_factor": 2,
|
|
74
|
+
"upscale_fidelity": 0.5,
|
|
75
|
+
},
|
|
76
|
+
name="Edited Portrait",
|
|
77
|
+
wait_for_completion=True,
|
|
78
|
+
download_outputs=True,
|
|
79
|
+
download_directory="outputs/",
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
file_client = FilesClient(base_client=self._base_client)
|
|
85
|
+
|
|
86
|
+
image_file_path = assets["image_file_path"]
|
|
87
|
+
assets["image_file_path"] = file_client.upload_file(file=image_file_path)
|
|
88
|
+
|
|
89
|
+
create_response = self.create(
|
|
90
|
+
assets=assets,
|
|
91
|
+
resolution=resolution,
|
|
92
|
+
style=style,
|
|
93
|
+
name=name,
|
|
94
|
+
steps=steps,
|
|
95
|
+
request_options=request_options,
|
|
96
|
+
)
|
|
97
|
+
logger.info(f"AI Photo Editor response: {create_response}")
|
|
98
|
+
|
|
99
|
+
image_projects_client = ImageProjectsClient(base_client=self._base_client)
|
|
100
|
+
response = image_projects_client.check_result(
|
|
101
|
+
id=create_response.id,
|
|
102
|
+
wait_for_completion=wait_for_completion,
|
|
103
|
+
download_outputs=download_outputs,
|
|
104
|
+
download_directory=download_directory,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
return response
|
|
108
|
+
|
|
18
109
|
def create(
|
|
19
110
|
self,
|
|
20
111
|
*,
|
|
21
|
-
assets: params.
|
|
112
|
+
assets: params.V1AiPhotoEditorCreateBodyAssets,
|
|
22
113
|
resolution: int,
|
|
23
|
-
style: params.
|
|
114
|
+
style: params.V1AiPhotoEditorCreateBodyStyle,
|
|
24
115
|
name: typing.Union[
|
|
25
116
|
typing.Optional[str], type_utils.NotGiven
|
|
26
117
|
] = type_utils.NOT_GIVEN,
|
|
@@ -28,22 +119,22 @@ class AiPhotoEditorClient:
|
|
|
28
119
|
typing.Optional[int], type_utils.NotGiven
|
|
29
120
|
] = type_utils.NOT_GIVEN,
|
|
30
121
|
request_options: typing.Optional[RequestOptions] = None,
|
|
31
|
-
) -> models.
|
|
122
|
+
) -> models.V1AiPhotoEditorCreateResponse:
|
|
32
123
|
"""
|
|
33
124
|
AI Photo Editor
|
|
34
125
|
|
|
35
126
|
> **NOTE**: this API is still in early development stages, and should be avoided. Please reach out to us if you're interested in this API.
|
|
36
127
|
|
|
37
|
-
Edit photo using AI. Each photo costs 10
|
|
128
|
+
Edit photo using AI. Each photo costs 10 credits.
|
|
38
129
|
|
|
39
130
|
POST /v1/ai-photo-editor
|
|
40
131
|
|
|
41
132
|
Args:
|
|
42
|
-
name: The name of image
|
|
133
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
43
134
|
steps: Deprecated: Please use `.style.steps` instead. Number of iterations used to generate the output. Higher values improve quality and increase the strength of the prompt but increase processing time.
|
|
44
135
|
assets: Provide the assets for photo editor
|
|
45
136
|
resolution: The resolution of the final output image. The allowed value is based on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details
|
|
46
|
-
style:
|
|
137
|
+
style: V1AiPhotoEditorCreateBodyStyle
|
|
47
138
|
request_options: Additional options to customize the HTTP request
|
|
48
139
|
|
|
49
140
|
Returns:
|
|
@@ -61,8 +152,12 @@ class AiPhotoEditorClient:
|
|
|
61
152
|
style={
|
|
62
153
|
"image_description": "A photo of a person",
|
|
63
154
|
"likeness_strength": 5.2,
|
|
155
|
+
"negative_prompt": "painting, cartoon, sketch",
|
|
64
156
|
"prompt": "A photo portrait of a person wearing a hat",
|
|
65
157
|
"prompt_strength": 3.75,
|
|
158
|
+
"steps": 4,
|
|
159
|
+
"upscale_factor": 2,
|
|
160
|
+
"upscale_fidelity": 0.5,
|
|
66
161
|
},
|
|
67
162
|
name="Photo Editor image",
|
|
68
163
|
)
|
|
@@ -76,14 +171,14 @@ class AiPhotoEditorClient:
|
|
|
76
171
|
"resolution": resolution,
|
|
77
172
|
"style": style,
|
|
78
173
|
},
|
|
79
|
-
dump_with=params.
|
|
174
|
+
dump_with=params._SerializerV1AiPhotoEditorCreateBody,
|
|
80
175
|
)
|
|
81
176
|
return self._base_client.request(
|
|
82
177
|
method="POST",
|
|
83
178
|
path="/v1/ai-photo-editor",
|
|
84
179
|
auth_names=["bearerAuth"],
|
|
85
180
|
json=_json,
|
|
86
|
-
cast_to=models.
|
|
181
|
+
cast_to=models.V1AiPhotoEditorCreateResponse,
|
|
87
182
|
request_options=request_options or default_request_options(),
|
|
88
183
|
)
|
|
89
184
|
|
|
@@ -92,12 +187,94 @@ class AsyncAiPhotoEditorClient:
|
|
|
92
187
|
def __init__(self, *, base_client: AsyncBaseClient):
|
|
93
188
|
self._base_client = base_client
|
|
94
189
|
|
|
190
|
+
async def generate(
|
|
191
|
+
self,
|
|
192
|
+
*,
|
|
193
|
+
assets: params.V1AiPhotoEditorGenerateBodyAssets,
|
|
194
|
+
resolution: int,
|
|
195
|
+
style: params.V1AiPhotoEditorCreateBodyStyle,
|
|
196
|
+
name: typing.Union[
|
|
197
|
+
typing.Optional[str], type_utils.NotGiven
|
|
198
|
+
] = type_utils.NOT_GIVEN,
|
|
199
|
+
steps: typing.Union[
|
|
200
|
+
typing.Optional[int], type_utils.NotGiven
|
|
201
|
+
] = type_utils.NOT_GIVEN,
|
|
202
|
+
wait_for_completion: bool = True,
|
|
203
|
+
download_outputs: bool = True,
|
|
204
|
+
download_directory: typing.Optional[str] = None,
|
|
205
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
206
|
+
):
|
|
207
|
+
"""
|
|
208
|
+
Generate edited photo (alias for create with additional functionality).
|
|
209
|
+
|
|
210
|
+
Edit photo using AI. Each edit costs 5 credits.
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
214
|
+
assets: Provide the assets for photo editor
|
|
215
|
+
style: Photo editing parameters
|
|
216
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
217
|
+
download_outputs: Whether to download the outputs
|
|
218
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
219
|
+
request_options: Additional options to customize the HTTP request
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI Photo Editor API with the downloaded paths if `download_outputs` is True.
|
|
223
|
+
|
|
224
|
+
Examples:
|
|
225
|
+
```py
|
|
226
|
+
response = await client.v1.ai_photo_editor.generate(
|
|
227
|
+
assets={"image_file_path": "path/to/photo.jpg"},
|
|
228
|
+
resolution=768,
|
|
229
|
+
style={
|
|
230
|
+
"image_description": "A photo of a person",
|
|
231
|
+
"likeness_strength": 5.2,
|
|
232
|
+
"negative_prompt": "painting, cartoon, sketch",
|
|
233
|
+
"prompt": "A photo portrait of a person wearing a hat",
|
|
234
|
+
"prompt_strength": 3.75,
|
|
235
|
+
"steps": 4,
|
|
236
|
+
"upscale_factor": 2,
|
|
237
|
+
"upscale_fidelity": 0.5,
|
|
238
|
+
},
|
|
239
|
+
name="Edited Portrait",
|
|
240
|
+
wait_for_completion=True,
|
|
241
|
+
download_outputs=True,
|
|
242
|
+
download_directory="outputs/",
|
|
243
|
+
)
|
|
244
|
+
```
|
|
245
|
+
"""
|
|
246
|
+
|
|
247
|
+
file_client = AsyncFilesClient(base_client=self._base_client)
|
|
248
|
+
|
|
249
|
+
image_file_path = assets["image_file_path"]
|
|
250
|
+
assets["image_file_path"] = await file_client.upload_file(file=image_file_path)
|
|
251
|
+
|
|
252
|
+
create_response = await self.create(
|
|
253
|
+
assets=assets,
|
|
254
|
+
resolution=resolution,
|
|
255
|
+
style=style,
|
|
256
|
+
name=name,
|
|
257
|
+
steps=steps,
|
|
258
|
+
request_options=request_options,
|
|
259
|
+
)
|
|
260
|
+
logger.info(f"AI Photo Editor response: {create_response}")
|
|
261
|
+
|
|
262
|
+
image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
|
|
263
|
+
response = await image_projects_client.check_result(
|
|
264
|
+
id=create_response.id,
|
|
265
|
+
wait_for_completion=wait_for_completion,
|
|
266
|
+
download_outputs=download_outputs,
|
|
267
|
+
download_directory=download_directory,
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
return response
|
|
271
|
+
|
|
95
272
|
async def create(
|
|
96
273
|
self,
|
|
97
274
|
*,
|
|
98
|
-
assets: params.
|
|
275
|
+
assets: params.V1AiPhotoEditorCreateBodyAssets,
|
|
99
276
|
resolution: int,
|
|
100
|
-
style: params.
|
|
277
|
+
style: params.V1AiPhotoEditorCreateBodyStyle,
|
|
101
278
|
name: typing.Union[
|
|
102
279
|
typing.Optional[str], type_utils.NotGiven
|
|
103
280
|
] = type_utils.NOT_GIVEN,
|
|
@@ -105,22 +282,22 @@ class AsyncAiPhotoEditorClient:
|
|
|
105
282
|
typing.Optional[int], type_utils.NotGiven
|
|
106
283
|
] = type_utils.NOT_GIVEN,
|
|
107
284
|
request_options: typing.Optional[RequestOptions] = None,
|
|
108
|
-
) -> models.
|
|
285
|
+
) -> models.V1AiPhotoEditorCreateResponse:
|
|
109
286
|
"""
|
|
110
287
|
AI Photo Editor
|
|
111
288
|
|
|
112
289
|
> **NOTE**: this API is still in early development stages, and should be avoided. Please reach out to us if you're interested in this API.
|
|
113
290
|
|
|
114
|
-
Edit photo using AI. Each photo costs 10
|
|
291
|
+
Edit photo using AI. Each photo costs 10 credits.
|
|
115
292
|
|
|
116
293
|
POST /v1/ai-photo-editor
|
|
117
294
|
|
|
118
295
|
Args:
|
|
119
|
-
name: The name of image
|
|
296
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
120
297
|
steps: Deprecated: Please use `.style.steps` instead. Number of iterations used to generate the output. Higher values improve quality and increase the strength of the prompt but increase processing time.
|
|
121
298
|
assets: Provide the assets for photo editor
|
|
122
299
|
resolution: The resolution of the final output image. The allowed value is based on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details
|
|
123
|
-
style:
|
|
300
|
+
style: V1AiPhotoEditorCreateBodyStyle
|
|
124
301
|
request_options: Additional options to customize the HTTP request
|
|
125
302
|
|
|
126
303
|
Returns:
|
|
@@ -138,8 +315,12 @@ class AsyncAiPhotoEditorClient:
|
|
|
138
315
|
style={
|
|
139
316
|
"image_description": "A photo of a person",
|
|
140
317
|
"likeness_strength": 5.2,
|
|
318
|
+
"negative_prompt": "painting, cartoon, sketch",
|
|
141
319
|
"prompt": "A photo portrait of a person wearing a hat",
|
|
142
320
|
"prompt_strength": 3.75,
|
|
321
|
+
"steps": 4,
|
|
322
|
+
"upscale_factor": 2,
|
|
323
|
+
"upscale_fidelity": 0.5,
|
|
143
324
|
},
|
|
144
325
|
name="Photo Editor image",
|
|
145
326
|
)
|
|
@@ -153,13 +334,13 @@ class AsyncAiPhotoEditorClient:
|
|
|
153
334
|
"resolution": resolution,
|
|
154
335
|
"style": style,
|
|
155
336
|
},
|
|
156
|
-
dump_with=params.
|
|
337
|
+
dump_with=params._SerializerV1AiPhotoEditorCreateBody,
|
|
157
338
|
)
|
|
158
339
|
return await self._base_client.request(
|
|
159
340
|
method="POST",
|
|
160
341
|
path="/v1/ai-photo-editor",
|
|
161
342
|
auth_names=["bearerAuth"],
|
|
162
343
|
json=_json,
|
|
163
|
-
cast_to=models.
|
|
344
|
+
cast_to=models.V1AiPhotoEditorCreateResponse,
|
|
164
345
|
request_options=request_options or default_request_options(),
|
|
165
346
|
)
|
|
@@ -1,11 +1,80 @@
|
|
|
1
|
+
# v1.ai_qr_code_generator
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
AI QR Code
|
|
3
|
+
## Module Functions
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<!-- CUSTOM DOCS START -->
|
|
6
|
+
|
|
7
|
+
### Ai Qr Code 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_qr_code_generator.generate(
|
|
35
|
+
content="https://magichour.ai",
|
|
36
|
+
style={"art_style": "Watercolor"},
|
|
37
|
+
name="Qr Code 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_qr_code_generator.generate(
|
|
52
|
+
content="https://magichour.ai",
|
|
53
|
+
style={"art_style": "Watercolor"},
|
|
54
|
+
name="Qr Code image",
|
|
55
|
+
wait_for_completion=True,
|
|
56
|
+
download_outputs=True,
|
|
57
|
+
download_directory="outputs"
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
<!-- CUSTOM DOCS END -->
|
|
62
|
+
|
|
63
|
+
### AI QR Code Generator <a name="create"></a>
|
|
64
|
+
|
|
65
|
+
Create an AI QR code. Each QR code costs 0 credits.
|
|
6
66
|
|
|
7
67
|
**API Endpoint**: `POST /v1/ai-qr-code-generator`
|
|
8
68
|
|
|
69
|
+
#### Parameters
|
|
70
|
+
|
|
71
|
+
| Parameter | Required | Description | Example |
|
|
72
|
+
| -------------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
|
|
73
|
+
| `content` | ✓ | The content of the QR code. | `"https://magichour.ai"` |
|
|
74
|
+
| `style` | ✓ | | `{"art_style": "Watercolor"}` |
|
|
75
|
+
| `└─ art_style` | ✓ | To use our templates, pass in one of Watercolor, Cyberpunk City, Ink Landscape, Interior Painting, Japanese Street, Mech, Minecraft, Picasso Painting, Game Map, Spaceship, Chinese Painting, Winter Village, or pass any custom art style. | `"Watercolor"` |
|
|
76
|
+
| `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Qr Code image"` |
|
|
77
|
+
|
|
9
78
|
#### Synchronous Client
|
|
10
79
|
|
|
11
80
|
```python
|
|
@@ -33,3 +102,15 @@ res = await client.v1.ai_qr_code_generator.create(
|
|
|
33
102
|
name="Qr Code image",
|
|
34
103
|
)
|
|
35
104
|
```
|
|
105
|
+
|
|
106
|
+
#### Response
|
|
107
|
+
|
|
108
|
+
##### Type
|
|
109
|
+
|
|
110
|
+
[V1AiQrCodeGeneratorCreateResponse](/magic_hour/types/models/v1_ai_qr_code_generator_create_response.py)
|
|
111
|
+
|
|
112
|
+
##### Example
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
{"credits_charged": 0, "frame_cost": 0, "id": "cuid-example"}
|
|
116
|
+
```
|
|
@@ -1,6 +1,12 @@
|
|
|
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.image_projects.client import (
|
|
5
|
+
AsyncImageProjectsClient,
|
|
6
|
+
ImageProjectsClient,
|
|
7
|
+
)
|
|
8
|
+
from magic_hour.types import models, params
|
|
9
|
+
from make_api_request import (
|
|
4
10
|
AsyncBaseClient,
|
|
5
11
|
RequestOptions,
|
|
6
12
|
SyncBaseClient,
|
|
@@ -8,34 +14,93 @@ from magic_hour.core import (
|
|
|
8
14
|
to_encodable,
|
|
9
15
|
type_utils,
|
|
10
16
|
)
|
|
11
|
-
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
logger = get_sdk_logger(__name__)
|
|
12
20
|
|
|
13
21
|
|
|
14
22
|
class AiQrCodeGeneratorClient:
|
|
15
23
|
def __init__(self, *, base_client: SyncBaseClient):
|
|
16
24
|
self._base_client = base_client
|
|
17
25
|
|
|
26
|
+
def generate(
|
|
27
|
+
self,
|
|
28
|
+
*,
|
|
29
|
+
content: str,
|
|
30
|
+
style: params.V1AiQrCodeGeneratorCreateBodyStyle,
|
|
31
|
+
name: typing.Union[
|
|
32
|
+
typing.Optional[str], type_utils.NotGiven
|
|
33
|
+
] = type_utils.NOT_GIVEN,
|
|
34
|
+
wait_for_completion: bool = True,
|
|
35
|
+
download_outputs: bool = True,
|
|
36
|
+
download_directory: typing.Optional[str] = None,
|
|
37
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
38
|
+
):
|
|
39
|
+
"""
|
|
40
|
+
Generate QR code (alias for create with additional functionality).
|
|
41
|
+
|
|
42
|
+
Create an AI QR code. Each QR code costs 5 credits.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
46
|
+
style: The art style to use for QR code generation
|
|
47
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
48
|
+
download_outputs: Whether to download the outputs
|
|
49
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
50
|
+
request_options: Additional options to customize the HTTP request
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI QR Code Generator API with the downloaded paths if `download_outputs` is True.
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
```py
|
|
57
|
+
response = client.v1.ai_qr_code_generator.generate(
|
|
58
|
+
content="https://magichour.ai",
|
|
59
|
+
style={"art_style": "Watercolor"},
|
|
60
|
+
name="Artistic QR Code",
|
|
61
|
+
wait_for_completion=True,
|
|
62
|
+
download_outputs=True,
|
|
63
|
+
download_directory="outputs/",
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
create_response = self.create(
|
|
69
|
+
content=content, style=style, name=name, request_options=request_options
|
|
70
|
+
)
|
|
71
|
+
logger.info(f"AI QR Code Generator response: {create_response}")
|
|
72
|
+
|
|
73
|
+
image_projects_client = ImageProjectsClient(base_client=self._base_client)
|
|
74
|
+
response = image_projects_client.check_result(
|
|
75
|
+
id=create_response.id,
|
|
76
|
+
wait_for_completion=wait_for_completion,
|
|
77
|
+
download_outputs=download_outputs,
|
|
78
|
+
download_directory=download_directory,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
return response
|
|
82
|
+
|
|
18
83
|
def create(
|
|
19
84
|
self,
|
|
20
85
|
*,
|
|
21
86
|
content: str,
|
|
22
|
-
style: params.
|
|
87
|
+
style: params.V1AiQrCodeGeneratorCreateBodyStyle,
|
|
23
88
|
name: typing.Union[
|
|
24
89
|
typing.Optional[str], type_utils.NotGiven
|
|
25
90
|
] = type_utils.NOT_GIVEN,
|
|
26
91
|
request_options: typing.Optional[RequestOptions] = None,
|
|
27
|
-
) -> models.
|
|
92
|
+
) -> models.V1AiQrCodeGeneratorCreateResponse:
|
|
28
93
|
"""
|
|
29
|
-
AI QR Code
|
|
94
|
+
AI QR Code Generator
|
|
30
95
|
|
|
31
|
-
Create an AI QR code. Each QR code costs
|
|
96
|
+
Create an AI QR code. Each QR code costs 0 credits.
|
|
32
97
|
|
|
33
98
|
POST /v1/ai-qr-code-generator
|
|
34
99
|
|
|
35
100
|
Args:
|
|
36
|
-
name: The name of image
|
|
101
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
37
102
|
content: The content of the QR code.
|
|
38
|
-
style:
|
|
103
|
+
style: V1AiQrCodeGeneratorCreateBodyStyle
|
|
39
104
|
request_options: Additional options to customize the HTTP request
|
|
40
105
|
|
|
41
106
|
Returns:
|
|
@@ -56,14 +121,14 @@ class AiQrCodeGeneratorClient:
|
|
|
56
121
|
"""
|
|
57
122
|
_json = to_encodable(
|
|
58
123
|
item={"name": name, "content": content, "style": style},
|
|
59
|
-
dump_with=params.
|
|
124
|
+
dump_with=params._SerializerV1AiQrCodeGeneratorCreateBody,
|
|
60
125
|
)
|
|
61
126
|
return self._base_client.request(
|
|
62
127
|
method="POST",
|
|
63
128
|
path="/v1/ai-qr-code-generator",
|
|
64
129
|
auth_names=["bearerAuth"],
|
|
65
130
|
json=_json,
|
|
66
|
-
cast_to=models.
|
|
131
|
+
cast_to=models.V1AiQrCodeGeneratorCreateResponse,
|
|
67
132
|
request_options=request_options or default_request_options(),
|
|
68
133
|
)
|
|
69
134
|
|
|
@@ -72,27 +137,84 @@ class AsyncAiQrCodeGeneratorClient:
|
|
|
72
137
|
def __init__(self, *, base_client: AsyncBaseClient):
|
|
73
138
|
self._base_client = base_client
|
|
74
139
|
|
|
140
|
+
async def generate(
|
|
141
|
+
self,
|
|
142
|
+
*,
|
|
143
|
+
content: str,
|
|
144
|
+
style: params.V1AiQrCodeGeneratorCreateBodyStyle,
|
|
145
|
+
name: typing.Union[
|
|
146
|
+
typing.Optional[str], type_utils.NotGiven
|
|
147
|
+
] = type_utils.NOT_GIVEN,
|
|
148
|
+
wait_for_completion: bool = True,
|
|
149
|
+
download_outputs: bool = True,
|
|
150
|
+
download_directory: typing.Optional[str] = None,
|
|
151
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
152
|
+
):
|
|
153
|
+
"""
|
|
154
|
+
Generate QR code (alias for create with additional functionality).
|
|
155
|
+
|
|
156
|
+
Create an AI QR code. Each QR code costs 5 credits.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
160
|
+
style: The art style to use for QR code generation
|
|
161
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
162
|
+
download_outputs: Whether to download the outputs
|
|
163
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
164
|
+
request_options: Additional options to customize the HTTP request
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI QR Code Generator API with the downloaded paths if `download_outputs` is True.
|
|
168
|
+
|
|
169
|
+
Examples:
|
|
170
|
+
```py
|
|
171
|
+
response = await client.v1.ai_qr_code_generator.generate(
|
|
172
|
+
content="https://magichour.ai",
|
|
173
|
+
style={"art_style": "Watercolor"},
|
|
174
|
+
name="Artistic QR Code",
|
|
175
|
+
wait_for_completion=True,
|
|
176
|
+
download_outputs=True,
|
|
177
|
+
download_directory="outputs/",
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
"""
|
|
181
|
+
|
|
182
|
+
create_response = await self.create(
|
|
183
|
+
content=content, style=style, name=name, request_options=request_options
|
|
184
|
+
)
|
|
185
|
+
logger.info(f"AI QR Code Generator response: {create_response}")
|
|
186
|
+
|
|
187
|
+
image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
|
|
188
|
+
response = await image_projects_client.check_result(
|
|
189
|
+
id=create_response.id,
|
|
190
|
+
wait_for_completion=wait_for_completion,
|
|
191
|
+
download_outputs=download_outputs,
|
|
192
|
+
download_directory=download_directory,
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
return response
|
|
196
|
+
|
|
75
197
|
async def create(
|
|
76
198
|
self,
|
|
77
199
|
*,
|
|
78
200
|
content: str,
|
|
79
|
-
style: params.
|
|
201
|
+
style: params.V1AiQrCodeGeneratorCreateBodyStyle,
|
|
80
202
|
name: typing.Union[
|
|
81
203
|
typing.Optional[str], type_utils.NotGiven
|
|
82
204
|
] = type_utils.NOT_GIVEN,
|
|
83
205
|
request_options: typing.Optional[RequestOptions] = None,
|
|
84
|
-
) -> models.
|
|
206
|
+
) -> models.V1AiQrCodeGeneratorCreateResponse:
|
|
85
207
|
"""
|
|
86
|
-
AI QR Code
|
|
208
|
+
AI QR Code Generator
|
|
87
209
|
|
|
88
|
-
Create an AI QR code. Each QR code costs
|
|
210
|
+
Create an AI QR code. Each QR code costs 0 credits.
|
|
89
211
|
|
|
90
212
|
POST /v1/ai-qr-code-generator
|
|
91
213
|
|
|
92
214
|
Args:
|
|
93
|
-
name: The name of image
|
|
215
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
94
216
|
content: The content of the QR code.
|
|
95
|
-
style:
|
|
217
|
+
style: V1AiQrCodeGeneratorCreateBodyStyle
|
|
96
218
|
request_options: Additional options to customize the HTTP request
|
|
97
219
|
|
|
98
220
|
Returns:
|
|
@@ -113,13 +235,13 @@ class AsyncAiQrCodeGeneratorClient:
|
|
|
113
235
|
"""
|
|
114
236
|
_json = to_encodable(
|
|
115
237
|
item={"name": name, "content": content, "style": style},
|
|
116
|
-
dump_with=params.
|
|
238
|
+
dump_with=params._SerializerV1AiQrCodeGeneratorCreateBody,
|
|
117
239
|
)
|
|
118
240
|
return await self._base_client.request(
|
|
119
241
|
method="POST",
|
|
120
242
|
path="/v1/ai-qr-code-generator",
|
|
121
243
|
auth_names=["bearerAuth"],
|
|
122
244
|
json=_json,
|
|
123
|
-
cast_to=models.
|
|
245
|
+
cast_to=models.V1AiQrCodeGeneratorCreateResponse,
|
|
124
246
|
request_options=request_options or default_request_options(),
|
|
125
247
|
)
|