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,129 @@
|
|
|
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 AiClothesChangerClient:
|
|
15
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
16
|
+
self._base_client = base_client
|
|
17
|
+
|
|
18
|
+
def create(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
assets: params.PostV1AiClothesChangerBodyAssets,
|
|
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.PostV1AiClothesChangerResponse:
|
|
27
|
+
"""
|
|
28
|
+
AI Clothes Changer
|
|
29
|
+
|
|
30
|
+
Change outfits in photos in seconds with just a photo reference. Each photo costs 25 frames.
|
|
31
|
+
|
|
32
|
+
POST /v1/ai-clothes-changer
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
name: The name of image
|
|
36
|
+
assets: Provide the assets for clothes changer
|
|
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.ai_clothes_changer.create(
|
|
49
|
+
assets={
|
|
50
|
+
"garment_file_path": "api-assets/id/outfit.png",
|
|
51
|
+
"garment_type": "dresses",
|
|
52
|
+
"person_file_path": "api-assets/id/model.png",
|
|
53
|
+
},
|
|
54
|
+
name="Clothes Changer image",
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
"""
|
|
59
|
+
_json = to_encodable(
|
|
60
|
+
item={"name": name, "assets": assets},
|
|
61
|
+
dump_with=params._SerializerPostV1AiClothesChangerBody,
|
|
62
|
+
)
|
|
63
|
+
return self._base_client.request(
|
|
64
|
+
method="POST",
|
|
65
|
+
path="/v1/ai-clothes-changer",
|
|
66
|
+
auth_names=["bearerAuth"],
|
|
67
|
+
json=_json,
|
|
68
|
+
cast_to=models.PostV1AiClothesChangerResponse,
|
|
69
|
+
request_options=request_options or default_request_options(),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class AsyncAiClothesChangerClient:
|
|
74
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
75
|
+
self._base_client = base_client
|
|
76
|
+
|
|
77
|
+
async def create(
|
|
78
|
+
self,
|
|
79
|
+
*,
|
|
80
|
+
assets: params.PostV1AiClothesChangerBodyAssets,
|
|
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.PostV1AiClothesChangerResponse:
|
|
86
|
+
"""
|
|
87
|
+
AI Clothes Changer
|
|
88
|
+
|
|
89
|
+
Change outfits in photos in seconds with just a photo reference. Each photo costs 25 frames.
|
|
90
|
+
|
|
91
|
+
POST /v1/ai-clothes-changer
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
name: The name of image
|
|
95
|
+
assets: Provide the assets for clothes changer
|
|
96
|
+
request_options: Additional options to customize the HTTP request
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
Success
|
|
100
|
+
|
|
101
|
+
Raises:
|
|
102
|
+
ApiError: A custom exception class that provides additional context
|
|
103
|
+
for API errors, including the HTTP status code and response body.
|
|
104
|
+
|
|
105
|
+
Examples:
|
|
106
|
+
```py
|
|
107
|
+
await client.v1.ai_clothes_changer.create(
|
|
108
|
+
assets={
|
|
109
|
+
"garment_file_path": "api-assets/id/outfit.png",
|
|
110
|
+
"garment_type": "dresses",
|
|
111
|
+
"person_file_path": "api-assets/id/model.png",
|
|
112
|
+
},
|
|
113
|
+
name="Clothes Changer image",
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
"""
|
|
118
|
+
_json = to_encodable(
|
|
119
|
+
item={"name": name, "assets": assets},
|
|
120
|
+
dump_with=params._SerializerPostV1AiClothesChangerBody,
|
|
121
|
+
)
|
|
122
|
+
return await self._base_client.request(
|
|
123
|
+
method="POST",
|
|
124
|
+
path="/v1/ai-clothes-changer",
|
|
125
|
+
auth_names=["bearerAuth"],
|
|
126
|
+
json=_json,
|
|
127
|
+
cast_to=models.PostV1AiClothesChangerResponse,
|
|
128
|
+
request_options=request_options or default_request_options(),
|
|
129
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
### create <a name="create"></a>
|
|
3
|
+
AI Headshots
|
|
4
|
+
|
|
5
|
+
Create an AI headshot. Each headshot costs 50 frames.
|
|
6
|
+
|
|
7
|
+
**API Endpoint**: `POST /v1/ai-headshot-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_headshot_generator.create(
|
|
17
|
+
assets={"image_file_path": "image/id/1234.png"}, name="Ai Headshot 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.ai_headshot_generator.create(
|
|
29
|
+
assets={"image_file_path": "image/id/1234.png"}, name="Ai Headshot image"
|
|
30
|
+
)
|
|
31
|
+
```
|
|
@@ -0,0 +1,119 @@
|
|
|
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 AiHeadshotGeneratorClient:
|
|
15
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
16
|
+
self._base_client = base_client
|
|
17
|
+
|
|
18
|
+
def create(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
assets: params.PostV1AiHeadshotGeneratorBodyAssets,
|
|
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.PostV1AiHeadshotGeneratorResponse:
|
|
27
|
+
"""
|
|
28
|
+
AI Headshots
|
|
29
|
+
|
|
30
|
+
Create an AI headshot. Each headshot costs 50 frames.
|
|
31
|
+
|
|
32
|
+
POST /v1/ai-headshot-generator
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
name: The name of image
|
|
36
|
+
assets: Provide the assets for headshot photo
|
|
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.ai_headshot_generator.create(
|
|
49
|
+
assets={"image_file_path": "image/id/1234.png"}, name="Ai Headshot image"
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
"""
|
|
54
|
+
_json = to_encodable(
|
|
55
|
+
item={"name": name, "assets": assets},
|
|
56
|
+
dump_with=params._SerializerPostV1AiHeadshotGeneratorBody,
|
|
57
|
+
)
|
|
58
|
+
return self._base_client.request(
|
|
59
|
+
method="POST",
|
|
60
|
+
path="/v1/ai-headshot-generator",
|
|
61
|
+
auth_names=["bearerAuth"],
|
|
62
|
+
json=_json,
|
|
63
|
+
cast_to=models.PostV1AiHeadshotGeneratorResponse,
|
|
64
|
+
request_options=request_options or default_request_options(),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class AsyncAiHeadshotGeneratorClient:
|
|
69
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
70
|
+
self._base_client = base_client
|
|
71
|
+
|
|
72
|
+
async def create(
|
|
73
|
+
self,
|
|
74
|
+
*,
|
|
75
|
+
assets: params.PostV1AiHeadshotGeneratorBodyAssets,
|
|
76
|
+
name: typing.Union[
|
|
77
|
+
typing.Optional[str], type_utils.NotGiven
|
|
78
|
+
] = type_utils.NOT_GIVEN,
|
|
79
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
80
|
+
) -> models.PostV1AiHeadshotGeneratorResponse:
|
|
81
|
+
"""
|
|
82
|
+
AI Headshots
|
|
83
|
+
|
|
84
|
+
Create an AI headshot. Each headshot costs 50 frames.
|
|
85
|
+
|
|
86
|
+
POST /v1/ai-headshot-generator
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
name: The name of image
|
|
90
|
+
assets: Provide the assets for headshot photo
|
|
91
|
+
request_options: Additional options to customize the HTTP request
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
Success
|
|
95
|
+
|
|
96
|
+
Raises:
|
|
97
|
+
ApiError: A custom exception class that provides additional context
|
|
98
|
+
for API errors, including the HTTP status code and response body.
|
|
99
|
+
|
|
100
|
+
Examples:
|
|
101
|
+
```py
|
|
102
|
+
await client.v1.ai_headshot_generator.create(
|
|
103
|
+
assets={"image_file_path": "image/id/1234.png"}, name="Ai Headshot image"
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
"""
|
|
108
|
+
_json = to_encodable(
|
|
109
|
+
item={"name": name, "assets": assets},
|
|
110
|
+
dump_with=params._SerializerPostV1AiHeadshotGeneratorBody,
|
|
111
|
+
)
|
|
112
|
+
return await self._base_client.request(
|
|
113
|
+
method="POST",
|
|
114
|
+
path="/v1/ai-headshot-generator",
|
|
115
|
+
auth_names=["bearerAuth"],
|
|
116
|
+
json=_json,
|
|
117
|
+
cast_to=models.PostV1AiHeadshotGeneratorResponse,
|
|
118
|
+
request_options=request_options or default_request_options(),
|
|
119
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
### create <a name="create"></a>
|
|
3
|
+
AI Images
|
|
4
|
+
|
|
5
|
+
Create an AI image. Each image costs 5 frames.
|
|
6
|
+
|
|
7
|
+
**API Endpoint**: `POST /v1/ai-image-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_image_generator.create(
|
|
17
|
+
image_count=1,
|
|
18
|
+
orientation="landscape",
|
|
19
|
+
style={"prompt": "Cool image"},
|
|
20
|
+
name="Ai Image image",
|
|
21
|
+
)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Asynchronous Client
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from magic_hour import AsyncClient
|
|
28
|
+
from os import getenv
|
|
29
|
+
|
|
30
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
31
|
+
res = await client.v1.ai_image_generator.create(
|
|
32
|
+
image_count=1,
|
|
33
|
+
orientation="landscape",
|
|
34
|
+
style={"prompt": "Cool image"},
|
|
35
|
+
name="Ai Image image",
|
|
36
|
+
)
|
|
37
|
+
```
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import typing_extensions
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from magic_hour.core import (
|
|
5
|
+
AsyncBaseClient,
|
|
6
|
+
RequestOptions,
|
|
7
|
+
SyncBaseClient,
|
|
8
|
+
default_request_options,
|
|
9
|
+
to_encodable,
|
|
10
|
+
type_utils,
|
|
11
|
+
)
|
|
12
|
+
from magic_hour.types import models, params
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AiImageGeneratorClient:
|
|
16
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
17
|
+
self._base_client = base_client
|
|
18
|
+
|
|
19
|
+
def create(
|
|
20
|
+
self,
|
|
21
|
+
*,
|
|
22
|
+
image_count: int,
|
|
23
|
+
orientation: typing_extensions.Literal["landscape", "portrait", "square"],
|
|
24
|
+
style: params.PostV1AiImageGeneratorBodyStyle,
|
|
25
|
+
name: typing.Union[
|
|
26
|
+
typing.Optional[str], type_utils.NotGiven
|
|
27
|
+
] = type_utils.NOT_GIVEN,
|
|
28
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
29
|
+
) -> models.PostV1AiImageGeneratorResponse:
|
|
30
|
+
"""
|
|
31
|
+
AI Images
|
|
32
|
+
|
|
33
|
+
Create an AI image. Each image costs 5 frames.
|
|
34
|
+
|
|
35
|
+
POST /v1/ai-image-generator
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
name: The name of image
|
|
39
|
+
image_count: number to images to generate
|
|
40
|
+
orientation: typing_extensions.Literal["landscape", "portrait", "square"]
|
|
41
|
+
style: PostV1AiImageGeneratorBodyStyle
|
|
42
|
+
request_options: Additional options to customize the HTTP request
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Success
|
|
46
|
+
|
|
47
|
+
Raises:
|
|
48
|
+
ApiError: A custom exception class that provides additional context
|
|
49
|
+
for API errors, including the HTTP status code and response body.
|
|
50
|
+
|
|
51
|
+
Examples:
|
|
52
|
+
```py
|
|
53
|
+
client.v1.ai_image_generator.create(
|
|
54
|
+
image_count=1,
|
|
55
|
+
orientation="landscape",
|
|
56
|
+
style={"prompt": "Cool image"},
|
|
57
|
+
name="Ai Image image",
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
"""
|
|
62
|
+
_json = to_encodable(
|
|
63
|
+
item={
|
|
64
|
+
"name": name,
|
|
65
|
+
"image_count": image_count,
|
|
66
|
+
"orientation": orientation,
|
|
67
|
+
"style": style,
|
|
68
|
+
},
|
|
69
|
+
dump_with=params._SerializerPostV1AiImageGeneratorBody,
|
|
70
|
+
)
|
|
71
|
+
return self._base_client.request(
|
|
72
|
+
method="POST",
|
|
73
|
+
path="/v1/ai-image-generator",
|
|
74
|
+
auth_names=["bearerAuth"],
|
|
75
|
+
json=_json,
|
|
76
|
+
cast_to=models.PostV1AiImageGeneratorResponse,
|
|
77
|
+
request_options=request_options or default_request_options(),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class AsyncAiImageGeneratorClient:
|
|
82
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
83
|
+
self._base_client = base_client
|
|
84
|
+
|
|
85
|
+
async def create(
|
|
86
|
+
self,
|
|
87
|
+
*,
|
|
88
|
+
image_count: int,
|
|
89
|
+
orientation: typing_extensions.Literal["landscape", "portrait", "square"],
|
|
90
|
+
style: params.PostV1AiImageGeneratorBodyStyle,
|
|
91
|
+
name: typing.Union[
|
|
92
|
+
typing.Optional[str], type_utils.NotGiven
|
|
93
|
+
] = type_utils.NOT_GIVEN,
|
|
94
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
95
|
+
) -> models.PostV1AiImageGeneratorResponse:
|
|
96
|
+
"""
|
|
97
|
+
AI Images
|
|
98
|
+
|
|
99
|
+
Create an AI image. Each image costs 5 frames.
|
|
100
|
+
|
|
101
|
+
POST /v1/ai-image-generator
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
name: The name of image
|
|
105
|
+
image_count: number to images to generate
|
|
106
|
+
orientation: typing_extensions.Literal["landscape", "portrait", "square"]
|
|
107
|
+
style: PostV1AiImageGeneratorBodyStyle
|
|
108
|
+
request_options: Additional options to customize the HTTP request
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
Success
|
|
112
|
+
|
|
113
|
+
Raises:
|
|
114
|
+
ApiError: A custom exception class that provides additional context
|
|
115
|
+
for API errors, including the HTTP status code and response body.
|
|
116
|
+
|
|
117
|
+
Examples:
|
|
118
|
+
```py
|
|
119
|
+
await client.v1.ai_image_generator.create(
|
|
120
|
+
image_count=1,
|
|
121
|
+
orientation="landscape",
|
|
122
|
+
style={"prompt": "Cool image"},
|
|
123
|
+
name="Ai Image image",
|
|
124
|
+
)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
"""
|
|
128
|
+
_json = to_encodable(
|
|
129
|
+
item={
|
|
130
|
+
"name": name,
|
|
131
|
+
"image_count": image_count,
|
|
132
|
+
"orientation": orientation,
|
|
133
|
+
"style": style,
|
|
134
|
+
},
|
|
135
|
+
dump_with=params._SerializerPostV1AiImageGeneratorBody,
|
|
136
|
+
)
|
|
137
|
+
return await self._base_client.request(
|
|
138
|
+
method="POST",
|
|
139
|
+
path="/v1/ai-image-generator",
|
|
140
|
+
auth_names=["bearerAuth"],
|
|
141
|
+
json=_json,
|
|
142
|
+
cast_to=models.PostV1AiImageGeneratorResponse,
|
|
143
|
+
request_options=request_options or default_request_options(),
|
|
144
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
### create <a name="create"></a>
|
|
3
|
+
AI Image Upscaler
|
|
4
|
+
|
|
5
|
+
Upscale your image using AI. Each 2x upscale costs 50 frames, and 4x upscale costs 200 frames.
|
|
6
|
+
|
|
7
|
+
**API Endpoint**: `POST /v1/ai-image-upscaler`
|
|
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_image_upscaler.create(
|
|
17
|
+
assets={"image_file_path": "image/id/1234.png"},
|
|
18
|
+
scale_factor=123.45,
|
|
19
|
+
style={"enhancement": "Balanced"},
|
|
20
|
+
name="Image Upscaler image",
|
|
21
|
+
)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Asynchronous Client
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from magic_hour import AsyncClient
|
|
28
|
+
from os import getenv
|
|
29
|
+
|
|
30
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
31
|
+
res = await client.v1.ai_image_upscaler.create(
|
|
32
|
+
assets={"image_file_path": "image/id/1234.png"},
|
|
33
|
+
scale_factor=123.45,
|
|
34
|
+
style={"enhancement": "Balanced"},
|
|
35
|
+
name="Image Upscaler image",
|
|
36
|
+
)
|
|
37
|
+
```
|
|
@@ -0,0 +1,143 @@
|
|
|
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 AiImageUpscalerClient:
|
|
15
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
16
|
+
self._base_client = base_client
|
|
17
|
+
|
|
18
|
+
def create(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
assets: params.PostV1AiImageUpscalerBodyAssets,
|
|
22
|
+
scale_factor: float,
|
|
23
|
+
style: params.PostV1AiImageUpscalerBodyStyle,
|
|
24
|
+
name: typing.Union[
|
|
25
|
+
typing.Optional[str], type_utils.NotGiven
|
|
26
|
+
] = type_utils.NOT_GIVEN,
|
|
27
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
28
|
+
) -> models.PostV1AiImageUpscalerResponse:
|
|
29
|
+
"""
|
|
30
|
+
AI Image Upscaler
|
|
31
|
+
|
|
32
|
+
Upscale your image using AI. Each 2x upscale costs 50 frames, and 4x upscale costs 200 frames.
|
|
33
|
+
|
|
34
|
+
POST /v1/ai-image-upscaler
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
name: The name of image
|
|
38
|
+
assets: Provide the assets for upscaling
|
|
39
|
+
scale_factor: float
|
|
40
|
+
style: PostV1AiImageUpscalerBodyStyle
|
|
41
|
+
request_options: Additional options to customize the HTTP request
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
Success
|
|
45
|
+
|
|
46
|
+
Raises:
|
|
47
|
+
ApiError: A custom exception class that provides additional context
|
|
48
|
+
for API errors, including the HTTP status code and response body.
|
|
49
|
+
|
|
50
|
+
Examples:
|
|
51
|
+
```py
|
|
52
|
+
client.v1.ai_image_upscaler.create(
|
|
53
|
+
assets={"image_file_path": "image/id/1234.png"},
|
|
54
|
+
scale_factor=123.0,
|
|
55
|
+
style={"enhancement": "Balanced"},
|
|
56
|
+
name="Image Upscaler image",
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
_json = to_encodable(
|
|
62
|
+
item={
|
|
63
|
+
"name": name,
|
|
64
|
+
"assets": assets,
|
|
65
|
+
"scale_factor": scale_factor,
|
|
66
|
+
"style": style,
|
|
67
|
+
},
|
|
68
|
+
dump_with=params._SerializerPostV1AiImageUpscalerBody,
|
|
69
|
+
)
|
|
70
|
+
return self._base_client.request(
|
|
71
|
+
method="POST",
|
|
72
|
+
path="/v1/ai-image-upscaler",
|
|
73
|
+
auth_names=["bearerAuth"],
|
|
74
|
+
json=_json,
|
|
75
|
+
cast_to=models.PostV1AiImageUpscalerResponse,
|
|
76
|
+
request_options=request_options or default_request_options(),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class AsyncAiImageUpscalerClient:
|
|
81
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
82
|
+
self._base_client = base_client
|
|
83
|
+
|
|
84
|
+
async def create(
|
|
85
|
+
self,
|
|
86
|
+
*,
|
|
87
|
+
assets: params.PostV1AiImageUpscalerBodyAssets,
|
|
88
|
+
scale_factor: float,
|
|
89
|
+
style: params.PostV1AiImageUpscalerBodyStyle,
|
|
90
|
+
name: typing.Union[
|
|
91
|
+
typing.Optional[str], type_utils.NotGiven
|
|
92
|
+
] = type_utils.NOT_GIVEN,
|
|
93
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
94
|
+
) -> models.PostV1AiImageUpscalerResponse:
|
|
95
|
+
"""
|
|
96
|
+
AI Image Upscaler
|
|
97
|
+
|
|
98
|
+
Upscale your image using AI. Each 2x upscale costs 50 frames, and 4x upscale costs 200 frames.
|
|
99
|
+
|
|
100
|
+
POST /v1/ai-image-upscaler
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
name: The name of image
|
|
104
|
+
assets: Provide the assets for upscaling
|
|
105
|
+
scale_factor: float
|
|
106
|
+
style: PostV1AiImageUpscalerBodyStyle
|
|
107
|
+
request_options: Additional options to customize the HTTP request
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
Success
|
|
111
|
+
|
|
112
|
+
Raises:
|
|
113
|
+
ApiError: A custom exception class that provides additional context
|
|
114
|
+
for API errors, including the HTTP status code and response body.
|
|
115
|
+
|
|
116
|
+
Examples:
|
|
117
|
+
```py
|
|
118
|
+
await client.v1.ai_image_upscaler.create(
|
|
119
|
+
assets={"image_file_path": "image/id/1234.png"},
|
|
120
|
+
scale_factor=123.0,
|
|
121
|
+
style={"enhancement": "Balanced"},
|
|
122
|
+
name="Image Upscaler image",
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
"""
|
|
127
|
+
_json = to_encodable(
|
|
128
|
+
item={
|
|
129
|
+
"name": name,
|
|
130
|
+
"assets": assets,
|
|
131
|
+
"scale_factor": scale_factor,
|
|
132
|
+
"style": style,
|
|
133
|
+
},
|
|
134
|
+
dump_with=params._SerializerPostV1AiImageUpscalerBody,
|
|
135
|
+
)
|
|
136
|
+
return await self._base_client.request(
|
|
137
|
+
method="POST",
|
|
138
|
+
path="/v1/ai-image-upscaler",
|
|
139
|
+
auth_names=["bearerAuth"],
|
|
140
|
+
json=_json,
|
|
141
|
+
cast_to=models.PostV1AiImageUpscalerResponse,
|
|
142
|
+
request_options=request_options or default_request_options(),
|
|
143
|
+
)
|