magic_hour 0.8.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 (131) hide show
  1. magic_hour/__init__.py +6 -0
  2. magic_hour/client.py +61 -0
  3. magic_hour/core/__init__.py +53 -0
  4. magic_hour/core/api_error.py +48 -0
  5. magic_hour/core/auth.py +314 -0
  6. magic_hour/core/base_client.py +600 -0
  7. magic_hour/core/binary_response.py +23 -0
  8. magic_hour/core/request.py +158 -0
  9. magic_hour/core/response.py +293 -0
  10. magic_hour/core/type_utils.py +28 -0
  11. magic_hour/core/utils.py +38 -0
  12. magic_hour/environment.py +6 -0
  13. magic_hour/resources/v1/__init__.py +4 -0
  14. magic_hour/resources/v1/ai_clothes_changer/README.md +41 -0
  15. magic_hour/resources/v1/ai_clothes_changer/__init__.py +4 -0
  16. magic_hour/resources/v1/ai_clothes_changer/client.py +129 -0
  17. magic_hour/resources/v1/ai_headshot_generator/README.md +31 -0
  18. magic_hour/resources/v1/ai_headshot_generator/__init__.py +4 -0
  19. magic_hour/resources/v1/ai_headshot_generator/client.py +119 -0
  20. magic_hour/resources/v1/ai_image_generator/README.md +37 -0
  21. magic_hour/resources/v1/ai_image_generator/__init__.py +4 -0
  22. magic_hour/resources/v1/ai_image_generator/client.py +144 -0
  23. magic_hour/resources/v1/ai_image_upscaler/README.md +37 -0
  24. magic_hour/resources/v1/ai_image_upscaler/__init__.py +4 -0
  25. magic_hour/resources/v1/ai_image_upscaler/client.py +143 -0
  26. magic_hour/resources/v1/ai_photo_editor/README.md +53 -0
  27. magic_hour/resources/v1/ai_photo_editor/__init__.py +4 -0
  28. magic_hour/resources/v1/ai_photo_editor/client.py +167 -0
  29. magic_hour/resources/v1/ai_qr_code_generator/README.md +35 -0
  30. magic_hour/resources/v1/ai_qr_code_generator/__init__.py +4 -0
  31. magic_hour/resources/v1/ai_qr_code_generator/client.py +127 -0
  32. magic_hour/resources/v1/animation/README.md +63 -0
  33. magic_hour/resources/v1/animation/__init__.py +4 -0
  34. magic_hour/resources/v1/animation/client.py +179 -0
  35. magic_hour/resources/v1/client.py +153 -0
  36. magic_hour/resources/v1/face_swap/README.md +52 -0
  37. magic_hour/resources/v1/face_swap/__init__.py +4 -0
  38. magic_hour/resources/v1/face_swap/client.py +165 -0
  39. magic_hour/resources/v1/face_swap_photo/README.md +39 -0
  40. magic_hour/resources/v1/face_swap_photo/__init__.py +4 -0
  41. magic_hour/resources/v1/face_swap_photo/client.py +127 -0
  42. magic_hour/resources/v1/files/__init__.py +4 -0
  43. magic_hour/resources/v1/files/client.py +19 -0
  44. magic_hour/resources/v1/files/upload_urls/README.md +56 -0
  45. magic_hour/resources/v1/files/upload_urls/__init__.py +4 -0
  46. magic_hour/resources/v1/files/upload_urls/client.py +142 -0
  47. magic_hour/resources/v1/image_background_remover/README.md +31 -0
  48. magic_hour/resources/v1/image_background_remover/__init__.py +4 -0
  49. magic_hour/resources/v1/image_background_remover/client.py +121 -0
  50. magic_hour/resources/v1/image_projects/README.md +63 -0
  51. magic_hour/resources/v1/image_projects/__init__.py +4 -0
  52. magic_hour/resources/v1/image_projects/client.py +177 -0
  53. magic_hour/resources/v1/image_to_video/README.md +44 -0
  54. magic_hour/resources/v1/image_to_video/__init__.py +4 -0
  55. magic_hour/resources/v1/image_to_video/client.py +165 -0
  56. magic_hour/resources/v1/lip_sync/README.md +54 -0
  57. magic_hour/resources/v1/lip_sync/__init__.py +4 -0
  58. magic_hour/resources/v1/lip_sync/client.py +177 -0
  59. magic_hour/resources/v1/text_to_video/README.md +40 -0
  60. magic_hour/resources/v1/text_to_video/__init__.py +4 -0
  61. magic_hour/resources/v1/text_to_video/client.py +150 -0
  62. magic_hour/resources/v1/video_projects/README.md +63 -0
  63. magic_hour/resources/v1/video_projects/__init__.py +4 -0
  64. magic_hour/resources/v1/video_projects/client.py +177 -0
  65. magic_hour/resources/v1/video_to_video/README.md +60 -0
  66. magic_hour/resources/v1/video_to_video/__init__.py +4 -0
  67. magic_hour/resources/v1/video_to_video/client.py +204 -0
  68. magic_hour/types/models/__init__.py +60 -0
  69. magic_hour/types/models/get_v1_image_projects_id_response.py +82 -0
  70. magic_hour/types/models/get_v1_image_projects_id_response_downloads_item.py +19 -0
  71. magic_hour/types/models/get_v1_image_projects_id_response_error.py +25 -0
  72. magic_hour/types/models/get_v1_video_projects_id_response.py +114 -0
  73. magic_hour/types/models/get_v1_video_projects_id_response_download.py +19 -0
  74. magic_hour/types/models/get_v1_video_projects_id_response_downloads_item.py +19 -0
  75. magic_hour/types/models/get_v1_video_projects_id_response_error.py +25 -0
  76. magic_hour/types/models/post_v1_ai_clothes_changer_response.py +25 -0
  77. magic_hour/types/models/post_v1_ai_headshot_generator_response.py +25 -0
  78. magic_hour/types/models/post_v1_ai_image_generator_response.py +25 -0
  79. magic_hour/types/models/post_v1_ai_image_upscaler_response.py +25 -0
  80. magic_hour/types/models/post_v1_ai_photo_editor_response.py +25 -0
  81. magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +25 -0
  82. magic_hour/types/models/post_v1_animation_response.py +25 -0
  83. magic_hour/types/models/post_v1_face_swap_photo_response.py +25 -0
  84. magic_hour/types/models/post_v1_face_swap_response.py +25 -0
  85. magic_hour/types/models/post_v1_files_upload_urls_response.py +21 -0
  86. magic_hour/types/models/post_v1_files_upload_urls_response_items_item.py +31 -0
  87. magic_hour/types/models/post_v1_image_background_remover_response.py +25 -0
  88. magic_hour/types/models/post_v1_image_to_video_response.py +25 -0
  89. magic_hour/types/models/post_v1_lip_sync_response.py +25 -0
  90. magic_hour/types/models/post_v1_text_to_video_response.py +25 -0
  91. magic_hour/types/models/post_v1_video_to_video_response.py +25 -0
  92. magic_hour/types/params/__init__.py +205 -0
  93. magic_hour/types/params/post_v1_ai_clothes_changer_body.py +40 -0
  94. magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +45 -0
  95. magic_hour/types/params/post_v1_ai_headshot_generator_body.py +40 -0
  96. magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +28 -0
  97. magic_hour/types/params/post_v1_ai_image_generator_body.py +54 -0
  98. magic_hour/types/params/post_v1_ai_image_generator_body_style.py +28 -0
  99. magic_hour/types/params/post_v1_ai_image_upscaler_body.py +54 -0
  100. magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +28 -0
  101. magic_hour/types/params/post_v1_ai_image_upscaler_body_style.py +36 -0
  102. magic_hour/types/params/post_v1_ai_photo_editor_body.py +63 -0
  103. magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +28 -0
  104. magic_hour/types/params/post_v1_ai_photo_editor_body_style.py +67 -0
  105. magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +45 -0
  106. magic_hour/types/params/post_v1_ai_qr_code_generator_body_style.py +28 -0
  107. magic_hour/types/params/post_v1_animation_body.py +84 -0
  108. magic_hour/types/params/post_v1_animation_body_assets.py +55 -0
  109. magic_hour/types/params/post_v1_animation_body_style.py +279 -0
  110. magic_hour/types/params/post_v1_face_swap_body.py +72 -0
  111. magic_hour/types/params/post_v1_face_swap_body_assets.py +52 -0
  112. magic_hour/types/params/post_v1_face_swap_photo_body.py +40 -0
  113. magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +36 -0
  114. magic_hour/types/params/post_v1_files_upload_urls_body.py +31 -0
  115. magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +38 -0
  116. magic_hour/types/params/post_v1_image_background_remover_body.py +40 -0
  117. magic_hour/types/params/post_v1_image_background_remover_body_assets.py +28 -0
  118. magic_hour/types/params/post_v1_image_to_video_body.py +73 -0
  119. magic_hour/types/params/post_v1_image_to_video_body_assets.py +28 -0
  120. magic_hour/types/params/post_v1_image_to_video_body_style.py +29 -0
  121. magic_hour/types/params/post_v1_lip_sync_body.py +80 -0
  122. magic_hour/types/params/post_v1_lip_sync_body_assets.py +52 -0
  123. magic_hour/types/params/post_v1_text_to_video_body.py +57 -0
  124. magic_hour/types/params/post_v1_text_to_video_body_style.py +28 -0
  125. magic_hour/types/params/post_v1_video_to_video_body.py +93 -0
  126. magic_hour/types/params/post_v1_video_to_video_body_assets.py +44 -0
  127. magic_hour/types/params/post_v1_video_to_video_body_style.py +199 -0
  128. magic_hour-0.8.0.dist-info/LICENSE +21 -0
  129. magic_hour-0.8.0.dist-info/METADATA +138 -0
  130. magic_hour-0.8.0.dist-info/RECORD +131 -0
  131. magic_hour-0.8.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,53 @@
