magic_hour 0.35.0__py3-none-any.whl → 0.36.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.

Potentially problematic release.


This version of magic_hour might be problematic. Click here for more details.

Files changed (94) hide show
  1. magic_hour/README.md +35 -0
  2. magic_hour/core/base_client.py +6 -5
  3. magic_hour/core/query.py +12 -6
  4. magic_hour/core/request.py +3 -3
  5. magic_hour/core/response.py +18 -14
  6. magic_hour/core/utils.py +3 -3
  7. magic_hour/environment.py +1 -1
  8. magic_hour/helpers/__init__.py +3 -0
  9. magic_hour/helpers/download.py +75 -0
  10. magic_hour/resources/v1/README.md +33 -0
  11. magic_hour/resources/v1/ai_clothes_changer/README.md +73 -0
  12. magic_hour/resources/v1/ai_clothes_changer/client.py +146 -0
  13. magic_hour/resources/v1/ai_face_editor/README.md +110 -0
  14. magic_hour/resources/v1/ai_face_editor/client.py +168 -0
  15. magic_hour/resources/v1/ai_gif_generator/README.md +59 -0
  16. magic_hour/resources/v1/ai_gif_generator/client.py +119 -0
  17. magic_hour/resources/v1/ai_headshot_generator/README.md +60 -0
  18. magic_hour/resources/v1/ai_headshot_generator/client.py +140 -0
  19. magic_hour/resources/v1/ai_image_editor/README.md +64 -0
  20. magic_hour/resources/v1/ai_image_editor/client.py +136 -0
  21. magic_hour/resources/v1/ai_image_generator/README.md +66 -0
  22. magic_hour/resources/v1/ai_image_generator/client.py +139 -0
  23. magic_hour/resources/v1/ai_image_upscaler/README.md +67 -0
  24. magic_hour/resources/v1/ai_image_upscaler/client.py +150 -0
  25. magic_hour/resources/v1/ai_meme_generator/README.md +71 -0
  26. magic_hour/resources/v1/ai_meme_generator/client.py +127 -0
  27. magic_hour/resources/v1/ai_photo_editor/README.md +98 -7
  28. magic_hour/resources/v1/ai_photo_editor/client.py +174 -0
  29. magic_hour/resources/v1/ai_qr_code_generator/README.md +63 -0
  30. magic_hour/resources/v1/ai_qr_code_generator/client.py +123 -0
  31. magic_hour/resources/v1/ai_talking_photo/README.md +74 -0
  32. magic_hour/resources/v1/ai_talking_photo/client.py +170 -0
  33. magic_hour/resources/v1/animation/README.md +100 -0
  34. magic_hour/resources/v1/animation/client.py +218 -0
  35. magic_hour/resources/v1/auto_subtitle_generator/README.md +69 -0
  36. magic_hour/resources/v1/auto_subtitle_generator/client.py +178 -0
  37. magic_hour/resources/v1/face_detection/README.md +59 -0
  38. magic_hour/resources/v1/face_detection/__init__.py +10 -2
  39. magic_hour/resources/v1/face_detection/client.py +179 -0
  40. magic_hour/resources/v1/face_swap/README.md +105 -8
  41. magic_hour/resources/v1/face_swap/client.py +242 -0
  42. magic_hour/resources/v1/face_swap_photo/README.md +84 -0
  43. magic_hour/resources/v1/face_swap_photo/client.py +172 -0
  44. magic_hour/resources/v1/files/README.md +6 -0
  45. magic_hour/resources/v1/files/client.py +350 -0
  46. magic_hour/resources/v1/files/client_test.py +414 -0
  47. magic_hour/resources/v1/files/upload_urls/README.md +8 -0
  48. magic_hour/resources/v1/image_background_remover/README.md +68 -0
  49. magic_hour/resources/v1/image_background_remover/client.py +130 -0
  50. magic_hour/resources/v1/image_projects/README.md +8 -0
  51. magic_hour/resources/v1/image_projects/__init__.py +10 -2
  52. magic_hour/resources/v1/image_projects/client.py +138 -0
  53. magic_hour/resources/v1/image_projects/client_test.py +527 -0
  54. magic_hour/resources/v1/image_to_video/README.md +77 -9
  55. magic_hour/resources/v1/image_to_video/client.py +186 -0
  56. magic_hour/resources/v1/lip_sync/README.md +87 -9
  57. magic_hour/resources/v1/lip_sync/client.py +210 -0
  58. magic_hour/resources/v1/photo_colorizer/README.md +59 -0
  59. magic_hour/resources/v1/photo_colorizer/client.py +130 -0
  60. magic_hour/resources/v1/text_to_video/README.md +68 -0
  61. magic_hour/resources/v1/text_to_video/client.py +151 -0
  62. magic_hour/resources/v1/video_projects/README.md +8 -0
  63. magic_hour/resources/v1/video_projects/__init__.py +10 -2
  64. magic_hour/resources/v1/video_projects/client.py +137 -0
  65. magic_hour/resources/v1/video_projects/client_test.py +527 -0
  66. magic_hour/resources/v1/video_to_video/README.md +98 -10
  67. magic_hour/resources/v1/video_to_video/client.py +222 -0
  68. magic_hour/types/params/__init__.py +58 -0
  69. magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
  70. magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
  71. magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
  72. magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +17 -0
  73. magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
  74. magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
  75. magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
  76. magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
  77. magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
  78. magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
  79. magic_hour/types/params/v1_face_swap_create_body.py +12 -0
  80. magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
  81. magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
  82. magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
  83. magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
  84. magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
  85. magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
  86. magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
  87. magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
  88. magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
  89. magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
  90. magic_hour-0.36.0.dist-info/METADATA +303 -0
  91. {magic_hour-0.35.0.dist-info → magic_hour-0.36.0.dist-info}/RECORD +93 -65
  92. magic_hour-0.35.0.dist-info/METADATA +0 -166
  93. {magic_hour-0.35.0.dist-info → magic_hour-0.36.0.dist-info}/LICENSE +0 -0
  94. {magic_hour-0.35.0.dist-info → magic_hour-0.36.0.dist-info}/WHEEL +0 -0
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  import typing
2
3
 
