magic_hour 0.23.0__py3-none-any.whl → 0.25.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/client.py +2 -2
- magic_hour/core/__init__.py +6 -10
- magic_hour/core/auth.py +136 -96
- magic_hour/core/query.py +5 -6
- magic_hour/environment.py +1 -1
- magic_hour/resources/v1/ai_clothes_changer/README.md +17 -0
- magic_hour/resources/v1/ai_face_editor/README.md +18 -0
- magic_hour/resources/v1/ai_gif_generator/README.md +17 -0
- magic_hour/resources/v1/ai_headshot_generator/README.md +18 -0
- magic_hour/resources/v1/ai_image_editor/README.md +52 -0
- magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_image_editor/client.py +125 -0
- magic_hour/resources/v1/ai_image_generator/README.md +21 -2
- magic_hour/resources/v1/ai_image_generator/client.py +2 -2
- magic_hour/resources/v1/ai_image_upscaler/README.md +19 -0
- magic_hour/resources/v1/ai_meme_generator/README.md +17 -0
- magic_hour/resources/v1/ai_photo_editor/README.md +20 -0
- magic_hour/resources/v1/ai_qr_code_generator/README.md +18 -0
- magic_hour/resources/v1/ai_talking_photo/README.md +20 -0
- magic_hour/resources/v1/animation/README.md +22 -0
- magic_hour/resources/v1/client.py +6 -0
- magic_hour/resources/v1/face_swap/README.md +21 -0
- magic_hour/resources/v1/face_swap_photo/README.md +17 -0
- magic_hour/resources/v1/files/upload_urls/README.md +19 -4
- magic_hour/resources/v1/files/upload_urls/client.py +6 -8
- magic_hour/resources/v1/image_background_remover/README.md +17 -0
- magic_hour/resources/v1/image_projects/README.md +24 -0
- magic_hour/resources/v1/image_to_video/README.md +21 -0
- magic_hour/resources/v1/lip_sync/README.md +22 -0
- magic_hour/resources/v1/photo_colorizer/README.md +17 -0
- magic_hour/resources/v1/text_to_video/README.md +19 -0
- magic_hour/resources/v1/video_projects/README.md +24 -0
- magic_hour/resources/v1/video_to_video/README.md +23 -0
- magic_hour/types/models/__init__.py +2 -0
- magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
- magic_hour/types/models/v1_image_projects_get_response.py +1 -1
- magic_hour/types/params/__init__.py +18 -0
- magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +28 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_style.py +28 -0
- magic_hour/types/params/v1_ai_image_generator_create_body_style.py +83 -0
- {magic_hour-0.23.0.dist-info → magic_hour-0.25.0.dist-info}/METADATA +5 -1
- {magic_hour-0.23.0.dist-info → magic_hour-0.25.0.dist-info}/RECORD +45 -38
- {magic_hour-0.23.0.dist-info → magic_hour-0.25.0.dist-info}/LICENSE +0 -0
- {magic_hour-0.23.0.dist-info → magic_hour-0.25.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
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 AiImageEditorClient:
|
|
15
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
16
|
+
self._base_client = base_client
|
|
17
|
+
|
|
18
|
+
def create(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
assets: params.V1AiImageEditorCreateBodyAssets,
|
|
22
|
+
style: params.V1AiImageEditorCreateBodyStyle,
|
|
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.V1AiImageEditorCreateResponse:
|
|
28
|
+
"""
|
|
29
|
+
AI Image Editor
|
|
30
|
+
|
|
31
|
+
Edit images with AI. Each edit costs 50 credits.
|
|
32
|
+
|
|
33
|
+
POST /v1/ai-image-editor
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
name: The name of image
|
|
37
|
+
assets: Provide the assets for image edit
|
|
38
|
+
style: V1AiImageEditorCreateBodyStyle
|
|
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_image_editor.create(
|
|
51
|
+
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
52
|
+
style={"prompt": "Give me sunglasses"},
|
|
53
|
+
name="Ai Image Editor image",
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
"""
|
|
57
|
+
_json = to_encodable(
|
|
58
|
+
item={"name": name, "assets": assets, "style": style},
|
|
59
|
+
dump_with=params._SerializerV1AiImageEditorCreateBody,
|
|
60
|
+
)
|
|
61
|
+
return self._base_client.request(
|
|
62
|
+
method="POST",
|
|
63
|
+
path="/v1/ai-image-editor",
|
|
64
|
+
auth_names=["bearerAuth"],
|
|
65
|
+
json=_json,
|
|
66
|
+
cast_to=models.V1AiImageEditorCreateResponse,
|
|
67
|
+
request_options=request_options or default_request_options(),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class AsyncAiImageEditorClient:
|
|
72
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
73
|
+
self._base_client = base_client
|
|
74
|
+
|
|
75
|
+
async def create(
|
|
76
|
+
self,
|
|
77
|
+
*,
|
|
78
|
+
assets: params.V1AiImageEditorCreateBodyAssets,
|
|
79
|
+
style: params.V1AiImageEditorCreateBodyStyle,
|
|
80
|
+
name: typing.Union[
|
|
81
|
+
typing.Optional[str], type_utils.NotGiven
|
|
82
|
+
] = type_utils.NOT_GIVEN,
|
|
83
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
84
|
+
) -> models.V1AiImageEditorCreateResponse:
|
|
85
|
+
"""
|
|
86
|
+
AI Image Editor
|
|
87
|
+
|
|
88
|
+
Edit images with AI. Each edit costs 50 credits.
|
|
89
|
+
|
|
90
|
+
POST /v1/ai-image-editor
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
name: The name of image
|
|
94
|
+
assets: Provide the assets for image edit
|
|
95
|
+
style: V1AiImageEditorCreateBodyStyle
|
|
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_image_editor.create(
|
|
108
|
+
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
109
|
+
style={"prompt": "Give me sunglasses"},
|
|
110
|
+
name="Ai Image Editor image",
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
"""
|
|
114
|
+
_json = to_encodable(
|
|
115
|
+
item={"name": name, "assets": assets, "style": style},
|
|
116
|
+
dump_with=params._SerializerV1AiImageEditorCreateBody,
|
|
117
|
+
)
|
|
118
|
+
return await self._base_client.request(
|
|
119
|
+
method="POST",
|
|
120
|
+
path="/v1/ai-image-editor",
|
|
121
|
+
auth_names=["bearerAuth"],
|
|
122
|
+
json=_json,
|
|
123
|
+
cast_to=models.V1AiImageEditorCreateResponse,
|
|
124
|
+
request_options=request_options or default_request_options(),
|
|
125
|
+
)
|
|
@@ -5,6 +5,15 @@ Create an AI image. Each image costs 5 credits.
|
|
|
5
5
|
|
|
6
6
|
**API Endpoint**: `POST /v1/ai-image-generator`
|
|
7
7
|
|
|
8
|
+
#### Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Required | Description | Example |
|
|
11
|
+
|-----------|:--------:|-------------|--------|
|
|
12
|
+
| `image_count` | ✓ | number to images to generate | `1` |
|
|
13
|
+
| `orientation` | ✓ | | `"landscape"` |
|
|
14
|
+
| `style` | ✓ | | `{"prompt": "Cool image", "tool": "ai-anime-generator"}` |
|
|
15
|
+
| `name` | ✗ | The name of image | `"Ai Image image"` |
|
|
16
|
+
|
|
8
17
|
#### Synchronous Client
|
|
9
18
|
|
|
10
19
|
```python
|
|
@@ -15,9 +24,10 @@ client = Client(token=getenv("API_TOKEN"))
|
|
|
15
24
|
res = client.v1.ai_image_generator.create(
|
|
16
25
|
image_count=1,
|
|
17
26
|
orientation="landscape",
|
|
18
|
-
style={"prompt": "Cool image"},
|
|
27
|
+
style={"prompt": "Cool image", "tool": "ai-anime-generator"},
|
|
19
28
|
name="Ai Image image",
|
|
20
29
|
)
|
|
30
|
+
|
|
21
31
|
```
|
|
22
32
|
|
|
23
33
|
#### Asynchronous Client
|
|
@@ -30,7 +40,16 @@ client = AsyncClient(token=getenv("API_TOKEN"))
|
|
|
30
40
|
res = await client.v1.ai_image_generator.create(
|
|
31
41
|
image_count=1,
|
|
32
42
|
orientation="landscape",
|
|
33
|
-
style={"prompt": "Cool image"},
|
|
43
|
+
style={"prompt": "Cool image", "tool": "ai-anime-generator"},
|
|
34
44
|
name="Ai Image image",
|
|
35
45
|
)
|
|
46
|
+
|
|
36
47
|
```
|
|
48
|
+
|
|
49
|
+
#### Response
|
|
50
|
+
|
|
51
|
+
##### Type
|
|
52
|
+
[V1AiImageGeneratorCreateResponse](/magic_hour/types/models/v1_ai_image_generator_create_response.py)
|
|
53
|
+
|
|
54
|
+
##### Example
|
|
55
|
+
`{"credits_charged": 5, "frame_cost": 5, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -53,7 +53,7 @@ class AiImageGeneratorClient:
|
|
|
53
53
|
client.v1.ai_image_generator.create(
|
|
54
54
|
image_count=1,
|
|
55
55
|
orientation="landscape",
|
|
56
|
-
style={"prompt": "Cool image"},
|
|
56
|
+
style={"prompt": "Cool image", "tool": "ai-anime-generator"},
|
|
57
57
|
name="Ai Image image",
|
|
58
58
|
)
|
|
59
59
|
```
|
|
@@ -118,7 +118,7 @@ class AsyncAiImageGeneratorClient:
|
|
|
118
118
|
await client.v1.ai_image_generator.create(
|
|
119
119
|
image_count=1,
|
|
120
120
|
orientation="landscape",
|
|
121
|
-
style={"prompt": "Cool image"},
|
|
121
|
+
style={"prompt": "Cool image", "tool": "ai-anime-generator"},
|
|
122
122
|
name="Ai Image image",
|
|
123
123
|
)
|
|
124
124
|
```
|
|
@@ -5,6 +5,15 @@ Upscale your image using AI. Each 2x upscale costs 50 credits, and 4x upscale co
|
|
|
5
5
|
|
|
6
6
|
**API Endpoint**: `POST /v1/ai-image-upscaler`
|
|
7
7
|
|
|
8
|
+
#### Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Required | Description | Example |
|
|
11
|
+
|-----------|:--------:|-------------|--------|
|
|
12
|
+
| `assets` | ✓ | Provide the assets for upscaling | `{"image_file_path": "api-assets/id/1234.png"}` |
|
|
13
|
+
| `scale_factor` | ✓ | How much to scale the image. Must be either 2 or 4 | `2.0` |
|
|
14
|
+
| `style` | ✓ | | `{"enhancement": "Balanced"}` |
|
|
15
|
+
| `name` | ✗ | The name of image | `"Image Upscaler image"` |
|
|
16
|
+
|
|
8
17
|
#### Synchronous Client
|
|
9
18
|
|
|
10
19
|
```python
|
|
@@ -18,6 +27,7 @@ res = client.v1.ai_image_upscaler.create(
|
|
|
18
27
|
style={"enhancement": "Balanced"},
|
|
19
28
|
name="Image Upscaler image",
|
|
20
29
|
)
|
|
30
|
+
|
|
21
31
|
```
|
|
22
32
|
|
|
23
33
|
#### Asynchronous Client
|
|
@@ -33,4 +43,13 @@ res = await client.v1.ai_image_upscaler.create(
|
|
|
33
43
|
style={"enhancement": "Balanced"},
|
|
34
44
|
name="Image Upscaler image",
|
|
35
45
|
)
|
|
46
|
+
|
|
36
47
|
```
|
|
48
|
+
|
|
49
|
+
#### Response
|
|
50
|
+
|
|
51
|
+
##### Type
|
|
52
|
+
[V1AiImageUpscalerCreateResponse](/magic_hour/types/models/v1_ai_image_upscaler_create_response.py)
|
|
53
|
+
|
|
54
|
+
##### Example
|
|
55
|
+
`{"credits_charged": 50, "frame_cost": 50, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -5,6 +5,13 @@ Create an AI generated meme. Each meme costs 10 credits.
|
|
|
5
5
|
|
|
6
6
|
**API Endpoint**: `POST /v1/ai-meme-generator`
|
|
7
7
|
|
|
8
|
+
#### Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Required | Description | Example |
|
|
11
|
+
|-----------|:--------:|-------------|--------|
|
|
12
|
+
| `style` | ✓ | | `{"search_web": False, "template": "Drake Hotline Bling", "topic": "When the code finally works"}` |
|
|
13
|
+
| `name` | ✗ | The name of the meme. | `"My Funny Meme"` |
|
|
14
|
+
|
|
8
15
|
#### Synchronous Client
|
|
9
16
|
|
|
10
17
|
```python
|
|
@@ -20,6 +27,7 @@ res = client.v1.ai_meme_generator.create(
|
|
|
20
27
|
},
|
|
21
28
|
name="My Funny Meme",
|
|
22
29
|
)
|
|
30
|
+
|
|
23
31
|
```
|
|
24
32
|
|
|
25
33
|
#### Asynchronous Client
|
|
@@ -37,4 +45,13 @@ res = await client.v1.ai_meme_generator.create(
|
|
|
37
45
|
},
|
|
38
46
|
name="My Funny Meme",
|
|
39
47
|
)
|
|
48
|
+
|
|
40
49
|
```
|
|
50
|
+
|
|
51
|
+
#### Response
|
|
52
|
+
|
|
53
|
+
##### Type
|
|
54
|
+
[V1AiMemeGeneratorCreateResponse](/magic_hour/types/models/v1_ai_meme_generator_create_response.py)
|
|
55
|
+
|
|
56
|
+
##### Example
|
|
57
|
+
`{"credits_charged": 10, "frame_cost": 10, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -7,6 +7,16 @@ Edit photo using AI. Each photo costs 10 credits.
|
|
|
7
7
|
|
|
8
8
|
**API Endpoint**: `POST /v1/ai-photo-editor`
|
|
9
9
|
|
|
10
|
+
#### Parameters
|
|
11
|
+
|
|
12
|
+
| Parameter | Required | Description | Example |
|
|
13
|
+
|-----------|:--------:|-------------|--------|
|
|
14
|
+
| `assets` | ✓ | Provide the assets for photo editor | `{"image_file_path": "api-assets/id/1234.png"}` |
|
|
15
|
+
| `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 | `768` |
|
|
16
|
+
| `style` | ✓ | | `{"image_description": "A photo of a person", "likeness_strength": 5.2, "negative_prompt": "painting, cartoon, sketch", "prompt": "A photo portrait of a person wearing a hat", "prompt_strength": 3.75, "steps": 4, "upscale_factor": 2, "upscale_fidelity": 0.5}` |
|
|
17
|
+
| `name` | ✗ | The name of image | `"Photo Editor image"` |
|
|
18
|
+
| `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. | `123` |
|
|
19
|
+
|
|
10
20
|
#### Synchronous Client
|
|
11
21
|
|
|
12
22
|
```python
|
|
@@ -29,6 +39,7 @@ res = client.v1.ai_photo_editor.create(
|
|
|
29
39
|
},
|
|
30
40
|
name="Photo Editor image",
|
|
31
41
|
)
|
|
42
|
+
|
|
32
43
|
```
|
|
33
44
|
|
|
34
45
|
#### Asynchronous Client
|
|
@@ -53,4 +64,13 @@ res = await client.v1.ai_photo_editor.create(
|
|
|
53
64
|
},
|
|
54
65
|
name="Photo Editor image",
|
|
55
66
|
)
|
|
67
|
+
|
|
56
68
|
```
|
|
69
|
+
|
|
70
|
+
#### Response
|
|
71
|
+
|
|
72
|
+
##### Type
|
|
73
|
+
[V1AiPhotoEditorCreateResponse](/magic_hour/types/models/v1_ai_photo_editor_create_response.py)
|
|
74
|
+
|
|
75
|
+
##### Example
|
|
76
|
+
`{"credits_charged": 10, "frame_cost": 10, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -5,6 +5,14 @@ Create an AI QR code. Each QR code costs 20 credits.
|
|
|
5
5
|
|
|
6
6
|
**API Endpoint**: `POST /v1/ai-qr-code-generator`
|
|
7
7
|
|
|
8
|
+
#### Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Required | Description | Example |
|
|
11
|
+
|-----------|:--------:|-------------|--------|
|
|
12
|
+
| `content` | ✓ | The content of the QR code. | `"https://magichour.ai"` |
|
|
13
|
+
| `style` | ✓ | | `{"art_style": "Watercolor"}` |
|
|
14
|
+
| `name` | ✗ | The name of image | `"Qr Code image"` |
|
|
15
|
+
|
|
8
16
|
#### Synchronous Client
|
|
9
17
|
|
|
10
18
|
```python
|
|
@@ -17,6 +25,7 @@ res = client.v1.ai_qr_code_generator.create(
|
|
|
17
25
|
style={"art_style": "Watercolor"},
|
|
18
26
|
name="Qr Code image",
|
|
19
27
|
)
|
|
28
|
+
|
|
20
29
|
```
|
|
21
30
|
|
|
22
31
|
#### Asynchronous Client
|
|
@@ -31,4 +40,13 @@ res = await client.v1.ai_qr_code_generator.create(
|
|
|
31
40
|
style={"art_style": "Watercolor"},
|
|
32
41
|
name="Qr Code image",
|
|
33
42
|
)
|
|
43
|
+
|
|
34
44
|
```
|
|
45
|
+
|
|
46
|
+
#### Response
|
|
47
|
+
|
|
48
|
+
##### Type
|
|
49
|
+
[V1AiQrCodeGeneratorCreateResponse](/magic_hour/types/models/v1_ai_qr_code_generator_create_response.py)
|
|
50
|
+
|
|
51
|
+
##### Example
|
|
52
|
+
`{"credits_charged": 20, "frame_cost": 20, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -5,6 +5,16 @@ Create a talking photo from an image and audio or text input.
|
|
|
5
5
|
|
|
6
6
|
**API Endpoint**: `POST /v1/ai-talking-photo`
|
|
7
7
|
|
|
8
|
+
#### Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Required | Description | Example |
|
|
11
|
+
|-----------|:--------:|-------------|--------|
|
|
12
|
+
| `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"}` |
|
|
13
|
+
| `end_seconds` | ✓ | The end time of the input audio in seconds. The maximum duration allowed is 30 seconds. | `15.0` |
|
|
14
|
+
| `start_seconds` | ✓ | The start time of the input audio in seconds. The maximum duration allowed is 30 seconds. | `0.0` |
|
|
15
|
+
| `name` | ✗ | The name of image | `"Talking Photo image"` |
|
|
16
|
+
| `style` | ✗ | Attributes used to dictate the style of the output | `{"generation_mode": "expressive", "intensity": 1.5}` |
|
|
17
|
+
|
|
8
18
|
#### Synchronous Client
|
|
9
19
|
|
|
10
20
|
```python
|
|
@@ -21,6 +31,7 @@ res = client.v1.ai_talking_photo.create(
|
|
|
21
31
|
start_seconds=0.0,
|
|
22
32
|
name="Talking Photo image",
|
|
23
33
|
)
|
|
34
|
+
|
|
24
35
|
```
|
|
25
36
|
|
|
26
37
|
#### Asynchronous Client
|
|
@@ -39,4 +50,13 @@ res = await client.v1.ai_talking_photo.create(
|
|
|
39
50
|
start_seconds=0.0,
|
|
40
51
|
name="Talking Photo image",
|
|
41
52
|
)
|
|
53
|
+
|
|
42
54
|
```
|
|
55
|
+
|
|
56
|
+
#### Response
|
|
57
|
+
|
|
58
|
+
##### Type
|
|
59
|
+
[V1AiTalkingPhotoCreateResponse](/magic_hour/types/models/v1_ai_talking_photo_create_response.py)
|
|
60
|
+
|
|
61
|
+
##### Example
|
|
62
|
+
`{"credits_charged": 450, "estimated_frame_cost": 450, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -5,6 +5,18 @@ Create a Animation video. The estimated frame cost is calculated based on the `f
|
|
|
5
5
|
|
|
6
6
|
**API Endpoint**: `POST /v1/animation`
|
|
7
7
|
|
|
8
|
+
#### Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Required | Description | Example |
|
|
11
|
+
|-----------|:--------:|-------------|--------|
|
|
12
|
+
| `assets` | ✓ | Provide the assets for animation. | `{"audio_file_path": "api-assets/id/1234.mp3", "audio_source": "file", "image_file_path": "api-assets/id/1234.png"}` |
|
|
13
|
+
| `end_seconds` | ✓ | The end time of the input video in seconds | `15.0` |
|
|
14
|
+
| `fps` | ✓ | The desire output video frame rate | `12.0` |
|
|
15
|
+
| `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 | `960` |
|
|
16
|
+
| `style` | ✓ | Defines the style of the output video | `{"art_style": "Painterly Illustration", "camera_effect": "Accelerate", "prompt": "Cyberpunk city", "prompt_type": "ai_choose", "transition_speed": 5}` |
|
|
17
|
+
| `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 | `512` |
|
|
18
|
+
| `name` | ✗ | The name of video | `"Animation video"` |
|
|
19
|
+
|
|
8
20
|
#### Synchronous Client
|
|
9
21
|
|
|
10
22
|
```python
|
|
@@ -31,6 +43,7 @@ res = client.v1.animation.create(
|
|
|
31
43
|
width=512,
|
|
32
44
|
name="Animation video",
|
|
33
45
|
)
|
|
46
|
+
|
|
34
47
|
```
|
|
35
48
|
|
|
36
49
|
#### Asynchronous Client
|
|
@@ -59,4 +72,13 @@ res = await client.v1.animation.create(
|
|
|
59
72
|
width=512,
|
|
60
73
|
name="Animation video",
|
|
61
74
|
)
|
|
75
|
+
|
|
62
76
|
```
|
|
77
|
+
|
|
78
|
+
#### Response
|
|
79
|
+
|
|
80
|
+
##### Type
|
|
81
|
+
[V1AnimationCreateResponse](/magic_hour/types/models/v1_animation_create_response.py)
|
|
82
|
+
|
|
83
|
+
##### Example
|
|
84
|
+
`{"credits_charged": 450, "estimated_frame_cost": 450, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -15,6 +15,10 @@ from magic_hour.resources.v1.ai_headshot_generator import (
|
|
|
15
15
|
AiHeadshotGeneratorClient,
|
|
16
16
|
AsyncAiHeadshotGeneratorClient,
|
|
17
17
|
)
|
|
18
|
+
from magic_hour.resources.v1.ai_image_editor import (
|
|
19
|
+
AiImageEditorClient,
|
|
20
|
+
AsyncAiImageEditorClient,
|
|
21
|
+
)
|
|
18
22
|
from magic_hour.resources.v1.ai_image_generator import (
|
|
19
23
|
AiImageGeneratorClient,
|
|
20
24
|
AsyncAiImageGeneratorClient,
|
|
@@ -88,6 +92,7 @@ class V1Client:
|
|
|
88
92
|
self.ai_headshot_generator = AiHeadshotGeneratorClient(
|
|
89
93
|
base_client=self._base_client
|
|
90
94
|
)
|
|
95
|
+
self.ai_image_editor = AiImageEditorClient(base_client=self._base_client)
|
|
91
96
|
self.ai_image_generator = AiImageGeneratorClient(base_client=self._base_client)
|
|
92
97
|
self.ai_image_upscaler = AiImageUpscalerClient(base_client=self._base_client)
|
|
93
98
|
self.ai_meme_generator = AiMemeGeneratorClient(base_client=self._base_client)
|
|
@@ -123,6 +128,7 @@ class AsyncV1Client:
|
|
|
123
128
|
self.ai_headshot_generator = AsyncAiHeadshotGeneratorClient(
|
|
124
129
|
base_client=self._base_client
|
|
125
130
|
)
|
|
131
|
+
self.ai_image_editor = AsyncAiImageEditorClient(base_client=self._base_client)
|
|
126
132
|
self.ai_image_generator = AsyncAiImageGeneratorClient(
|
|
127
133
|
base_client=self._base_client
|
|
128
134
|
)
|
|
@@ -8,6 +8,17 @@ Get more information about this mode at our [product page](/products/face-swap).
|
|
|
8
8
|
|
|
9
9
|
**API Endpoint**: `POST /v1/face-swap`
|
|
10
10
|
|
|
11
|
+
#### Parameters
|
|
12
|
+
|
|
13
|
+
| Parameter | Required | Description | Example |
|
|
14
|
+
|-----------|:--------:|-------------|--------|
|
|
15
|
+
| `assets` | ✓ | Provide the assets for face swap. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used | `{"image_file_path": "image/id/1234.png", "video_file_path": "api-assets/id/1234.mp4", "video_source": "file"}` |
|
|
16
|
+
| `end_seconds` | ✓ | The end time of the input video in seconds | `15.0` |
|
|
17
|
+
| `start_seconds` | ✓ | The start time of the input video in seconds | `0.0` |
|
|
18
|
+
| `height` | ✗ | Used to determine the dimensions of the output video. * If height is provided, width will also be required. The larger value between width and height will be used to determine the maximum output resolution while maintaining the original aspect ratio. * If both height and width are omitted, the video will be resized according to your subscription's maximum resolution, while preserving aspect ratio. Note: if the video's original resolution is less than the maximum, the video will not be resized. See our [pricing page](https://magichour.ai/pricing) for more details. | `960` |
|
|
19
|
+
| `name` | ✗ | The name of video | `"Face Swap video"` |
|
|
20
|
+
| `width` | ✗ | Used to determine the dimensions of the output video. * If width is provided, height will also be required. The larger value between width and height will be used to determine the maximum output resolution while maintaining the original aspect ratio. * If both height and width are omitted, the video will be resized according to your subscription's maximum resolution, while preserving aspect ratio. Note: if the video's original resolution is less than the maximum, the video will not be resized. See our [pricing page](https://magichour.ai/pricing) for more details. | `512` |
|
|
21
|
+
|
|
11
22
|
#### Synchronous Client
|
|
12
23
|
|
|
13
24
|
```python
|
|
@@ -27,6 +38,7 @@ res = client.v1.face_swap.create(
|
|
|
27
38
|
name="Face Swap video",
|
|
28
39
|
width=512,
|
|
29
40
|
)
|
|
41
|
+
|
|
30
42
|
```
|
|
31
43
|
|
|
32
44
|
#### Asynchronous Client
|
|
@@ -48,4 +60,13 @@ res = await client.v1.face_swap.create(
|
|
|
48
60
|
name="Face Swap video",
|
|
49
61
|
width=512,
|
|
50
62
|
)
|
|
63
|
+
|
|
51
64
|
```
|
|
65
|
+
|
|
66
|
+
#### Response
|
|
67
|
+
|
|
68
|
+
##### Type
|
|
69
|
+
[V1FaceSwapCreateResponse](/magic_hour/types/models/v1_face_swap_create_response.py)
|
|
70
|
+
|
|
71
|
+
##### Example
|
|
72
|
+
`{"credits_charged": 450, "estimated_frame_cost": 450, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -5,6 +5,13 @@ Create a face swap photo. Each photo costs 5 credits. The height/width of the ou
|
|
|
5
5
|
|
|
6
6
|
**API Endpoint**: `POST /v1/face-swap-photo`
|
|
7
7
|
|
|
8
|
+
#### Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Required | Description | Example |
|
|
11
|
+
|-----------|:--------:|-------------|--------|
|
|
12
|
+
| `assets` | ✓ | Provide the assets for face swap photo | `{"source_file_path": "api-assets/id/1234.png", "target_file_path": "api-assets/id/1234.png"}` |
|
|
13
|
+
| `name` | ✗ | The name of image | `"Face Swap image"` |
|
|
14
|
+
|
|
8
15
|
#### Synchronous Client
|
|
9
16
|
|
|
10
17
|
```python
|
|
@@ -19,6 +26,7 @@ res = client.v1.face_swap_photo.create(
|
|
|
19
26
|
},
|
|
20
27
|
name="Face Swap image",
|
|
21
28
|
)
|
|
29
|
+
|
|
22
30
|
```
|
|
23
31
|
|
|
24
32
|
#### Asynchronous Client
|
|
@@ -35,4 +43,13 @@ res = await client.v1.face_swap_photo.create(
|
|
|
35
43
|
},
|
|
36
44
|
name="Face Swap image",
|
|
37
45
|
)
|
|
46
|
+
|
|
38
47
|
```
|
|
48
|
+
|
|
49
|
+
#### Response
|
|
50
|
+
|
|
51
|
+
##### Type
|
|
52
|
+
[V1FaceSwapPhotoCreateResponse](/magic_hour/types/models/v1_face_swap_photo_create_response.py)
|
|
53
|
+
|
|
54
|
+
##### Example
|
|
55
|
+
`{"credits_charged": 5, "frame_cost": 5, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|
|
@@ -11,19 +11,24 @@ Below is the list of valid extensions for each asset type:
|
|
|
11
11
|
|
|
12
12
|
Note: `.gif` is supported for face swap API `video_file_path` field.
|
|
13
13
|
|
|
14
|
-
After receiving the upload url, you can upload the file by sending a PUT request
|
|
14
|
+
After receiving the upload url, you can upload the file by sending a PUT request.
|
|
15
15
|
|
|
16
16
|
For example using curl
|
|
17
17
|
|
|
18
18
|
```
|
|
19
|
-
curl -X PUT
|
|
20
|
-
|
|
21
|
-
https://videos.magichour.ai/api-assets/id/video.mp4?auth-value=1234567890
|
|
19
|
+
curl -X PUT --data '@/path/to/file/video.mp4' \
|
|
20
|
+
https://videos.magichour.ai/api-assets/id/video.mp4?<auth params from the API response>
|
|
22
21
|
```
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
**API Endpoint**: `POST /v1/files/upload-urls`
|
|
26
25
|
|
|
26
|
+
#### Parameters
|
|
27
|
+
|
|
28
|
+
| Parameter | Required | Description | Example |
|
|
29
|
+
|-----------|:--------:|-------------|--------|
|
|
30
|
+
| `items` | ✓ | | `[{"extension": "mp4", "type_": "video"}, {"extension": "mp3", "type_": "audio"}]` |
|
|
31
|
+
|
|
27
32
|
#### Synchronous Client
|
|
28
33
|
|
|
29
34
|
```python
|
|
@@ -37,6 +42,7 @@ res = client.v1.files.upload_urls.create(
|
|
|
37
42
|
{"extension": "mp3", "type_": "audio"},
|
|
38
43
|
]
|
|
39
44
|
)
|
|
45
|
+
|
|
40
46
|
```
|
|
41
47
|
|
|
42
48
|
#### Asynchronous Client
|
|
@@ -52,4 +58,13 @@ res = await client.v1.files.upload_urls.create(
|
|
|
52
58
|
{"extension": "mp3", "type_": "audio"},
|
|
53
59
|
]
|
|
54
60
|
)
|
|
61
|
+
|
|
55
62
|
```
|
|
63
|
+
|
|
64
|
+
#### Response
|
|
65
|
+
|
|
66
|
+
##### Type
|
|
67
|
+
[V1FilesUploadUrlsCreateResponse](/magic_hour/types/models/v1_files_upload_urls_create_response.py)
|
|
68
|
+
|
|
69
|
+
##### Example
|
|
70
|
+
`{"items": [{"expires_at": "2024-07-25T16:56:21.932Z", "file_path": "api-assets/id/video.mp4", "upload_url": "https://videos.magichour.ai/api-assets/id/video.mp4?auth-value=1234567890"}, {"expires_at": "2024-07-25T16:56:21.932Z", "file_path": "api-assets/id/audio.mp3", "upload_url": "https://videos.magichour.ai/api-assets/id/audio.mp3?auth-value=1234567890"}]}`
|
|
@@ -33,14 +33,13 @@ class UploadUrlsClient:
|
|
|
33
33
|
|
|
34
34
|
Note: `.gif` is supported for face swap API `video_file_path` field.
|
|
35
35
|
|
|
36
|
-
After receiving the upload url, you can upload the file by sending a PUT request
|
|
36
|
+
After receiving the upload url, you can upload the file by sending a PUT request.
|
|
37
37
|
|
|
38
38
|
For example using curl
|
|
39
39
|
|
|
40
40
|
```
|
|
41
|
-
curl -X PUT
|
|
42
|
-
|
|
43
|
-
https://videos.magichour.ai/api-assets/id/video.mp4?auth-value=1234567890
|
|
41
|
+
curl -X PUT --data '@/path/to/file/video.mp4' \
|
|
42
|
+
https://videos.magichour.ai/api-assets/id/video.mp4?<auth params from the API response>
|
|
44
43
|
```
|
|
45
44
|
|
|
46
45
|
|
|
@@ -99,14 +98,13 @@ class AsyncUploadUrlsClient:
|
|
|
99
98
|
|
|
100
99
|
Note: `.gif` is supported for face swap API `video_file_path` field.
|
|
101
100
|
|
|
102
|
-
After receiving the upload url, you can upload the file by sending a PUT request
|
|
101
|
+
After receiving the upload url, you can upload the file by sending a PUT request.
|
|
103
102
|
|
|
104
103
|
For example using curl
|
|
105
104
|
|
|
106
105
|
```
|
|
107
|
-
curl -X PUT
|
|
108
|
-
|
|
109
|
-
https://videos.magichour.ai/api-assets/id/video.mp4?auth-value=1234567890
|
|
106
|
+
curl -X PUT --data '@/path/to/file/video.mp4' \
|
|
107
|
+
https://videos.magichour.ai/api-assets/id/video.mp4?<auth params from the API response>
|
|
110
108
|
```
|
|
111
109
|
|
|
112
110
|
|
|
@@ -5,6 +5,13 @@ Remove background from image. Each image costs 5 credits.
|
|
|
5
5
|
|
|
6
6
|
**API Endpoint**: `POST /v1/image-background-remover`
|
|
7
7
|
|
|
8
|
+
#### Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Required | Description | Example |
|
|
11
|
+
|-----------|:--------:|-------------|--------|
|
|
12
|
+
| `assets` | ✓ | Provide the assets for background removal | `{"image_file_path": "api-assets/id/1234.png"}` |
|
|
13
|
+
| `name` | ✗ | The name of image | `"Background Remover image"` |
|
|
14
|
+
|
|
8
15
|
#### Synchronous Client
|
|
9
16
|
|
|
10
17
|
```python
|
|
@@ -16,6 +23,7 @@ res = client.v1.image_background_remover.create(
|
|
|
16
23
|
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
17
24
|
name="Background Remover image",
|
|
18
25
|
)
|
|
26
|
+
|
|
19
27
|
```
|
|
20
28
|
|
|
21
29
|
#### Asynchronous Client
|
|
@@ -29,4 +37,13 @@ res = await client.v1.image_background_remover.create(
|
|
|
29
37
|
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
30
38
|
name="Background Remover image",
|
|
31
39
|
)
|
|
40
|
+
|
|
32
41
|
```
|
|
42
|
+
|
|
43
|
+
#### Response
|
|
44
|
+
|
|
45
|
+
##### Type
|
|
46
|
+
[V1ImageBackgroundRemoverCreateResponse](/magic_hour/types/models/v1_image_background_remover_create_response.py)
|
|
47
|
+
|
|
48
|
+
##### Example
|
|
49
|
+
`{"credits_charged": 5, "frame_cost": 5, "id": "clx7uu86w0a5qp55yxz315r6r"}`
|