1
+
2
+ ### create <a name="create"></a>
3
+ AI Photo Editor
4
+
5
+ > **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.
6
+
7
+ Edit photo using AI. Each photo costs 10 frames.
8
+
9
+ **API Endpoint**: `POST /v1/ai-photo-editor`
10
+
11
+ #### Synchronous Client
12
+
13
+ ```python
14
+ from magic_hour import Client
15
+ from os import getenv
16
+
17
+ client = Client(token=getenv("API_TOKEN"))
18
+ res = client.v1.ai_photo_editor.create(
19
+ assets={"image_file_path": "api-assets/id/1234.png"},
20
+ resolution=768,
21
+ style={
22
+ "image_description": "A photo of a person",
23
+ "likeness_strength": 5.2,
24
+ "negative_prompt": "painting, cartoon, sketch",
25
+ "prompt": "A photo portrait of a person wearing a hat",
26
+ "prompt_strength": 3.75,
27
+ "steps": 4,
28
+ },
29
+ name="Photo Editor image",
30
+ )
31
+ ```
32
+
33
+ #### Asynchronous Client
34
+
35
+ ```python
36
+ from magic_hour import AsyncClient
37
+ from os import getenv
38
+
39
+ client = AsyncClient(token=getenv("API_TOKEN"))
40
+ res = await client.v1.ai_photo_editor.create(
41
+ assets={"image_file_path": "api-assets/id/1234.png"},
42
+ resolution=768,
43
+ style={
44
+ "image_description": "A photo of a person",
45
+ "likeness_strength": 5.2,
46
+ "negative_prompt": "painting, cartoon, sketch",
47
+ "prompt": "A photo portrait of a person wearing a hat",
48
+ "prompt_strength": 3.75,
49
+ "steps": 4,
50
+ },
51
+ name="Photo Editor image",
52
+ )
53
+ ```
@@ -0,0 +1,4 @@
1
+ from .client import AiPhotoEditorClient, AsyncAiPhotoEditorClient
2
+
3
+
4
+ __all__ = ["AiPhotoEditorClient", "AsyncAiPhotoEditorClient"]
@@ -0,0 +1,167 @@
1
+ import typing
2
+
3
+ from magic_hour.core import (
4
+ AsyncBaseClient,
5
+ RequestOptions,
6
+ SyncBaseClient,
7
+ default_request_options,
8
+ to_encodable,
9
+ type_utils,
10
+ )
11
+ from magic_hour.types import models, params
12
+
13
+
14
+ class AiPhotoEditorClient:
15
+ def __init__(self, *, base_client: SyncBaseClient):
16
+ self._base_client = base_client
17
+
18
+ def create(
19
+ self,
20
+ *,
21
+ assets: params.PostV1AiPhotoEditorBodyAssets,
22
+ resolution: int,
23
+ style: params.PostV1AiPhotoEditorBodyStyle,
24
+ name: typing.Union[
25
+ typing.Optional[str], type_utils.NotGiven
26
+ ] = type_utils.NOT_GIVEN,
27
+ steps: typing.Union[
28
+ typing.Optional[int], type_utils.NotGiven
29
+ ] = type_utils.NOT_GIVEN,
30
+ request_options: typing.Optional[RequestOptions] = None,
31
+ ) -> models.PostV1AiPhotoEditorResponse:
32
+ """
33
+ AI Photo Editor
34
+
35
+ > **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
+
37
+ Edit photo using AI. Each photo costs 10 frames.
38
+
39
+ POST /v1/ai-photo-editor
40
+
41
+ Args:
42
+ name: The name of image
43
+ 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
+ assets: Provide the assets for photo editor
45
+ 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: PostV1AiPhotoEditorBodyStyle
47
+ request_options: Additional options to customize the HTTP request
48
+
49
+ Returns:
50
+ Success
51
+
52
+ Raises:
53
+ ApiError: A custom exception class that provides additional context
54
+ for API errors, including the HTTP status code and response body.
55
+
56
+ Examples:
57
+ ```py
58
+ client.v1.ai_photo_editor.create(
59
+ assets={"image_file_path": "api-assets/id/1234.png"},
60
+ resolution=768,
61
+ style={
62
+ "image_description": "A photo of a person",
63
+ "likeness_strength": 5.2,
64
+ "prompt": "A photo portrait of a person wearing a hat",
65
+ "prompt_strength": 3.75,
66
+ },
67
+ name="Photo Editor image",
68
+ )
69
+ ```
70
+
71
+ """
72
+ _json = to_encodable(
73
+ item={
74
+ "name": name,
75
+ "steps": steps,
76
+ "assets": assets,
77
+ "resolution": resolution,
78
+ "style": style,
79
+ },
80
+ dump_with=params._SerializerPostV1AiPhotoEditorBody,
81
+ )
82
+ return self._base_client.request(
83
+ method="POST",
84
+ path="/v1/ai-photo-editor",
85
+ auth_names=["bearerAuth"],
86
+ json=_json,
87
+ cast_to=models.PostV1AiPhotoEditorResponse,
88
+ request_options=request_options or default_request_options(),
89
+ )
90
+
91
+
92
+ class AsyncAiPhotoEditorClient:
93
+ def __init__(self, *, base_client: AsyncBaseClient):
94
+ self._base_client = base_client
95
+
96
+ async def create(
97
+ self,
98
+ *,
99
+ assets: params.PostV1AiPhotoEditorBodyAssets,
100
+ resolution: int,
101
+ style: params.PostV1AiPhotoEditorBodyStyle,
102
+ name: typing.Union[
103
+ typing.Optional[str], type_utils.NotGiven
104
+ ] = type_utils.NOT_GIVEN,
105
+ steps: typing.Union[
106
+ typing.Optional[int], type_utils.NotGiven
107
+ ] = type_utils.NOT_GIVEN,
108
+ request_options: typing.Optional[RequestOptions] = None,
109
+ ) -> models.PostV1AiPhotoEditorResponse:
110
+ """
111
+ AI Photo Editor
112
+
113
+ > **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.
114
+
115
+ Edit photo using AI. Each photo costs 10 frames.
116
+
117
+ POST /v1/ai-photo-editor
118
+
119
+ Args:
120
+ name: The name of image
121
+ 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.
122
+ assets: Provide the assets for photo editor
123
+ 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
124
+ style: PostV1AiPhotoEditorBodyStyle
125
+ request_options: Additional options to customize the HTTP request
126
+
127
+ Returns:
128
+ Success
129
+
130
+ Raises:
131
+ ApiError: A custom exception class that provides additional context
132
+ for API errors, including the HTTP status code and response body.
133
+
134
+ Examples:
135
+ ```py
136
+ await client.v1.ai_photo_editor.create(
137
+ assets={"image_file_path": "api-assets/id/1234.png"},
138
+ resolution=768,
139
+ style={
140
+ "image_description": "A photo of a person",
141
+ "likeness_strength": 5.2,
142
+ "prompt": "A photo portrait of a person wearing a hat",
143
+ "prompt_strength": 3.75,
144
+ },
145
+ name="Photo Editor image",
146
+ )
147
+ ```
148
+
149
+ """
150
+ _json = to_encodable(
151
+ item={
152
+ "name": name,
153
+ "steps": steps,
154
+ "assets": assets,
155
+ "resolution": resolution,
156
+ "style": style,
157
+ },
158
+ dump_with=params._SerializerPostV1AiPhotoEditorBody,
159
+ )
160
+ return await self._base_client.request(
161
+ method="POST",
162
+ path="/v1/ai-photo-editor",
163
+ auth_names=["bearerAuth"],
164
+ json=_json,
165
+ cast_to=models.PostV1AiPhotoEditorResponse,
166
+ request_options=request_options or default_request_options(),
167
+ )
@@ -0,0 +1,35 @@
1
+
2
+ ### create <a name="create"></a>
3
+ AI QR Code
4
+
5
+ Create an AI QR code. Each QR code costs 20 frames.
6
+
7
+ **API Endpoint**: `POST /v1/ai-qr-code-generator`
8
+
9
+ #### Synchronous Client
10
+
11
+ ```python
12
+ from magic_hour import Client
13
+ from os import getenv
14
+
15
+ client = Client(token=getenv("API_TOKEN"))
16
+ res = client.v1.ai_qr_code_generator.create(
17
+ content="https://magichour.ai",
18
+ style={"art_style": "Watercolor"},
19
+ name="Qr Code image",
20
+ )
21
+ ```
22
+
23
+ #### Asynchronous Client
24
+
25
+ ```python
26
+ from magic_hour import AsyncClient
27
+ from os import getenv
28
+
29
+ client = AsyncClient(token=getenv("API_TOKEN"))
30
+ res = await client.v1.ai_qr_code_generator.create(
31
+ content="https://magichour.ai",
32
+ style={"art_style": "Watercolor"},
33
+ name="Qr Code image",
34
+ )
35
+ ```
@@ -0,0 +1,4 @@
1
+ from .client import AiQrCodeGeneratorClient, AsyncAiQrCodeGeneratorClient
2
+
3
+
4
+ __all__ = ["AiQrCodeGeneratorClient", "AsyncAiQrCodeGeneratorClient"]
@@ -0,0 +1,127 @@
1
+ import typing
2
+
3
+ from magic_hour.core import (
4
+ AsyncBaseClient,
5
+ RequestOptions,
6
+ SyncBaseClient,
7
+ default_request_options,
8
+ to_encodable,
9
+ type_utils,
10
+ )
11
+ from magic_hour.types import models, params
12
+
13
+
14
+ class AiQrCodeGeneratorClient:
15
+ def __init__(self, *, base_client: SyncBaseClient):
16
+ self._base_client = base_client
17
+
18
+ def create(
19
+ self,
20
+ *,
21
+ content: str,
22
+ style: params.PostV1AiQrCodeGeneratorBodyStyle,
23
+ name: typing.Union[
24
+ typing.Optional[str], type_utils.NotGiven
25
+ ] = type_utils.NOT_GIVEN,
26
+ request_options: typing.Optional[RequestOptions] = None,
27
+ ) -> models.PostV1AiQrCodeGeneratorResponse:
28
+ """
29
+ AI QR Code
30
+
31
+ Create an AI QR code. Each QR code costs 20 frames.
32
+
33
+ POST /v1/ai-qr-code-generator
34
+
35
+ Args:
36
+ name: The name of image
37
+ content: The content of the QR code.
38
+ style: PostV1AiQrCodeGeneratorBodyStyle
39
+ request_options: Additional options to customize the HTTP request
40
+
41
+ Returns:
42
+ Success
43
+
44
+ Raises:
45
+ ApiError: A custom exception class that provides additional context
46
+ for API errors, including the HTTP status code and response body.
47
+
48
+ Examples:
49
+ ```py
50
+ client.v1.ai_qr_code_generator.create(
51
+ content="https://magichour.ai",
52
+ style={"art_style": "Watercolor"},
53
+ name="Qr Code image",
54
+ )
55
+ ```
56
+
57
+ """
58
+ _json = to_encodable(
59
+ item={"name": name, "content": content, "style": style},
60
+ dump_with=params._SerializerPostV1AiQrCodeGeneratorBody,
61
+ )
62
+ return self._base_client.request(
63
+ method="POST",
64
+ path="/v1/ai-qr-code-generator",
65
+ auth_names=["bearerAuth"],
66
+ json=_json,
67
+ cast_to=models.PostV1AiQrCodeGeneratorResponse,
68
+ request_options=request_options or default_request_options(),
69
+ )
70
+
71
+
72
+ class AsyncAiQrCodeGeneratorClient:
73
+ def __init__(self, *, base_client: AsyncBaseClient):
74
+ self._base_client = base_client
75
+
76
+ async def create(
77
+ self,
78
+ *,
79
+ content: str,
80
+ style: params.PostV1AiQrCodeGeneratorBodyStyle,
81
+ name: typing.Union[
82
+ typing.Optional[str], type_utils.NotGiven
83
+ ] = type_utils.NOT_GIVEN,
84
+ request_options: typing.Optional[RequestOptions] = None,
85
+ ) -> models.PostV1AiQrCodeGeneratorResponse:
86
+ """
87
+ AI QR Code
88
+
89
+ Create an AI QR code. Each QR code costs 20 frames.
90
+
91
+ POST /v1/ai-qr-code-generator
92
+
93
+ Args:
94
+ name: The name of image
95
+ content: The content of the QR code.
96
+ style: PostV1AiQrCodeGeneratorBodyStyle
97
+ request_options: Additional options to customize the HTTP request
98
+
99
+ Returns:
100
+ Success
101
+
102
+ Raises:
103
+ ApiError: A custom exception class that provides additional context
104
+ for API errors, including the HTTP status code and response body.
105
+
106
+ Examples:
107
+ ```py
108
+ await client.v1.ai_qr_code_generator.create(
109
+ content="https://magichour.ai",
110
+ style={"art_style": "Watercolor"},
111
+ name="Qr Code image",
112
+ )
113
+ ```
114
+
115
+ """
116
+ _json = to_encodable(
117
+ item={"name": name, "content": content, "style": style},
118
+ dump_with=params._SerializerPostV1AiQrCodeGeneratorBody,
119
+ )
120
+ return await self._base_client.request(
121
+ method="POST",
122
+ path="/v1/ai-qr-code-generator",
123
+ auth_names=["bearerAuth"],
124
+ json=_json,
125
+ cast_to=models.PostV1AiQrCodeGeneratorResponse,
126
+ request_options=request_options or default_request_options(),
127
+ )
@@ -0,0 +1,63 @@
1
+
2
+ ### create <a name="create"></a>
3
+ Animation
4
+
5
+ Create a Animation video. The estimated frame cost is calculated based on the `fps` and `end_seconds` input.
6
+
7
+ **API Endpoint**: `POST /v1/animation`
8
+
9
+ #### Synchronous Client
10
+
11
+ ```python
12
+ from magic_hour import Client
13
+ from os import getenv
14
+
15
+ client = Client(token=getenv("API_TOKEN"))
16
+ res = client.v1.animation.create(
17
+ assets={
18
+ "audio_file_path": "api-assets/id/1234.mp3",
19
+ "audio_source": "file",
20
+ "image_file_path": "api-assets/id/1234.png",
21
+ },
22
+ end_seconds=15,
23
+ fps=12,
24
+ height=960,
25
+ style={
26
+ "art_style": "Painterly Illustration",
27
+ "camera_effect": "Accelerate",
28
+ "prompt": "Cyberpunk city",
29
+ "prompt_type": "ai_choose",
30
+ "transition_speed": 5,
31
+ },
32
+ width=512,
33
+ name="Animation video",
34
+ )
35
+ ```
36
+
37
+ #### Asynchronous Client
38
+
39
+ ```python
40
+ from magic_hour import AsyncClient
41
+ from os import getenv
42
+
43
+ client = AsyncClient(token=getenv("API_TOKEN"))
44
+ res = await client.v1.animation.create(
45
+ assets={
46
+ "audio_file_path": "api-assets/id/1234.mp3",
47
+ "audio_source": "file",
48
+ "image_file_path": "api-assets/id/1234.png",
49
+ },
50
+ end_seconds=15,
51
+ fps=12,
52
+ height=960,
53
+ style={
54
+ "art_style": "Painterly Illustration",
55
+ "camera_effect": "Accelerate",
56
+ "prompt": "Cyberpunk city",
57
+ "prompt_type": "ai_choose",
58
+ "transition_speed": 5,
59
+ },
60
+ width=512,
61
+ name="Animation video",
62
+ )
63
+ ```
@@ -0,0 +1,4 @@
1
+ from .client import AnimationClient, AsyncAnimationClient
2
+
3
+
4
+ __all__ = ["AnimationClient", "AsyncAnimationClient"]
@@ -0,0 +1,179 @@
1
+ import typing
2
+
3
+ from magic_hour.core import (
4
+ AsyncBaseClient,
5
+ RequestOptions,
6
+ SyncBaseClient,
7
+ default_request_options,
8
+ to_encodable,
9
+ type_utils,
10
+ )
11
+ from magic_hour.types import models, params
12
+
13
+
14
+ class AnimationClient:
15
+ def __init__(self, *, base_client: SyncBaseClient):
16
+ self._base_client = base_client
17
+
18
+ def create(
19
+ self,
20
+ *,
21
+ assets: params.PostV1AnimationBodyAssets,
22
+ end_seconds: float,
23
+ fps: float,
24
+ height: int,
25
+ style: params.PostV1AnimationBodyStyle,
26
+ width: int,
27
+ name: typing.Union[
28
+ typing.Optional[str], type_utils.NotGiven
29
+ ] = type_utils.NOT_GIVEN,
30
+ request_options: typing.Optional[RequestOptions] = None,
31
+ ) -> models.PostV1AnimationResponse:
32
+ """
33
+ Animation
34
+
35
+ Create a Animation video. The estimated frame cost is calculated based on the `fps` and `end_seconds` input.
36
+
37
+ POST /v1/animation
38
+
39
+ Args:
40
+ name: The name of video
41
+ assets: Provide the assets for animation.
42
+ end_seconds: The end time of the input video in seconds
43
+ fps: The desire output video frame rate
44
+ height: The height of the final output video. The maximum height depends on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details
45
+ style: Defines the style of the output video
46
+ width: The width of the final output video. The maximum width depends on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details
47
+ request_options: Additional options to customize the HTTP request
48
+
49
+ Returns:
50
+ Success
51
+
52
+ Raises:
53
+ ApiError: A custom exception class that provides additional context
54
+ for API errors, including the HTTP status code and response body.
55
+
56
+ Examples:
57
+ ```py
58
+ client.v1.animation.create(
59
+ assets={"audio_source": "file"},
60
+ end_seconds=15,
61
+ fps=12,
62
+ height=960,
63
+ style={
64
+ "art_style": "Painterly Illustration",
65
+ "camera_effect": "Accelerate",
66
+ "prompt": "Cyberpunk city",
67
+ "prompt_type": "ai_choose",
68
+ "transition_speed": 5,
69
+ },
70
+ width=512,
71
+ name="Animation video",
72
+ )
73
+ ```
74
+
75
+ """
76
+ _json = to_encodable(
77
+ item={
78
+ "name": name,
79
+ "assets": assets,
80
+ "end_seconds": end_seconds,
81
+ "fps": fps,
82
+ "height": height,
83
+ "style": style,
84
+ "width": width,
85
+ },
86
+ dump_with=params._SerializerPostV1AnimationBody,
87
+ )
88
+ return self._base_client.request(
89
+ method="POST",
90
+ path="/v1/animation",
91
+ auth_names=["bearerAuth"],
92
+ json=_json,
93
+ cast_to=models.PostV1AnimationResponse,
94
+ request_options=request_options or default_request_options(),
95
+ )
96
+
97
+
98
+ class AsyncAnimationClient:
99
+ def __init__(self, *, base_client: AsyncBaseClient):
100
+ self._base_client = base_client
101
+
102
+ async def create(
103
+ self,
104
+ *,
105
+ assets: params.PostV1AnimationBodyAssets,
106
+ end_seconds: float,
107
+ fps: float,
108
+ height: int,
109
+ style: params.PostV1AnimationBodyStyle,
110
+ width: int,
111
+ name: typing.Union[
112
+ typing.Optional[str], type_utils.NotGiven
113
+ ] = type_utils.NOT_GIVEN,
114
+ request_options: typing.Optional[RequestOptions] = None,
115
+ ) -> models.PostV1AnimationResponse:
116
+ """
117
+ Animation
118
+
119
+ Create a Animation video. The estimated frame cost is calculated based on the `fps` and `end_seconds` input.
120
+
121
+ POST /v1/animation
122
+
123
+ Args:
124
+ name: The name of video
125
+ assets: Provide the assets for animation.
126
+ end_seconds: The end time of the input video in seconds
127
+ fps: The desire output video frame rate
128
+ height: The height of the final output video. The maximum height depends on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details
129
+ style: Defines the style of the output video
130
+ width: The width of the final output video. The maximum width depends on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details
131
+ request_options: Additional options to customize the HTTP request
132
+
133
+ Returns:
134
+ Success
135
+
136
+ Raises:
137
+ ApiError: A custom exception class that provides additional context
138
+ for API errors, including the HTTP status code and response body.
139
+
140
+ Examples:
141
+ ```py
142
+ await client.v1.animation.create(
143
+ assets={"audio_source": "file"},
144
+ end_seconds=15,
145
+ fps=12,
146
+ height=960,
147
+ style={
148
+ "art_style": "Painterly Illustration",
149
+ "camera_effect": "Accelerate",
150
+ "prompt": "Cyberpunk city",
151
+ "prompt_type": "ai_choose",
152
+ "transition_speed": 5,
153
+ },
154
+ width=512,
155
+ name="Animation video",
156
+ )
157
+ ```
158
+
159
+ """
160
+ _json = to_encodable(
161
+ item={
162
+ "name": name,
163
+ "assets": assets,
164
+ "end_seconds": end_seconds,
165
+ "fps": fps,
166
+ "height": height,
167
+ "style": style,
168
+ "width": width,
169
+ },
170
+ dump_with=params._SerializerPostV1AnimationBody,
171
+ )
172
+ return await self._base_client.request(
173
+ method="POST",
174
+ path="/v1/animation",
175
+ auth_names=["bearerAuth"],
176
+ json=_json,
177
+ cast_to=models.PostV1AnimationResponse,
178
+ request_options=request_options or default_request_options(),
179
+ )