3
4
  from magic_hour.core import (
@@ -8,13 +9,104 @@ from magic_hour.core import (
8
9
  to_encodable,
9
10
  type_utils,
10
11
  )
12
+ from magic_hour.resources.v1.files.client import AsyncFilesClient, FilesClient
13
+ from magic_hour.resources.v1.image_projects.client import (
14
+ AsyncImageProjectsClient,
15
+ ImageProjectsClient,
16
+ )
11
17
  from magic_hour.types import models, params
12
18
 
13
19
 
20
+ logging.basicConfig(level=logging.INFO)
21
+ logger = logging.getLogger(__name__)
22
+
23
+
14
24
  class AiPhotoEditorClient:
15
25
  def __init__(self, *, base_client: SyncBaseClient):
16
26
  self._base_client = base_client
17
27
 
28
+ def generate(
29
+ self,
30
+ *,
31
+ assets: params.V1AiPhotoEditorGenerateBodyAssets,
32
+ resolution: int,
33
+ style: params.V1AiPhotoEditorCreateBodyStyle,
34
+ name: typing.Union[
35
+ typing.Optional[str], type_utils.NotGiven
36
+ ] = type_utils.NOT_GIVEN,
37
+ steps: typing.Union[
38
+ typing.Optional[int], type_utils.NotGiven
39
+ ] = type_utils.NOT_GIVEN,
40
+ wait_for_completion: bool = True,
41
+ download_outputs: bool = True,
42
+ download_directory: typing.Optional[str] = None,
43
+ request_options: typing.Optional[RequestOptions] = None,
44
+ ):
45
+ """
46
+ Generate edited photo (alias for create with additional functionality).
47
+
48
+ Edit photo using AI. Each edit costs 5 credits.
49
+
50
+ Args:
51
+ name: The name of image. This value is mainly used for your own identification of the image.
52
+ assets: Provide the assets for photo editor
53
+ style: Photo editing parameters
54
+ wait_for_completion: Whether to wait for the image project to complete
55
+ download_outputs: Whether to download the outputs
56
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
57
+ request_options: Additional options to customize the HTTP request
58
+
59
+ Returns:
60
+ V1ImageProjectsGetResponseWithDownloads: The response from the AI Photo Editor API with the downloaded paths if `download_outputs` is True.
61
+
62
+ Examples:
63
+ ```py
64
+ response = client.v1.ai_photo_editor.generate(
65
+ assets={"image_file_path": "path/to/photo.jpg"},
66
+ resolution=768,
67
+ style={
68
+ "image_description": "A photo of a person",
69
+ "likeness_strength": 5.2,
70
+ "negative_prompt": "painting, cartoon, sketch",
71
+ "prompt": "A photo portrait of a person wearing a hat",
72
+ "prompt_strength": 3.75,
73
+ "steps": 4,
74
+ "upscale_factor": 2,
75
+ "upscale_fidelity": 0.5,
76
+ },
77
+ name="Edited Portrait",
78
+ wait_for_completion=True,
79
+ download_outputs=True,
80
+ download_directory="outputs/",
81
+ )
82
+ ```
83
+ """
84
+
85
+ file_client = FilesClient(base_client=self._base_client)
86
+
87
+ image_file_path = assets["image_file_path"]
88
+ assets["image_file_path"] = file_client.upload_file(file=image_file_path)
89
+
90
+ create_response = self.create(
91
+ assets=assets,
92
+ resolution=resolution,
93
+ style=style,
94
+ name=name,
95
+ steps=steps,
96
+ request_options=request_options,
97
+ )
98
+ logger.info(f"AI Photo Editor response: {create_response}")
99
+
100
+ image_projects_client = ImageProjectsClient(base_client=self._base_client)
101
+ response = image_projects_client.check_result(
102
+ id=create_response.id,
103
+ wait_for_completion=wait_for_completion,
104
+ download_outputs=download_outputs,
105
+ download_directory=download_directory,
106
+ )
107
+
108
+ return response
109
+
18
110
  def create(
19
111
  self,
20
112
  *,
@@ -96,6 +188,88 @@ class AsyncAiPhotoEditorClient:
96
188
  def __init__(self, *, base_client: AsyncBaseClient):
97
189
  self._base_client = base_client
98
190
 
191
+ async def generate(
192
+ self,
193
+ *,
194
+ assets: params.V1AiPhotoEditorGenerateBodyAssets,
195
+ resolution: int,
196
+ style: params.V1AiPhotoEditorCreateBodyStyle,
197
+ name: typing.Union[
198
+ typing.Optional[str], type_utils.NotGiven
199
+ ] = type_utils.NOT_GIVEN,
200
+ steps: typing.Union[
201
+ typing.Optional[int], type_utils.NotGiven
202
+ ] = type_utils.NOT_GIVEN,
203
+ wait_for_completion: bool = True,
204
+ download_outputs: bool = True,
205
+ download_directory: typing.Optional[str] = None,
206
+ request_options: typing.Optional[RequestOptions] = None,
207
+ ):
208
+ """
209
+ Generate edited photo (alias for create with additional functionality).
210
+
211
+ Edit photo using AI. Each edit costs 5 credits.
212
+
213
+ Args:
214
+ name: The name of image. This value is mainly used for your own identification of the image.
215
+ assets: Provide the assets for photo editor
216
+ style: Photo editing parameters
217
+ wait_for_completion: Whether to wait for the image project to complete
218
+ download_outputs: Whether to download the outputs
219
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
220
+ request_options: Additional options to customize the HTTP request
221
+
222
+ Returns:
223
+ V1ImageProjectsGetResponseWithDownloads: The response from the AI Photo Editor API with the downloaded paths if `download_outputs` is True.
224
+
225
+ Examples:
226
+ ```py
227
+ response = await client.v1.ai_photo_editor.generate(
228
+ assets={"image_file_path": "path/to/photo.jpg"},
229
+ resolution=768,
230
+ style={
231
+ "image_description": "A photo of a person",
232
+ "likeness_strength": 5.2,
233
+ "negative_prompt": "painting, cartoon, sketch",
234
+ "prompt": "A photo portrait of a person wearing a hat",
235
+ "prompt_strength": 3.75,
236
+ "steps": 4,
237
+ "upscale_factor": 2,
238
+ "upscale_fidelity": 0.5,
239
+ },
240
+ name="Edited Portrait",
241
+ wait_for_completion=True,
242
+ download_outputs=True,
243
+ download_directory="outputs/",
244
+ )
245
+ ```
246
+ """
247
+
248
+ file_client = AsyncFilesClient(base_client=self._base_client)
249
+
250
+ image_file_path = assets["image_file_path"]
251
+ assets["image_file_path"] = await file_client.upload_file(file=image_file_path)
252
+
253
+ create_response = await self.create(
254
+ assets=assets,
255
+ resolution=resolution,
256
+ style=style,
257
+ name=name,
258
+ steps=steps,
259
+ request_options=request_options,
260
+ )
261
+ logger.info(f"AI Photo Editor response: {create_response}")
262
+
263
+ image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
264
+ response = await image_projects_client.check_result(
265
+ id=create_response.id,
266
+ wait_for_completion=wait_for_completion,
267
+ download_outputs=download_outputs,
268
+ download_directory=download_directory,
269
+ )
270
+
271
+ return response
272
+
99
273
  async def create(
100
274
  self,
101
275
  *,
@@ -1,3 +1,64 @@
1
+ # v1_ai_qr_code_generator
2
+
3
+ ## Module Functions
4
+
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 -->
1
62
 
2
63
  ### AI QR Code <a name="create"></a>
3
64
 
@@ -11,6 +72,7 @@ Create an AI QR code. Each QR code costs 20 credits.
11
72
  |-----------|:--------:|-------------|--------|
12
73
  | `content` | ✓ | The content of the QR code. | `"https://magichour.ai"` |
13
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"` |
14
76
  | `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Qr Code image"` |
15
77
 
16
78
  #### Synchronous Client
@@ -50,3 +112,4 @@ res = await client.v1.ai_qr_code_generator.create(
50
112
 
51
113
  ##### Example
52
114
  `{"credits_charged": 20, "frame_cost": 20, "id": "cuid-example"}`
115
+
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  import typing
2
3
 
3
4
  from magic_hour.core import (
@@ -8,13 +9,78 @@ from magic_hour.core import (
8
9
  to_encodable,
9
10
  type_utils,
10
11
  )
12
+ from magic_hour.resources.v1.image_projects.client import (
13
+ AsyncImageProjectsClient,
14
+ ImageProjectsClient,
15
+ )
11
16
  from magic_hour.types import models, params
12
17
 
13
18
 
19
+ logging.basicConfig(level=logging.INFO)
20
+ logger = logging.getLogger(__name__)
21
+
22
+
14
23
  class AiQrCodeGeneratorClient:
15
24
  def __init__(self, *, base_client: SyncBaseClient):
16
25
  self._base_client = base_client
17
26
 
27
+ def generate(
28
+ self,
29
+ *,
30
+ content: str,
31
+ style: params.V1AiQrCodeGeneratorCreateBodyStyle,
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 QR code (alias for create with additional functionality).
42
+
43
+ Create an AI QR code. Each QR code 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
+ style: The art style to use for QR code generation
48
+ wait_for_completion: Whether to wait for the image project to complete
49
+ download_outputs: Whether to download the outputs
50
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
51
+ request_options: Additional options to customize the HTTP request
52
+
53
+ Returns:
54
+ V1ImageProjectsGetResponseWithDownloads: The response from the AI QR Code Generator API with the downloaded paths if `download_outputs` is True.
55
+
56
+ Examples:
57
+ ```py
58
+ response = client.v1.ai_qr_code_generator.generate(
59
+ content="https://magichour.ai",
60
+ style={"art_style": "Watercolor"},
61
+ name="Artistic QR Code",
62
+ wait_for_completion=True,
63
+ download_outputs=True,
64
+ download_directory="outputs/",
65
+ )
66
+ ```
67
+ """
68
+
69
+ create_response = self.create(
70
+ content=content, style=style, name=name, request_options=request_options
71
+ )
72
+ logger.info(f"AI QR Code Generator response: {create_response}")
73
+
74
+ image_projects_client = ImageProjectsClient(base_client=self._base_client)
75
+ response = image_projects_client.check_result(
76
+ id=create_response.id,
77
+ wait_for_completion=wait_for_completion,
78
+ download_outputs=download_outputs,
79
+ download_directory=download_directory,
80
+ )
81
+
82
+ return response
83
+
18
84
  def create(
19
85
  self,
20
86
  *,
@@ -72,6 +138,63 @@ class AsyncAiQrCodeGeneratorClient:
72
138
  def __init__(self, *, base_client: AsyncBaseClient):
73
139
  self._base_client = base_client
74
140
 
141
+ async def generate(
142
+ self,
143
+ *,
144
+ content: str,
145
+ style: params.V1AiQrCodeGeneratorCreateBodyStyle,
146
+ name: typing.Union[
147
+ typing.Optional[str], type_utils.NotGiven
148
+ ] = type_utils.NOT_GIVEN,
149
+ wait_for_completion: bool = True,
150
+ download_outputs: bool = True,
151
+ download_directory: typing.Optional[str] = None,
152
+ request_options: typing.Optional[RequestOptions] = None,
153
+ ):
154
+ """
155
+ Generate QR code (alias for create with additional functionality).
156
+
157
+ Create an AI QR code. Each QR code costs 5 credits.
158
+
159
+ Args:
160
+ name: The name of image. This value is mainly used for your own identification of the image.
161
+ style: The art style to use for QR code generation
162
+ wait_for_completion: Whether to wait for the image project to complete
163
+ download_outputs: Whether to download the outputs
164
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
165
+ request_options: Additional options to customize the HTTP request
166
+
167
+ Returns:
168
+ V1ImageProjectsGetResponseWithDownloads: The response from the AI QR Code Generator API with the downloaded paths if `download_outputs` is True.
169
+
170
+ Examples:
171
+ ```py
172
+ response = await client.v1.ai_qr_code_generator.generate(
173
+ content="https://magichour.ai",
174
+ style={"art_style": "Watercolor"},
175
+ name="Artistic QR Code",
176
+ wait_for_completion=True,
177
+ download_outputs=True,
178
+ download_directory="outputs/",
179
+ )
180
+ ```
181
+ """
182
+
183
+ create_response = await self.create(
184
+ content=content, style=style, name=name, request_options=request_options
185
+ )
186
+ logger.info(f"AI QR Code Generator response: {create_response}")
187
+
188
+ image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
189
+ response = await image_projects_client.check_result(
190
+ id=create_response.id,
191
+ wait_for_completion=wait_for_completion,
192
+ download_outputs=download_outputs,
193
+ download_directory=download_directory,
194
+ )
195
+
196
+ return response
197
+
75
198
  async def create(
76
199
  self,
77
200
  *,
@@ -1,3 +1,72 @@
1
+ # v1_ai_talking_photo
2
+
3
+ ## Module Functions
4
+
5
+ <!-- CUSTOM DOCS START -->
6
+
7
+ ### Ai Talking Photo 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_talking_photo.generate(
35
+ assets={
36
+ "audio_file_path": "/path/to/1234.mp3",
37
+ "image_file_path": "/path/to/1234.png",
38
+ },
39
+ end_seconds=15.0,
40
+ start_seconds=0.0,
41
+ name="Talking Photo image",
42
+ wait_for_completion=True,
43
+ download_outputs=True,
44
+ download_directory="outputs"
45
+ )
46
+ ```
47
+
48
+ #### Asynchronous Client
49
+
50
+ ```python
51
+ from magic_hour import AsyncClient
52
+ from os import getenv
53
+
54
+ client = AsyncClient(token=getenv("API_TOKEN"))
55
+ res = await client.v1.ai_talking_photo.generate(
56
+ assets={
57
+ "audio_file_path": "/path/to/1234.mp3",
58
+ "image_file_path": "/path/to/1234.png",
59
+ },
60
+ end_seconds=15.0,
61
+ start_seconds=0.0,
62
+ name="Talking Photo image",
63
+ wait_for_completion=True,
64
+ download_outputs=True,
65
+ download_directory="outputs"
66
+ )
67
+ ```
68
+
69
+ <!-- CUSTOM DOCS END -->
1
70
 
2
71
  ### AI Talking Photo <a name="create"></a>
3
72
 
@@ -10,10 +79,14 @@ Create a talking photo from an image and audio or text input.
10
79
  | Parameter | Required | Description | Example |
11
80
  |-----------|:--------:|-------------|--------|
12
81
  | `assets` | ✓ | Provide the assets for creating a talking photo | `{"audio_file_path": "api-assets/id/1234.mp3", "image_file_path": "api-assets/id/1234.png"}` |
82
+ | `└─ audio_file_path` | ✓ | The audio file to sync with the image. 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.mp3"` |
83
+ | `└─ image_file_path` | ✓ | The source image to animate. 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"` |
13
84
  | `end_seconds` | ✓ | The end time of the input audio in seconds. The maximum duration allowed is 60 seconds. | `15.0` |
14
85
  | `start_seconds` | ✓ | The start time of the input audio in seconds. The maximum duration allowed is 60 seconds. | `0.0` |
15
86
  | `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Talking Photo image"` |
16
87
  | `style` | ✗ | Attributes used to dictate the style of the output | `{"generation_mode": "expressive", "intensity": 1.5}` |
88
+ | `└─ generation_mode` | ✗ | Controls overall motion style. * `expressive` - More motion and facial expressiveness; may introduce visual artifacts. * `stable` - Reduced motion for cleaner output; may result in minimal animation. | `"expressive"` |
89
+ | `└─ intensity` | ✗ | Note: this value is only applicable when generation_mode is `expressive`. The value can include up to 2 decimal places. * Lower values yield more stability but can suppress mouth movement. * Higher values increase motion and expressiveness, with a higher risk of distortion. | `1.5` |
17
90
 
18
91
  #### Synchronous Client
19
92
 
@@ -60,3 +133,4 @@ res = await client.v1.ai_talking_photo.create(
60
133
 
61
134
  ##### Example
62
135
  `{"credits_charged": 450, "estimated_frame_cost": 450, "id": "cuid-example"}`
136
+