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.
- magic_hour/__init__.py +6 -0
- magic_hour/client.py +61 -0
- magic_hour/core/__init__.py +53 -0
- magic_hour/core/api_error.py +48 -0
- magic_hour/core/auth.py +314 -0
- magic_hour/core/base_client.py +600 -0
- magic_hour/core/binary_response.py +23 -0
- magic_hour/core/request.py +158 -0
- magic_hour/core/response.py +293 -0
- magic_hour/core/type_utils.py +28 -0
- magic_hour/core/utils.py +38 -0
- magic_hour/environment.py +6 -0
- magic_hour/resources/v1/__init__.py +4 -0
- magic_hour/resources/v1/ai_clothes_changer/README.md +41 -0
- magic_hour/resources/v1/ai_clothes_changer/__init__.py +4 -0
- magic_hour/resources/v1/ai_clothes_changer/client.py +129 -0
- magic_hour/resources/v1/ai_headshot_generator/README.md +31 -0
- magic_hour/resources/v1/ai_headshot_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_headshot_generator/client.py +119 -0
- magic_hour/resources/v1/ai_image_generator/README.md +37 -0
- magic_hour/resources/v1/ai_image_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_image_generator/client.py +144 -0
- magic_hour/resources/v1/ai_image_upscaler/README.md +37 -0
- magic_hour/resources/v1/ai_image_upscaler/__init__.py +4 -0
- magic_hour/resources/v1/ai_image_upscaler/client.py +143 -0
- magic_hour/resources/v1/ai_photo_editor/README.md +53 -0
- magic_hour/resources/v1/ai_photo_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_photo_editor/client.py +167 -0
- magic_hour/resources/v1/ai_qr_code_generator/README.md +35 -0
- magic_hour/resources/v1/ai_qr_code_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_qr_code_generator/client.py +127 -0
- magic_hour/resources/v1/animation/README.md +63 -0
- magic_hour/resources/v1/animation/__init__.py +4 -0
- magic_hour/resources/v1/animation/client.py +179 -0
- magic_hour/resources/v1/client.py +153 -0
- magic_hour/resources/v1/face_swap/README.md +52 -0
- magic_hour/resources/v1/face_swap/__init__.py +4 -0
- magic_hour/resources/v1/face_swap/client.py +165 -0
- magic_hour/resources/v1/face_swap_photo/README.md +39 -0
- magic_hour/resources/v1/face_swap_photo/__init__.py +4 -0
- magic_hour/resources/v1/face_swap_photo/client.py +127 -0
- magic_hour/resources/v1/files/__init__.py +4 -0
- magic_hour/resources/v1/files/client.py +19 -0
- magic_hour/resources/v1/files/upload_urls/README.md +56 -0
- magic_hour/resources/v1/files/upload_urls/__init__.py +4 -0
- magic_hour/resources/v1/files/upload_urls/client.py +142 -0
- magic_hour/resources/v1/image_background_remover/README.md +31 -0
- magic_hour/resources/v1/image_background_remover/__init__.py +4 -0
- magic_hour/resources/v1/image_background_remover/client.py +121 -0
- magic_hour/resources/v1/image_projects/README.md +63 -0
- magic_hour/resources/v1/image_projects/__init__.py +4 -0
- magic_hour/resources/v1/image_projects/client.py +177 -0
- magic_hour/resources/v1/image_to_video/README.md +44 -0
- magic_hour/resources/v1/image_to_video/__init__.py +4 -0
- magic_hour/resources/v1/image_to_video/client.py +165 -0
- magic_hour/resources/v1/lip_sync/README.md +54 -0
- magic_hour/resources/v1/lip_sync/__init__.py +4 -0
- magic_hour/resources/v1/lip_sync/client.py +177 -0
- magic_hour/resources/v1/text_to_video/README.md +40 -0
- magic_hour/resources/v1/text_to_video/__init__.py +4 -0
- magic_hour/resources/v1/text_to_video/client.py +150 -0
- magic_hour/resources/v1/video_projects/README.md +63 -0
- magic_hour/resources/v1/video_projects/__init__.py +4 -0
- magic_hour/resources/v1/video_projects/client.py +177 -0
- magic_hour/resources/v1/video_to_video/README.md +60 -0
- magic_hour/resources/v1/video_to_video/__init__.py +4 -0
- magic_hour/resources/v1/video_to_video/client.py +204 -0
- magic_hour/types/models/__init__.py +60 -0
- magic_hour/types/models/get_v1_image_projects_id_response.py +82 -0
- magic_hour/types/models/get_v1_image_projects_id_response_downloads_item.py +19 -0
- magic_hour/types/models/get_v1_image_projects_id_response_error.py +25 -0
- magic_hour/types/models/get_v1_video_projects_id_response.py +114 -0
- magic_hour/types/models/get_v1_video_projects_id_response_download.py +19 -0
- magic_hour/types/models/get_v1_video_projects_id_response_downloads_item.py +19 -0
- magic_hour/types/models/get_v1_video_projects_id_response_error.py +25 -0
- magic_hour/types/models/post_v1_ai_clothes_changer_response.py +25 -0
- magic_hour/types/models/post_v1_ai_headshot_generator_response.py +25 -0
- magic_hour/types/models/post_v1_ai_image_generator_response.py +25 -0
- magic_hour/types/models/post_v1_ai_image_upscaler_response.py +25 -0
- magic_hour/types/models/post_v1_ai_photo_editor_response.py +25 -0
- magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +25 -0
- magic_hour/types/models/post_v1_animation_response.py +25 -0
- magic_hour/types/models/post_v1_face_swap_photo_response.py +25 -0
- magic_hour/types/models/post_v1_face_swap_response.py +25 -0
- magic_hour/types/models/post_v1_files_upload_urls_response.py +21 -0
- magic_hour/types/models/post_v1_files_upload_urls_response_items_item.py +31 -0
- magic_hour/types/models/post_v1_image_background_remover_response.py +25 -0
- magic_hour/types/models/post_v1_image_to_video_response.py +25 -0
- magic_hour/types/models/post_v1_lip_sync_response.py +25 -0
- magic_hour/types/models/post_v1_text_to_video_response.py +25 -0
- magic_hour/types/models/post_v1_video_to_video_response.py +25 -0
- magic_hour/types/params/__init__.py +205 -0
- magic_hour/types/params/post_v1_ai_clothes_changer_body.py +40 -0
- magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +45 -0
- magic_hour/types/params/post_v1_ai_headshot_generator_body.py +40 -0
- magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +28 -0
- magic_hour/types/params/post_v1_ai_image_generator_body.py +54 -0
- magic_hour/types/params/post_v1_ai_image_generator_body_style.py +28 -0
- magic_hour/types/params/post_v1_ai_image_upscaler_body.py +54 -0
- magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +28 -0
- magic_hour/types/params/post_v1_ai_image_upscaler_body_style.py +36 -0
- magic_hour/types/params/post_v1_ai_photo_editor_body.py +63 -0
- magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +28 -0
- magic_hour/types/params/post_v1_ai_photo_editor_body_style.py +67 -0
- magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +45 -0
- magic_hour/types/params/post_v1_ai_qr_code_generator_body_style.py +28 -0
- magic_hour/types/params/post_v1_animation_body.py +84 -0
- magic_hour/types/params/post_v1_animation_body_assets.py +55 -0
- magic_hour/types/params/post_v1_animation_body_style.py +279 -0
- magic_hour/types/params/post_v1_face_swap_body.py +72 -0
- magic_hour/types/params/post_v1_face_swap_body_assets.py +52 -0
- magic_hour/types/params/post_v1_face_swap_photo_body.py +40 -0
- magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +36 -0
- magic_hour/types/params/post_v1_files_upload_urls_body.py +31 -0
- magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +38 -0
- magic_hour/types/params/post_v1_image_background_remover_body.py +40 -0
- magic_hour/types/params/post_v1_image_background_remover_body_assets.py +28 -0
- magic_hour/types/params/post_v1_image_to_video_body.py +73 -0
- magic_hour/types/params/post_v1_image_to_video_body_assets.py +28 -0
- magic_hour/types/params/post_v1_image_to_video_body_style.py +29 -0
- magic_hour/types/params/post_v1_lip_sync_body.py +80 -0
- magic_hour/types/params/post_v1_lip_sync_body_assets.py +52 -0
- magic_hour/types/params/post_v1_text_to_video_body.py +57 -0
- magic_hour/types/params/post_v1_text_to_video_body_style.py +28 -0
- magic_hour/types/params/post_v1_video_to_video_body.py +93 -0
- magic_hour/types/params/post_v1_video_to_video_body_assets.py +44 -0
- magic_hour/types/params/post_v1_video_to_video_body_style.py +199 -0
- magic_hour-0.8.0.dist-info/LICENSE +21 -0
- magic_hour-0.8.0.dist-info/METADATA +138 -0
- magic_hour-0.8.0.dist-info/RECORD +131 -0
- magic_hour-0.8.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from magic_hour.core import (
|
|
4
|
+
AsyncBaseClient,
|
|
5
|
+
RequestOptions,
|
|
6
|
+
SyncBaseClient,
|
|
7
|
+
default_request_options,
|
|
8
|
+
to_encodable,
|
|
9
|
+
)
|
|
10
|
+
from magic_hour.types import models, params
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class UploadUrlsClient:
|
|
14
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
15
|
+
self._base_client = base_client
|
|
16
|
+
|
|
17
|
+
def create(
|
|
18
|
+
self,
|
|
19
|
+
*,
|
|
20
|
+
items: typing.List[params.PostV1FilesUploadUrlsBodyItemsItem],
|
|
21
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
22
|
+
) -> models.PostV1FilesUploadUrlsResponse:
|
|
23
|
+
"""
|
|
24
|
+
Generate asset upload urls
|
|
25
|
+
|
|
26
|
+
Create a list of urls used to upload the assets needed to generate a video. Each video type has their own requirements on what assets are required. Please refer to the specific mode API for more details. The response array will be in the same order as the request body.
|
|
27
|
+
|
|
28
|
+
Below is the list of valid extensions for each asset type:
|
|
29
|
+
|
|
30
|
+
- video: mp4, mov, webm
|
|
31
|
+
- audio: mp3, mpeg, wav, aac, aiff, flac
|
|
32
|
+
- image: png, jpg, jpeg, webp, avif, jp2, tiff, bmp
|
|
33
|
+
|
|
34
|
+
Note: `.gif` is supported for face swap API `video_file_path` field.
|
|
35
|
+
|
|
36
|
+
After receiving the upload url, you can upload the file by sending a PUT request with the header `'Content-Type: application/octet-stream'`.
|
|
37
|
+
|
|
38
|
+
For example using curl
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
curl -X PUT -H 'Content-Type: application/octet-stream' \
|
|
42
|
+
--data '@/path/to/file/video.mp4' \
|
|
43
|
+
https://videos.magichour.ai/api-assets/id/video.mp4?auth-value=1234567890
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
POST /v1/files/upload-urls
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
items: typing.List[PostV1FilesUploadUrlsBodyItemsItem]
|
|
51
|
+
request_options: Additional options to customize the HTTP request
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
Success
|
|
55
|
+
|
|
56
|
+
Raises:
|
|
57
|
+
ApiError: A custom exception class that provides additional context
|
|
58
|
+
for API errors, including the HTTP status code and response body.
|
|
59
|
+
|
|
60
|
+
Examples:
|
|
61
|
+
```py
|
|
62
|
+
client.v1.files.upload_urls.create(items=[{"extension": "mp4", "type_field": "video"}, {"extension": "mp3", "type_field": "audio"}])
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
"""
|
|
66
|
+
_json = to_encodable(
|
|
67
|
+
item={"items": items}, dump_with=params._SerializerPostV1FilesUploadUrlsBody
|
|
68
|
+
)
|
|
69
|
+
return self._base_client.request(
|
|
70
|
+
method="POST",
|
|
71
|
+
path="/v1/files/upload-urls",
|
|
72
|
+
auth_names=["bearerAuth"],
|
|
73
|
+
json=_json,
|
|
74
|
+
cast_to=models.PostV1FilesUploadUrlsResponse,
|
|
75
|
+
request_options=request_options or default_request_options(),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class AsyncUploadUrlsClient:
|
|
80
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
81
|
+
self._base_client = base_client
|
|
82
|
+
|
|
83
|
+
async def create(
|
|
84
|
+
self,
|
|
85
|
+
*,
|
|
86
|
+
items: typing.List[params.PostV1FilesUploadUrlsBodyItemsItem],
|
|
87
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
88
|
+
) -> models.PostV1FilesUploadUrlsResponse:
|
|
89
|
+
"""
|
|
90
|
+
Generate asset upload urls
|
|
91
|
+
|
|
92
|
+
Create a list of urls used to upload the assets needed to generate a video. Each video type has their own requirements on what assets are required. Please refer to the specific mode API for more details. The response array will be in the same order as the request body.
|
|
93
|
+
|
|
94
|
+
Below is the list of valid extensions for each asset type:
|
|
95
|
+
|
|
96
|
+
- video: mp4, mov, webm
|
|
97
|
+
- audio: mp3, mpeg, wav, aac, aiff, flac
|
|
98
|
+
- image: png, jpg, jpeg, webp, avif, jp2, tiff, bmp
|
|
99
|
+
|
|
100
|
+
Note: `.gif` is supported for face swap API `video_file_path` field.
|
|
101
|
+
|
|
102
|
+
After receiving the upload url, you can upload the file by sending a PUT request with the header `'Content-Type: application/octet-stream'`.
|
|
103
|
+
|
|
104
|
+
For example using curl
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
curl -X PUT -H 'Content-Type: application/octet-stream' \
|
|
108
|
+
--data '@/path/to/file/video.mp4' \
|
|
109
|
+
https://videos.magichour.ai/api-assets/id/video.mp4?auth-value=1234567890
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
POST /v1/files/upload-urls
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
items: typing.List[PostV1FilesUploadUrlsBodyItemsItem]
|
|
117
|
+
request_options: Additional options to customize the HTTP request
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
Success
|
|
121
|
+
|
|
122
|
+
Raises:
|
|
123
|
+
ApiError: A custom exception class that provides additional context
|
|
124
|
+
for API errors, including the HTTP status code and response body.
|
|
125
|
+
|
|
126
|
+
Examples:
|
|
127
|
+
```py
|
|
128
|
+
await client.v1.files.upload_urls.create(items=[{"extension": "mp4", "type_field": "video"}, {"extension": "mp3", "type_field": "audio"}])
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
"""
|
|
132
|
+
_json = to_encodable(
|
|
133
|
+
item={"items": items}, dump_with=params._SerializerPostV1FilesUploadUrlsBody
|
|
134
|
+
)
|
|
135
|
+
return await self._base_client.request(
|
|
136
|
+
method="POST",
|
|
137
|
+
path="/v1/files/upload-urls",
|
|
138
|
+
auth_names=["bearerAuth"],
|
|
139
|
+
json=_json,
|
|
140
|
+
cast_to=models.PostV1FilesUploadUrlsResponse,
|
|
141
|
+
request_options=request_options or default_request_options(),
|
|
142
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
### create <a name="create"></a>
|
|
3
|
+
Image Background Remover
|
|
4
|
+
|
|
5
|
+
Remove background from image. Each image costs 5 frames.
|
|
6
|
+
|
|
7
|
+
**API Endpoint**: `POST /v1/image-background-remover`
|
|
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.image_background_remover.create(
|
|
17
|
+
assets={"image_file_path": "image/id/1234.png"}, name="Background Remover image"
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### Asynchronous Client
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from magic_hour import AsyncClient
|
|
25
|
+
from os import getenv
|
|
26
|
+
|
|
27
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
28
|
+
res = await client.v1.image_background_remover.create(
|
|
29
|
+
assets={"image_file_path": "image/id/1234.png"}, name="Background Remover image"
|
|
30
|
+
)
|
|
31
|
+
```
|
|
@@ -0,0 +1,121 @@
|
|
|
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 ImageBackgroundRemoverClient:
|
|
15
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
16
|
+
self._base_client = base_client
|
|
17
|
+
|
|
18
|
+
def create(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
assets: params.PostV1ImageBackgroundRemoverBodyAssets,
|
|
22
|
+
name: typing.Union[
|
|
23
|
+
typing.Optional[str], type_utils.NotGiven
|
|
24
|
+
] = type_utils.NOT_GIVEN,
|
|
25
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
26
|
+
) -> models.PostV1ImageBackgroundRemoverResponse:
|
|
27
|
+
"""
|
|
28
|
+
Image Background Remover
|
|
29
|
+
|
|
30
|
+
Remove background from image. Each image costs 5 frames.
|
|
31
|
+
|
|
32
|
+
POST /v1/image-background-remover
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
name: The name of image
|
|
36
|
+
assets: Provide the assets for background removal
|
|
37
|
+
request_options: Additional options to customize the HTTP request
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Success
|
|
41
|
+
|
|
42
|
+
Raises:
|
|
43
|
+
ApiError: A custom exception class that provides additional context
|
|
44
|
+
for API errors, including the HTTP status code and response body.
|
|
45
|
+
|
|
46
|
+
Examples:
|
|
47
|
+
```py
|
|
48
|
+
client.v1.image_background_remover.create(
|
|
49
|
+
assets={"image_file_path": "image/id/1234.png"},
|
|
50
|
+
name="Background Remover image",
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
"""
|
|
55
|
+
_json = to_encodable(
|
|
56
|
+
item={"name": name, "assets": assets},
|
|
57
|
+
dump_with=params._SerializerPostV1ImageBackgroundRemoverBody,
|
|
58
|
+
)
|
|
59
|
+
return self._base_client.request(
|
|
60
|
+
method="POST",
|
|
61
|
+
path="/v1/image-background-remover",
|
|
62
|
+
auth_names=["bearerAuth"],
|
|
63
|
+
json=_json,
|
|
64
|
+
cast_to=models.PostV1ImageBackgroundRemoverResponse,
|
|
65
|
+
request_options=request_options or default_request_options(),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class AsyncImageBackgroundRemoverClient:
|
|
70
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
71
|
+
self._base_client = base_client
|
|
72
|
+
|
|
73
|
+
async def create(
|
|
74
|
+
self,
|
|
75
|
+
*,
|
|
76
|
+
assets: params.PostV1ImageBackgroundRemoverBodyAssets,
|
|
77
|
+
name: typing.Union[
|
|
78
|
+
typing.Optional[str], type_utils.NotGiven
|
|
79
|
+
] = type_utils.NOT_GIVEN,
|
|
80
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
81
|
+
) -> models.PostV1ImageBackgroundRemoverResponse:
|
|
82
|
+
"""
|
|
83
|
+
Image Background Remover
|
|
84
|
+
|
|
85
|
+
Remove background from image. Each image costs 5 frames.
|
|
86
|
+
|
|
87
|
+
POST /v1/image-background-remover
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
name: The name of image
|
|
91
|
+
assets: Provide the assets for background removal
|
|
92
|
+
request_options: Additional options to customize the HTTP request
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Success
|
|
96
|
+
|
|
97
|
+
Raises:
|
|
98
|
+
ApiError: A custom exception class that provides additional context
|
|
99
|
+
for API errors, including the HTTP status code and response body.
|
|
100
|
+
|
|
101
|
+
Examples:
|
|
102
|
+
```py
|
|
103
|
+
await client.v1.image_background_remover.create(
|
|
104
|
+
assets={"image_file_path": "image/id/1234.png"},
|
|
105
|
+
name="Background Remover image",
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
"""
|
|
110
|
+
_json = to_encodable(
|
|
111
|
+
item={"name": name, "assets": assets},
|
|
112
|
+
dump_with=params._SerializerPostV1ImageBackgroundRemoverBody,
|
|
113
|
+
)
|
|
114
|
+
return await self._base_client.request(
|
|
115
|
+
method="POST",
|
|
116
|
+
path="/v1/image-background-remover",
|
|
117
|
+
auth_names=["bearerAuth"],
|
|
118
|
+
json=_json,
|
|
119
|
+
cast_to=models.PostV1ImageBackgroundRemoverResponse,
|
|
120
|
+
request_options=request_options or default_request_options(),
|
|
121
|
+
)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
|
|
2
|
+
### delete <a name="delete"></a>
|
|
3
|
+
Delete image
|
|
4
|
+
|
|
5
|
+
Permanently delete the rendered image. This action is not reversible, please be sure before deleting.
|
|
6
|
+
|
|
7
|
+
**API Endpoint**: `DELETE /v1/image-projects/{id}`
|
|
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.image_projects.delete(id="string")
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
#### Asynchronous Client
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from magic_hour import AsyncClient
|
|
23
|
+
from os import getenv
|
|
24
|
+
|
|
25
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
26
|
+
res = await client.v1.image_projects.delete(id="string")
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### get <a name="get"></a>
|
|
30
|
+
Get image details
|
|
31
|
+
|
|
32
|
+
Get the details of a image project. The `download` field will be `null` unless the image was successfully rendered.
|
|
33
|
+
|
|
34
|
+
The image can be one of the following status
|
|
35
|
+
- `draft` - not currently used
|
|
36
|
+
- `queued` - the job is queued and waiting for a GPU
|
|
37
|
+
- `rendering` - the generation is in progress
|
|
38
|
+
- `complete` - the image is successful created
|
|
39
|
+
- `error` - an error occurred during rendering
|
|
40
|
+
- `canceled` - image render is canceled by the user
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
**API Endpoint**: `GET /v1/image-projects/{id}`
|
|
44
|
+
|
|
45
|
+
#### Synchronous Client
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from magic_hour import Client
|
|
49
|
+
from os import getenv
|
|
50
|
+
|
|
51
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
52
|
+
res = client.v1.image_projects.get(id="string")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Asynchronous Client
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from magic_hour import AsyncClient
|
|
59
|
+
from os import getenv
|
|
60
|
+
|
|
61
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
62
|
+
res = await client.v1.image_projects.get(id="string")
|
|
63
|
+
```
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from magic_hour.core import (
|
|
4
|
+
AsyncBaseClient,
|
|
5
|
+
RequestOptions,
|
|
6
|
+
SyncBaseClient,
|
|
7
|
+
default_request_options,
|
|
8
|
+
)
|
|
9
|
+
from magic_hour.types import models
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ImageProjectsClient:
|
|
13
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
14
|
+
self._base_client = base_client
|
|
15
|
+
|
|
16
|
+
def delete(
|
|
17
|
+
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
18
|
+
) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Delete image
|
|
21
|
+
|
|
22
|
+
Permanently delete the rendered image. This action is not reversible, please be sure before deleting.
|
|
23
|
+
|
|
24
|
+
DELETE /v1/image-projects/{id}
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
id: The id of the image project
|
|
28
|
+
request_options: Additional options to customize the HTTP request
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
204
|
|
32
|
+
|
|
33
|
+
Raises:
|
|
34
|
+
ApiError: A custom exception class that provides additional context
|
|
35
|
+
for API errors, including the HTTP status code and response body.
|
|
36
|
+
|
|
37
|
+
Examples:
|
|
38
|
+
```py
|
|
39
|
+
client.v1.image_projects.delete(id="string")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
"""
|
|
43
|
+
self._base_client.request(
|
|
44
|
+
method="DELETE",
|
|
45
|
+
path=f"/v1/image-projects/{id}",
|
|
46
|
+
auth_names=["bearerAuth"],
|
|
47
|
+
cast_to=type(None),
|
|
48
|
+
request_options=request_options or default_request_options(),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def get(
|
|
52
|
+
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
53
|
+
) -> models.GetV1ImageProjectsIdResponse:
|
|
54
|
+
"""
|
|
55
|
+
Get image details
|
|
56
|
+
|
|
57
|
+
Get the details of a image project. The `download` field will be `null` unless the image was successfully rendered.
|
|
58
|
+
|
|
59
|
+
The image can be one of the following status
|
|
60
|
+
- `draft` - not currently used
|
|
61
|
+
- `queued` - the job is queued and waiting for a GPU
|
|
62
|
+
- `rendering` - the generation is in progress
|
|
63
|
+
- `complete` - the image is successful created
|
|
64
|
+
- `error` - an error occurred during rendering
|
|
65
|
+
- `canceled` - image render is canceled by the user
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
GET /v1/image-projects/{id}
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
id: The id of the image project
|
|
72
|
+
request_options: Additional options to customize the HTTP request
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
Success
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
ApiError: A custom exception class that provides additional context
|
|
79
|
+
for API errors, including the HTTP status code and response body.
|
|
80
|
+
|
|
81
|
+
Examples:
|
|
82
|
+
```py
|
|
83
|
+
client.v1.image_projects.get(id="string")
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
"""
|
|
87
|
+
return self._base_client.request(
|
|
88
|
+
method="GET",
|
|
89
|
+
path=f"/v1/image-projects/{id}",
|
|
90
|
+
auth_names=["bearerAuth"],
|
|
91
|
+
cast_to=models.GetV1ImageProjectsIdResponse,
|
|
92
|
+
request_options=request_options or default_request_options(),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AsyncImageProjectsClient:
|
|
97
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
98
|
+
self._base_client = base_client
|
|
99
|
+
|
|
100
|
+
async def delete(
|
|
101
|
+
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
102
|
+
) -> None:
|
|
103
|
+
"""
|
|
104
|
+
Delete image
|
|
105
|
+
|
|
106
|
+
Permanently delete the rendered image. This action is not reversible, please be sure before deleting.
|
|
107
|
+
|
|
108
|
+
DELETE /v1/image-projects/{id}
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
id: The id of the image project
|
|
112
|
+
request_options: Additional options to customize the HTTP request
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
204
|
|
116
|
+
|
|
117
|
+
Raises:
|
|
118
|
+
ApiError: A custom exception class that provides additional context
|
|
119
|
+
for API errors, including the HTTP status code and response body.
|
|
120
|
+
|
|
121
|
+
Examples:
|
|
122
|
+
```py
|
|
123
|
+
await client.v1.image_projects.delete(id="string")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
"""
|
|
127
|
+
await self._base_client.request(
|
|
128
|
+
method="DELETE",
|
|
129
|
+
path=f"/v1/image-projects/{id}",
|
|
130
|
+
auth_names=["bearerAuth"],
|
|
131
|
+
cast_to=type(None),
|
|
132
|
+
request_options=request_options or default_request_options(),
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
async def get(
|
|
136
|
+
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
137
|
+
) -> models.GetV1ImageProjectsIdResponse:
|
|
138
|
+
"""
|
|
139
|
+
Get image details
|
|
140
|
+
|
|
141
|
+
Get the details of a image project. The `download` field will be `null` unless the image was successfully rendered.
|
|
142
|
+
|
|
143
|
+
The image can be one of the following status
|
|
144
|
+
- `draft` - not currently used
|
|
145
|
+
- `queued` - the job is queued and waiting for a GPU
|
|
146
|
+
- `rendering` - the generation is in progress
|
|
147
|
+
- `complete` - the image is successful created
|
|
148
|
+
- `error` - an error occurred during rendering
|
|
149
|
+
- `canceled` - image render is canceled by the user
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
GET /v1/image-projects/{id}
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
id: The id of the image project
|
|
156
|
+
request_options: Additional options to customize the HTTP request
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
Success
|
|
160
|
+
|
|
161
|
+
Raises:
|
|
162
|
+
ApiError: A custom exception class that provides additional context
|
|
163
|
+
for API errors, including the HTTP status code and response body.
|
|
164
|
+
|
|
165
|
+
Examples:
|
|
166
|
+
```py
|
|
167
|
+
await client.v1.image_projects.get(id="string")
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
"""
|
|
171
|
+
return await self._base_client.request(
|
|
172
|
+
method="GET",
|
|
173
|
+
path=f"/v1/image-projects/{id}",
|
|
174
|
+
auth_names=["bearerAuth"],
|
|
175
|
+
cast_to=models.GetV1ImageProjectsIdResponse,
|
|
176
|
+
request_options=request_options or default_request_options(),
|
|
177
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
### create <a name="create"></a>
|
|
3
|
+
Image-to-Video
|
|
4
|
+
|
|
5
|
+
Create a Image To Video video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
|
|
6
|
+
|
|
7
|
+
Get more information about this mode at our [product page](/products/image-to-video).
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
**API Endpoint**: `POST /v1/image-to-video`
|
|
11
|
+
|
|
12
|
+
#### Synchronous Client
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from magic_hour import Client
|
|
16
|
+
from os import getenv
|
|
17
|
+
|
|
18
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
19
|
+
res = client.v1.image_to_video.create(
|
|
20
|
+
assets={"image_file_path": "image/id/1234.png"},
|
|
21
|
+
end_seconds=5,
|
|
22
|
+
height=960,
|
|
23
|
+
style={"prompt": None},
|
|
24
|
+
width=512,
|
|
25
|
+
name="Image To Video video",
|
|
26
|
+
)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### Asynchronous Client
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from magic_hour import AsyncClient
|
|
33
|
+
from os import getenv
|
|
34
|
+
|
|
35
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
36
|
+
res = await client.v1.image_to_video.create(
|
|
37
|
+
assets={"image_file_path": "image/id/1234.png"},
|
|
38
|
+
end_seconds=5,
|
|
39
|
+
height=960,
|
|
40
|
+
style={"prompt": None},
|
|
41
|
+
width=512,
|
|
42
|
+
name="Image To Video video",
|
|
43
|
+
)
|
|
44
|
+
```
|