magic-hour 0.44.0 → 0.46.0

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.
Files changed (125) hide show
  1. package/dist/environment.d.ts +1 -1
  2. package/dist/environment.js +1 -1
  3. package/dist/resources/v1/ai-clothes-changer/request-types.d.ts +1 -1
  4. package/dist/resources/v1/ai-face-editor/request-types.d.ts +1 -1
  5. package/dist/resources/v1/ai-gif-generator/request-types.d.ts +1 -1
  6. package/dist/resources/v1/ai-headshot-generator/request-types.d.ts +1 -1
  7. package/dist/resources/v1/ai-image-editor/request-types.d.ts +1 -1
  8. package/dist/resources/v1/ai-image-editor/resource-client.d.ts +1 -1
  9. package/dist/resources/v1/ai-image-editor/resource-client.js +1 -1
  10. package/dist/resources/v1/ai-image-generator/request-types.d.ts +1 -1
  11. package/dist/resources/v1/ai-image-upscaler/request-types.d.ts +1 -1
  12. package/dist/resources/v1/ai-photo-editor/request-types.d.ts +1 -1
  13. package/dist/resources/v1/ai-qr-code-generator/request-types.d.ts +1 -1
  14. package/dist/resources/v1/ai-talking-photo/request-types.d.ts +6 -1
  15. package/dist/resources/v1/ai-talking-photo/request-types.js +4 -0
  16. package/dist/resources/v1/ai-voice-cloner/request-types.d.ts +1 -1
  17. package/dist/resources/v1/ai-voice-generator/request-types.d.ts +1 -1
  18. package/dist/resources/v1/animation/request-types.d.ts +1 -1
  19. package/dist/resources/v1/audio-projects/resource-client.d.ts +9 -10
  20. package/dist/resources/v1/audio-projects/resource-client.js +8 -9
  21. package/dist/resources/v1/auto-subtitle-generator/request-types.d.ts +3 -3
  22. package/dist/resources/v1/face-swap/request-types.d.ts +3 -3
  23. package/dist/resources/v1/face-swap/resource-client.d.ts +20 -2
  24. package/dist/resources/v1/face-swap/resource-client.js +20 -2
  25. package/dist/resources/v1/face-swap-photo/request-types.d.ts +1 -1
  26. package/dist/resources/v1/files/resource-client.d.ts +13 -3
  27. package/dist/resources/v1/files/resource-client.js +54 -3
  28. package/dist/resources/v1/files/resource-client.test.js +45 -0
  29. package/dist/resources/v1/image-background-remover/request-types.d.ts +1 -1
  30. package/dist/resources/v1/image-projects/resource-client.d.ts +9 -10
  31. package/dist/resources/v1/image-projects/resource-client.js +8 -9
  32. package/dist/resources/v1/image-to-video/request-types.d.ts +1 -1
  33. package/dist/resources/v1/image-to-video/resource-client.d.ts +20 -2
  34. package/dist/resources/v1/image-to-video/resource-client.js +20 -2
  35. package/dist/resources/v1/lip-sync/request-types.d.ts +3 -3
  36. package/dist/resources/v1/lip-sync/resource-client.d.ts +20 -2
  37. package/dist/resources/v1/lip-sync/resource-client.js +20 -2
  38. package/dist/resources/v1/photo-colorizer/request-types.d.ts +1 -1
  39. package/dist/resources/v1/photo-colorizer/resource-client.d.ts +1 -1
  40. package/dist/resources/v1/photo-colorizer/resource-client.js +1 -1
  41. package/dist/resources/v1/text-to-video/request-types.d.ts +1 -1
  42. package/dist/resources/v1/text-to-video/resource-client.d.ts +20 -2
  43. package/dist/resources/v1/text-to-video/resource-client.js +20 -2
  44. package/dist/resources/v1/video-projects/resource-client.d.ts +9 -10
  45. package/dist/resources/v1/video-projects/resource-client.js +8 -9
  46. package/dist/resources/v1/video-to-video/request-types.d.ts +3 -3
  47. package/dist/resources/v1/video-to-video/resource-client.d.ts +20 -2
  48. package/dist/resources/v1/video-to-video/resource-client.js +20 -2
  49. package/dist/types/v1-ai-clothes-changer-create-body-assets-garment-type-enum.d.ts +6 -2
  50. package/dist/types/v1-ai-clothes-changer-create-body-assets.d.ts +9 -5
  51. package/dist/types/v1-ai-clothes-changer-create-body-assets.js +6 -2
  52. package/dist/types/v1-ai-clothes-changer-create-body.d.ts +1 -1
  53. package/dist/types/v1-ai-clothes-changer-create-response.d.ts +1 -1
  54. package/dist/types/v1-ai-face-editor-create-body-assets.d.ts +1 -1
  55. package/dist/types/v1-ai-face-editor-create-body.d.ts +1 -1
  56. package/dist/types/v1-ai-face-editor-create-response.d.ts +1 -1
  57. package/dist/types/v1-ai-gif-generator-create-body.d.ts +1 -1
  58. package/dist/types/v1-ai-gif-generator-create-response.d.ts +1 -1
  59. package/dist/types/v1-ai-headshot-generator-create-body-assets.d.ts +1 -1
  60. package/dist/types/v1-ai-headshot-generator-create-body.d.ts +1 -1
  61. package/dist/types/v1-ai-headshot-generator-create-response.d.ts +1 -1
  62. package/dist/types/v1-ai-image-editor-create-body-assets.d.ts +2 -2
  63. package/dist/types/v1-ai-image-editor-create-body.d.ts +1 -1
  64. package/dist/types/v1-ai-image-editor-create-response.d.ts +1 -1
  65. package/dist/types/v1-ai-image-generator-create-body.d.ts +1 -1
  66. package/dist/types/v1-ai-image-generator-create-response.d.ts +1 -1
  67. package/dist/types/v1-ai-image-upscaler-create-body-assets.d.ts +1 -1
  68. package/dist/types/v1-ai-image-upscaler-create-body.d.ts +1 -1
  69. package/dist/types/v1-ai-image-upscaler-create-response.d.ts +1 -1
  70. package/dist/types/v1-ai-meme-generator-create-response.d.ts +1 -1
  71. package/dist/types/v1-ai-photo-editor-create-body-assets.d.ts +1 -1
  72. package/dist/types/v1-ai-photo-editor-create-body.d.ts +1 -1
  73. package/dist/types/v1-ai-photo-editor-create-response.d.ts +1 -1
  74. package/dist/types/v1-ai-qr-code-generator-create-body.d.ts +1 -1
  75. package/dist/types/v1-ai-qr-code-generator-create-response.d.ts +1 -1
  76. package/dist/types/v1-ai-talking-photo-create-body-assets.d.ts +2 -2
  77. package/dist/types/v1-ai-talking-photo-create-body.d.ts +6 -1
  78. package/dist/types/v1-ai-talking-photo-create-body.js +4 -0
  79. package/dist/types/v1-ai-talking-photo-create-response.d.ts +1 -1
  80. package/dist/types/v1-ai-voice-cloner-create-body-assets.d.ts +1 -1
  81. package/dist/types/v1-ai-voice-cloner-create-body.d.ts +1 -1
  82. package/dist/types/v1-ai-voice-cloner-create-response.d.ts +1 -1
  83. package/dist/types/v1-ai-voice-generator-create-body.d.ts +1 -1
  84. package/dist/types/v1-ai-voice-generator-create-response.d.ts +1 -1
  85. package/dist/types/v1-animation-create-body-assets.d.ts +2 -2
  86. package/dist/types/v1-animation-create-body.d.ts +1 -1
  87. package/dist/types/v1-animation-create-response.d.ts +1 -1
  88. package/dist/types/v1-audio-projects-get-response.d.ts +2 -2
  89. package/dist/types/v1-auto-subtitle-generator-create-body-assets.d.ts +1 -1
  90. package/dist/types/v1-auto-subtitle-generator-create-body.d.ts +3 -3
  91. package/dist/types/v1-auto-subtitle-generator-create-response.d.ts +1 -1
  92. package/dist/types/v1-face-detection-create-body-assets.d.ts +1 -1
  93. package/dist/types/v1-face-swap-create-body-assets-face-mappings-item.d.ts +1 -1
  94. package/dist/types/v1-face-swap-create-body-assets-face-swap-mode-enum.d.ts +3 -3
  95. package/dist/types/v1-face-swap-create-body-assets-video-source-enum.d.ts +1 -1
  96. package/dist/types/v1-face-swap-create-body-assets.d.ts +10 -7
  97. package/dist/types/v1-face-swap-create-body.d.ts +3 -3
  98. package/dist/types/v1-face-swap-create-response.d.ts +1 -1
  99. package/dist/types/v1-face-swap-photo-create-body-assets-face-mappings-item.d.ts +1 -1
  100. package/dist/types/v1-face-swap-photo-create-body-assets-face-swap-mode-enum.d.ts +3 -3
  101. package/dist/types/v1-face-swap-photo-create-body-assets.d.ts +5 -5
  102. package/dist/types/v1-face-swap-photo-create-body.d.ts +1 -1
  103. package/dist/types/v1-face-swap-photo-create-response.d.ts +1 -1
  104. package/dist/types/v1-image-background-remover-create-body-assets.d.ts +2 -2
  105. package/dist/types/v1-image-background-remover-create-body.d.ts +1 -1
  106. package/dist/types/v1-image-background-remover-create-response.d.ts +1 -1
  107. package/dist/types/v1-image-projects-get-response.d.ts +2 -2
  108. package/dist/types/v1-image-to-video-create-body-assets.d.ts +1 -1
  109. package/dist/types/v1-image-to-video-create-body.d.ts +1 -1
  110. package/dist/types/v1-image-to-video-create-response.d.ts +1 -1
  111. package/dist/types/v1-lip-sync-create-body-assets-video-source-enum.d.ts +1 -1
  112. package/dist/types/v1-lip-sync-create-body-assets.d.ts +7 -4
  113. package/dist/types/v1-lip-sync-create-body.d.ts +3 -3
  114. package/dist/types/v1-lip-sync-create-response.d.ts +1 -1
  115. package/dist/types/v1-photo-colorizer-create-body-assets.d.ts +1 -1
  116. package/dist/types/v1-photo-colorizer-create-body.d.ts +1 -1
  117. package/dist/types/v1-photo-colorizer-create-response.d.ts +1 -1
  118. package/dist/types/v1-text-to-video-create-body.d.ts +1 -1
  119. package/dist/types/v1-text-to-video-create-response.d.ts +1 -1
  120. package/dist/types/v1-video-projects-get-response.d.ts +4 -4
  121. package/dist/types/v1-video-to-video-create-body-assets-video-source-enum.d.ts +1 -1
  122. package/dist/types/v1-video-to-video-create-body-assets.d.ts +6 -3
  123. package/dist/types/v1-video-to-video-create-body.d.ts +3 -3
  124. package/dist/types/v1-video-to-video-create-response.d.ts +1 -1
  125. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  export declare enum Environment {
2
2
  Environment = "https://api.magichour.ai",
3
- MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.43.1"
3
+ MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.46.0"
4
4
  }
@@ -4,5 +4,5 @@ exports.Environment = void 0;
4
4
  var Environment;
5
5
  (function (Environment) {
6
6
  Environment["Environment"] = "https://api.magichour.ai";
7
- Environment["MockServer"] = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.43.1";
7
+ Environment["MockServer"] = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.46.0";
8
8
  })(Environment || (exports.Environment = Environment = {}));
@@ -9,7 +9,7 @@ export type CreateRequest = {
9
9
  */
10
10
  assets: V1AiClothesChangerCreateBodyAssets;
11
11
  /**
12
- * The name of image. This value is mainly used for your own identification of the image.
12
+ * Give your image a custom name for easy identification.
13
13
  */
14
14
  name?: string | undefined;
15
15
  };
@@ -10,7 +10,7 @@ export type CreateRequest = {
10
10
  */
11
11
  assets: V1AiFaceEditorCreateBodyAssets;
12
12
  /**
13
- * The name of image. This value is mainly used for your own identification of the image.
13
+ * Give your image a custom name for easy identification.
14
14
  */
15
15
  name?: string | undefined;
16
16
  /**
@@ -5,7 +5,7 @@ import { External$V1AiGifGeneratorCreateBodyStyle, V1AiGifGeneratorCreateBodySty
5
5
  */
6
6
  export type CreateRequest = {
7
7
  /**
8
- * The name of gif. This value is mainly used for your own identification of the gif.
8
+ * Give your gif a custom name for easy identification.
9
9
  */
10
10
  name?: string | undefined;
11
11
  /**
@@ -10,7 +10,7 @@ export type CreateRequest = {
10
10
  */
11
11
  assets: V1AiHeadshotGeneratorCreateBodyAssets;
12
12
  /**
13
- * The name of image. This value is mainly used for your own identification of the image.
13
+ * Give your image a custom name for easy identification.
14
14
  */
15
15
  name?: string | undefined;
16
16
  style?: V1AiHeadshotGeneratorCreateBodyStyle | undefined;
@@ -10,7 +10,7 @@ export type CreateRequest = {
10
10
  */
11
11
  assets: V1AiImageEditorCreateBodyAssets;
12
12
  /**
13
- * The name of image. This value is mainly used for your own identification of the image.
13
+ * Give your image a custom name for easy identification.
14
14
  */
15
15
  name?: string | undefined;
16
16
  style: V1AiImageEditorCreateBodyStyle;
@@ -54,7 +54,7 @@ export declare class AiImageEditorClient extends CoreResourceClient {
54
54
  /**
55
55
  * AI Image Editor
56
56
  *
57
- * Edit images with AI. Each edit costs 50 credits.
57
+ * Edit images with AI. Each edit costs 10 credits.
58
58
  *
59
59
  * POST /v1/ai-image-editor
60
60
  */
@@ -86,7 +86,7 @@ class AiImageEditorClient extends make_api_request_js_1.CoreResourceClient {
86
86
  /**
87
87
  * AI Image Editor
88
88
  *
89
- * Edit images with AI. Each edit costs 50 credits.
89
+ * Edit images with AI. Each edit costs 10 credits.
90
90
  *
91
91
  * POST /v1/ai-image-editor
92
92
  */
@@ -9,7 +9,7 @@ export type CreateRequest = {
9
9
  */
10
10
  imageCount: number;
11
11
  /**
12
- * The name of image. This value is mainly used for your own identification of the image.
12
+ * Give your image a custom name for easy identification.
13
13
  */
14
14
  name?: string | undefined;
15
15
  /**
@@ -10,7 +10,7 @@ export type CreateRequest = {
10
10
  */
11
11
  assets: V1AiImageUpscalerCreateBodyAssets;
12
12
  /**
13
- * The name of image. This value is mainly used for your own identification of the image.
13
+ * Give your image a custom name for easy identification.
14
14
  */
15
15
  name?: string | undefined;
16
16
  /**
@@ -10,7 +10,7 @@ export type CreateRequest = {
10
10
  */
11
11
  assets: V1AiPhotoEditorCreateBodyAssets;
12
12
  /**
13
- * The name of image. This value is mainly used for your own identification of the image.
13
+ * Give your image a custom name for easy identification.
14
14
  */
15
15
  name?: string | undefined;
16
16
  /**
@@ -9,7 +9,7 @@ export type CreateRequest = {
9
9
  */
10
10
  content: string;
11
11
  /**
12
- * The name of image. This value is mainly used for your own identification of the image.
12
+ * Give your image a custom name for easy identification.
13
13
  */
14
14
  name?: string | undefined;
15
15
  style: V1AiQrCodeGeneratorCreateBodyStyle;
@@ -14,7 +14,11 @@ export type CreateRequest = {
14
14
  */
15
15
  endSeconds: number;
16
16
  /**
17
- * The name of image. This value is mainly used for your own identification of the image.
17
+ * Constrains the larger dimension (height or width) of the output video. Allows you to set a lower resolution than your plan's maximum if desired. The value is capped by your plan's max resolution.
18
+ */
19
+ maxResolution?: number | undefined;
20
+ /**
21
+ * Give your image a custom name for easy identification.
18
22
  */
19
23
  name?: string | undefined;
20
24
  /**
@@ -34,6 +38,7 @@ export type CreateRequest = {
34
38
  export type External$CreateRequest = {
35
39
  assets: External$V1AiTalkingPhotoCreateBodyAssets;
36
40
  end_seconds: number;
41
+ max_resolution?: number | undefined;
37
42
  name?: string | undefined;
38
43
  start_seconds: number;
39
44
  style?: External$V1AiTalkingPhotoCreateBodyStyle | undefined;
@@ -45,6 +45,7 @@ const SchemaIn$CreateRequest = z
45
45
  .object({
46
46
  assets: v1_ai_talking_photo_create_body_assets_1.Schemas$V1AiTalkingPhotoCreateBodyAssets.in,
47
47
  end_seconds: z.number(),
48
+ max_resolution: z.number().int().optional(),
48
49
  name: z.string().optional(),
49
50
  start_seconds: z.number(),
50
51
  style: v1_ai_talking_photo_create_body_style_1.Schemas$V1AiTalkingPhotoCreateBodyStyle.in.optional(),
@@ -53,6 +54,7 @@ const SchemaIn$CreateRequest = z
53
54
  return (0, make_api_request_js_1.zodTransform)(obj, {
54
55
  assets: "assets",
55
56
  end_seconds: "endSeconds",
57
+ max_resolution: "maxResolution",
56
58
  name: "name",
57
59
  start_seconds: "startSeconds",
58
60
  style: "style",
@@ -66,6 +68,7 @@ const SchemaOut$CreateRequest = z
66
68
  .object({
67
69
  assets: v1_ai_talking_photo_create_body_assets_1.Schemas$V1AiTalkingPhotoCreateBodyAssets.out,
68
70
  endSeconds: z.number(),
71
+ maxResolution: z.number().int().optional(),
69
72
  name: z.string().optional(),
70
73
  startSeconds: z.number(),
71
74
  style: v1_ai_talking_photo_create_body_style_1.Schemas$V1AiTalkingPhotoCreateBodyStyle.out.optional(),
@@ -74,6 +77,7 @@ const SchemaOut$CreateRequest = z
74
77
  return (0, make_api_request_js_1.zodTransform)(obj, {
75
78
  assets: "assets",
76
79
  endSeconds: "end_seconds",
80
+ maxResolution: "max_resolution",
77
81
  name: "name",
78
82
  startSeconds: "start_seconds",
79
83
  style: "style",
@@ -10,7 +10,7 @@ export type CreateRequest = {
10
10
  */
11
11
  assets: V1AiVoiceClonerCreateBodyAssets;
12
12
  /**
13
- * The name of audio. This value is mainly used for your own identification of the audio.
13
+ * Give your audio a custom name for easy identification.
14
14
  */
15
15
  name?: string | undefined;
16
16
  style: V1AiVoiceClonerCreateBodyStyle;
@@ -5,7 +5,7 @@ import { External$V1AiVoiceGeneratorCreateBodyStyle, V1AiVoiceGeneratorCreateBod
5
5
  */
6
6
  export type CreateRequest = {
7
7
  /**
8
- * The name of audio. This value is mainly used for your own identification of the audio.
8
+ * Give your audio a custom name for easy identification.
9
9
  */
10
10
  name?: string | undefined;
11
11
  /**
@@ -22,7 +22,7 @@ export type CreateRequest = {
22
22
  */
23
23
  height: number;
24
24
  /**
25
- * The name of video. This value is mainly used for your own identification of the video.
25
+ * Give your video a custom name for easy identification.
26
26
  */
27
27
  name?: string | undefined;
28
28
  /**
@@ -36,16 +36,15 @@ export declare class AudioProjectsClient extends CoreResourceClient {
36
36
  /**
37
37
  * Get audio details
38
38
  *
39
- * Get the details of a audio project. The `downloads` field will be empty unless the audio was successfully rendered.
40
- *
41
- * The audio can be one of the following status
42
- * - `draft` - not currently used
43
- * - `queued` - the job is queued and waiting for a GPU
44
- * - `rendering` - the generation is in progress
45
- * - `complete` - the audio is successful created
46
- * - `error` - an error occurred during rendering
47
- * - `canceled` - audio render is canceled by the user
48
- *
39
+ * Check the progress of a audio project. The `downloads` field is populated after a successful render.
40
+ *
41
+ * **Statuses**
42
+ * - `queued` — waiting to start
43
+ * - `rendering` — in progress
44
+ * - `complete` — ready; see `downloads`
45
+ * - `error` — a failure occurred (see `error`)
46
+ * - `canceled` — user canceled
47
+ * - `draft` — not used
49
48
  *
50
49
  * GET /v1/audio-projects/{id}
51
50
  */
@@ -93,16 +93,15 @@ class AudioProjectsClient extends make_api_request_js_1.CoreResourceClient {
93
93
  /**
94
94
  * Get audio details
95
95
  *
96
- * Get the details of a audio project. The `downloads` field will be empty unless the audio was successfully rendered.
97
- *
98
- * The audio can be one of the following status
99
- * - `draft` - not currently used
100
- * - `queued` - the job is queued and waiting for a GPU
101
- * - `rendering` - the generation is in progress
102
- * - `complete` - the audio is successful created
103
- * - `error` - an error occurred during rendering
104
- * - `canceled` - audio render is canceled by the user
96
+ * Check the progress of a audio project. The `downloads` field is populated after a successful render.
105
97
  *
98
+ * **Statuses**
99
+ * - `queued` — waiting to start
100
+ * - `rendering` — in progress
101
+ * - `complete` — ready; see `downloads`
102
+ * - `error` — a failure occurred (see `error`)
103
+ * - `canceled` — user canceled
104
+ * - `draft` — not used
106
105
  *
107
106
  * GET /v1/audio-projects/{id}
108
107
  */
@@ -10,15 +10,15 @@ export type CreateRequest = {
10
10
  */
11
11
  assets: V1AutoSubtitleGeneratorCreateBodyAssets;
12
12
  /**
13
- * The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
13
+ * End time of your clip (seconds). Must be greater than start_seconds.
14
14
  */
15
15
  endSeconds: number;
16
16
  /**
17
- * The name of video. This value is mainly used for your own identification of the video.
17
+ * Give your video a custom name for easy identification.
18
18
  */
19
19
  name?: string | undefined;
20
20
  /**
21
- * The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
21
+ * Start time of your clip (seconds). Must be ≥ 0.
22
22
  */
23
23
  startSeconds: number;
24
24
  /**
@@ -10,7 +10,7 @@ export type CreateRequest = {
10
10
  */
11
11
  assets: V1FaceSwapCreateBodyAssets;
12
12
  /**
13
- * The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
13
+ * End time of your clip (seconds). Must be greater than start_seconds.
14
14
  */
15
15
  endSeconds: number;
16
16
  /**
@@ -24,11 +24,11 @@ export type CreateRequest = {
24
24
  */
25
25
  height?: number | null | undefined;
26
26
  /**
27
- * The name of video. This value is mainly used for your own identification of the video.
27
+ * Give your video a custom name for easy identification.
28
28
  */
29
29
  name?: string | undefined;
30
30
  /**
31
- * The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
31
+ * Start time of your clip (seconds). Must be ≥ 0.
32
32
  */
33
33
  startSeconds: number;
34
34
  /**
@@ -82,10 +82,28 @@ export declare class FaceSwapClient extends CoreResourceClient {
82
82
  /**
83
83
  * Face Swap Video
84
84
  *
85
- * Create a Face Swap 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.
85
+ * **What this API does**
86
86
  *
87
- * Get more information about this mode at our [product page](https://magichour.ai/products/face-swap).
87
+ * Create the same Face Swap you can make in the browser, but programmatically, so you can automate it, run it at scale, or connect it to your own app or workflow.
88
88
  *
89
+ * **Good for**
90
+ * - Automation and batch processing
91
+ * - Adding face swap into apps, pipelines, or tools
92
+ *
93
+ * **How it works (3 steps)**
94
+ * 1) Upload your inputs (video, image, or audio) with [Generate Upload URLs](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls) and copy the `file_path`.
95
+ * 2) Send a request to create a face swap job with the basic fields.
96
+ * 3) Check the job status until it's `complete`, then download the result from `downloads`.
97
+ *
98
+ * **Key options**
99
+ * - Inputs: usually a file, sometimes a YouTube link, depending on project type
100
+ * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
101
+ * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
102
+ *
103
+ * **Cost**
104
+ * Credits are only charged for the frames that actually render. You'll see an estimate when the job is queued, and the final total after it's done.
105
+ *
106
+ * For detailed examples, see the [product page](https://magichour.ai/products/face-swap).
89
107
  *
90
108
  * POST /v1/face-swap
91
109
  */
@@ -136,10 +136,28 @@ class FaceSwapClient extends make_api_request_js_1.CoreResourceClient {
136
136
  /**
137
137
  * Face Swap Video
138
138
  *
139
- * Create a Face Swap 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.
139
+ * **What this API does**
140
140
  *
141
- * Get more information about this mode at our [product page](https://magichour.ai/products/face-swap).
141
+ * Create the same Face Swap you can make in the browser, but programmatically, so you can automate it, run it at scale, or connect it to your own app or workflow.
142
142
  *
143
+ * **Good for**
144
+ * - Automation and batch processing
145
+ * - Adding face swap into apps, pipelines, or tools
146
+ *
147
+ * **How it works (3 steps)**
148
+ * 1) Upload your inputs (video, image, or audio) with [Generate Upload URLs](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls) and copy the `file_path`.
149
+ * 2) Send a request to create a face swap job with the basic fields.
150
+ * 3) Check the job status until it's `complete`, then download the result from `downloads`.
151
+ *
152
+ * **Key options**
153
+ * - Inputs: usually a file, sometimes a YouTube link, depending on project type
154
+ * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
155
+ * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
156
+ *
157
+ * **Cost**
158
+ * Credits are only charged for the frames that actually render. You'll see an estimate when the job is queued, and the final total after it's done.
159
+ *
160
+ * For detailed examples, see the [product page](https://magichour.ai/products/face-swap).
143
161
  *
144
162
  * POST /v1/face-swap
145
163
  */
@@ -9,7 +9,7 @@ export type CreateRequest = {
9
9
  */
10
10
  assets: V1FaceSwapPhotoCreateBodyAssets;
11
11
  /**
12
- * The name of image. This value is mainly used for your own identification of the image.
12
+ * Give your image a custom name for easy identification.
13
13
  */
14
14
  name?: string | undefined;
15
15
  };
@@ -13,14 +13,20 @@ export declare class FilesClient extends CoreResourceClient {
13
13
  * a file path that can be used as input for other Magic Hour API endpoints.
14
14
  * The file type is automatically detected from the file extension.
15
15
  *
16
+ * If a URL (http:// or https://) or an already-uploaded path (api-assets/...)
17
+ * is provided, it will be returned as-is without uploading.
18
+ *
16
19
  * @param file - The file to upload. Can be:
17
- * - **string**: Path to a local file (e.g., "/path/to/image.jpg")
20
+ * - **string**: Path to a local file (e.g., "/path/to/image.jpg"),
21
+ * a URL (e.g., "https://example.com/image.jpg"), or
22
+ * an already-uploaded path (e.g., "api-assets/id/1234.png")
18
23
  * - **Buffer**: File content as buffer (requires extension detection via other means)
19
24
  * - **Readable**: Node.js readable stream (must have a 'path' property)
20
25
  * - **File**: File object (browser environment)
21
26
  *
22
- * @returns The uploaded file's path in Magic Hour's storage system.
23
- * This path can be used as input for other API endpoints.
27
+ * @returns The file path that can be used as input for other API endpoints.
28
+ * For local files, this will be the uploaded path in Magic Hour's storage.
29
+ * For URLs and already-uploaded paths, this will be the input string as-is.
24
30
  *
25
31
  * @throws {Error} If the specified local file doesn't exist.
26
32
  * @throws {Error} If the file type is not supported.
@@ -36,6 +42,10 @@ export declare class FilesClient extends CoreResourceClient {
36
42
  * const filePath = await client.v1.files.uploadFile("/path/to/your/image.jpg");
37
43
  * console.log(`Uploaded file: ${filePath}`);
38
44
  *
45
+ * // URLs are returned as-is (no upload needed)
46
+ * const urlPath = await client.v1.files.uploadFile("https://example.com/image.jpg");
47
+ * console.log(urlPath); // "https://example.com/image.jpg"
48
+ *
39
49
  * // Use the uploaded file in other API calls
40
50
  * const result = await client.v1.aiImageUpscaler.create({
41
51
  * assets: { imageFilePath: filePath },
@@ -54,6 +54,25 @@ const fs = __importStar(require("fs"));
54
54
  const make_api_request_js_1 = require("make-api-request-js");
55
55
  const path = __importStar(require("path"));
56
56
  const stream_1 = require("stream");
57
+ const logger_1 = require("../../../logger");
58
+ /**
59
+ * Check if the given string is a valid HTTP/HTTPS URL.
60
+ */
61
+ function isUrl(str) {
62
+ try {
63
+ const url = new URL(str);
64
+ return url.protocol === "http:" || url.protocol === "https:";
65
+ }
66
+ catch (_a) {
67
+ return false;
68
+ }
69
+ }
70
+ /**
71
+ * Check if the given string is an already-uploaded path (api-assets/).
72
+ */
73
+ function isAlreadyUploaded(str) {
74
+ return str.startsWith("api-assets/");
75
+ }
57
76
  /**
58
77
  * Determine file type and extension from file path or name.
59
78
  */
@@ -144,14 +163,20 @@ class FilesClient extends make_api_request_js_1.CoreResourceClient {
144
163
  * a file path that can be used as input for other Magic Hour API endpoints.
145
164
  * The file type is automatically detected from the file extension.
146
165
  *
166
+ * If a URL (http:// or https://) or an already-uploaded path (api-assets/...)
167
+ * is provided, it will be returned as-is without uploading.
168
+ *
147
169
  * @param file - The file to upload. Can be:
148
- * - **string**: Path to a local file (e.g., "/path/to/image.jpg")
170
+ * - **string**: Path to a local file (e.g., "/path/to/image.jpg"),
171
+ * a URL (e.g., "https://example.com/image.jpg"), or
172
+ * an already-uploaded path (e.g., "api-assets/id/1234.png")
149
173
  * - **Buffer**: File content as buffer (requires extension detection via other means)
150
174
  * - **Readable**: Node.js readable stream (must have a 'path' property)
151
175
  * - **File**: File object (browser environment)
152
176
  *
153
- * @returns The uploaded file's path in Magic Hour's storage system.
154
- * This path can be used as input for other API endpoints.
177
+ * @returns The file path that can be used as input for other API endpoints.
178
+ * For local files, this will be the uploaded path in Magic Hour's storage.
179
+ * For URLs and already-uploaded paths, this will be the input string as-is.
155
180
  *
156
181
  * @throws {Error} If the specified local file doesn't exist.
157
182
  * @throws {Error} If the file type is not supported.
@@ -167,6 +192,10 @@ class FilesClient extends make_api_request_js_1.CoreResourceClient {
167
192
  * const filePath = await client.v1.files.uploadFile("/path/to/your/image.jpg");
168
193
  * console.log(`Uploaded file: ${filePath}`);
169
194
  *
195
+ * // URLs are returned as-is (no upload needed)
196
+ * const urlPath = await client.v1.files.uploadFile("https://example.com/image.jpg");
197
+ * console.log(urlPath); // "https://example.com/image.jpg"
198
+ *
170
199
  * // Use the uploaded file in other API calls
171
200
  * const result = await client.v1.aiImageUpscaler.create({
172
201
  * assets: { imageFilePath: filePath },
@@ -177,7 +206,23 @@ class FilesClient extends make_api_request_js_1.CoreResourceClient {
177
206
  uploadFile(file) {
178
207
  return __awaiter(this, void 0, void 0, function* () {
179
208
  var _a, e_1, _b, _c;
209
+ const logger = (0, logger_1.getLogger)();
210
+ // If the input is a URL or already-uploaded path, return it as-is
211
+ if (typeof file === "string") {
212
+ if (isUrl(file)) {
213
+ logger.debug(`Skipping upload for ${file} since it is a valid URL`);
214
+ return file;
215
+ }
216
+ else if (isAlreadyUploaded(file)) {
217
+ logger.debug(`Skipping upload for ${file} since it is a valid already-uploaded path`);
218
+ return file;
219
+ }
220
+ else {
221
+ logger.debug(`Processing file input for upload ${file} as a local file`);
222
+ }
223
+ }
180
224
  const { filePath, fileData, fileType, extension } = processFileInput(file);
225
+ logger.debug(`File processed: type=${fileType}, extension=${extension}, source=${filePath ? "path" : "data"}`);
181
226
  // Create upload URL
182
227
  const response = yield this.uploadUrls.create({
183
228
  items: [
@@ -194,14 +239,17 @@ class FilesClient extends make_api_request_js_1.CoreResourceClient {
194
239
  if (!uploadInfo) {
195
240
  throw new Error("Upload info is missing from server response");
196
241
  }
242
+ logger.debug(`Received upload URL, target path: ${uploadInfo.filePath}`);
197
243
  // Prepare file content
198
244
  let content;
199
245
  if (filePath) {
200
246
  content = fs.readFileSync(filePath);
247
+ logger.debug(`Read ${content.length} bytes from local file: ${filePath}`);
201
248
  }
202
249
  else if (fileData) {
203
250
  if (Buffer.isBuffer(fileData)) {
204
251
  content = fileData;
252
+ logger.debug(`Using buffer data: ${content.length} bytes`);
205
253
  }
206
254
  else if (fileData instanceof stream_1.Readable) {
207
255
  // For streams, read all data into buffer
@@ -222,11 +270,13 @@ class FilesClient extends make_api_request_js_1.CoreResourceClient {
222
270
  finally { if (e_1) throw e_1.error; }
223
271
  }
224
272
  content = Buffer.concat(chunks);
273
+ logger.debug(`Read ${content.length} bytes from stream`);
225
274
  }
226
275
  else if (typeof File !== "undefined" && fileData instanceof File) {
227
276
  // File object - convert to buffer
228
277
  const arrayBuffer = yield fileData.arrayBuffer();
229
278
  content = Buffer.from(arrayBuffer);
279
+ logger.debug(`Read ${content.length} bytes from File object: ${fileData.name}`);
230
280
  }
231
281
  else {
232
282
  throw new Error("Unsupported file data type");
@@ -246,6 +296,7 @@ class FilesClient extends make_api_request_js_1.CoreResourceClient {
246
296
  if (!uploadResponse.ok) {
247
297
  throw new Error(`Upload failed with status ${uploadResponse.status}: ${uploadResponse.statusText}`);
248
298
  }
299
+ logger.debug(`Upload complete: ${uploadInfo.filePath}`);
249
300
  return uploadInfo.filePath;
250
301
  });
251
302
  }
@@ -100,6 +100,51 @@ describe("FilesClient.uploadFile", () => {
100
100
  mockFs.existsSync.mockReturnValue(true);
101
101
  mockFs.readFileSync.mockReturnValue(Buffer.from("mock file content"));
102
102
  });
103
+ describe("URL and already-uploaded path handling", () => {
104
+ test("should return HTTP URL as-is without uploading", () => __awaiter(void 0, void 0, void 0, function* () {
105
+ const url = "http://example.com/image.jpg";
106
+ const createSpy = jest.spyOn(client.v1.files.uploadUrls, "create");
107
+ const result = yield client.v1.files.uploadFile(url);
108
+ expect(result).toBe(url);
109
+ expect(createSpy).not.toHaveBeenCalled();
110
+ expect(mockFs.existsSync).not.toHaveBeenCalled();
111
+ createSpy.mockRestore();
112
+ }));
113
+ test("should return HTTPS URL as-is without uploading", () => __awaiter(void 0, void 0, void 0, function* () {
114
+ const url = "https://example.com/path/to/video.mp4";
115
+ const createSpy = jest.spyOn(client.v1.files.uploadUrls, "create");
116
+ const result = yield client.v1.files.uploadFile(url);
117
+ expect(result).toBe(url);
118
+ expect(createSpy).not.toHaveBeenCalled();
119
+ expect(mockFs.existsSync).not.toHaveBeenCalled();
120
+ createSpy.mockRestore();
121
+ }));
122
+ test("should return already-uploaded api-assets path as-is without uploading", () => __awaiter(void 0, void 0, void 0, function* () {
123
+ const apiAssetsPath = "api-assets/12345/image.jpg";
124
+ const createSpy = jest.spyOn(client.v1.files.uploadUrls, "create");
125
+ const result = yield client.v1.files.uploadFile(apiAssetsPath);
126
+ expect(result).toBe(apiAssetsPath);
127
+ expect(createSpy).not.toHaveBeenCalled();
128
+ expect(mockFs.existsSync).not.toHaveBeenCalled();
129
+ createSpy.mockRestore();
130
+ }));
131
+ test("should handle URLs with query parameters", () => __awaiter(void 0, void 0, void 0, function* () {
132
+ const url = "https://example.com/image.jpg?token=abc123&expires=12345";
133
+ const createSpy = jest.spyOn(client.v1.files.uploadUrls, "create");
134
+ const result = yield client.v1.files.uploadFile(url);
135
+ expect(result).toBe(url);
136
+ expect(createSpy).not.toHaveBeenCalled();
137
+ createSpy.mockRestore();
138
+ }));
139
+ test("should upload local file paths that look similar to URLs but are not", () => __awaiter(void 0, void 0, void 0, function* () {
140
+ const filePath = "/http/example.com/image.jpg";
141
+ const createSpy = jest.spyOn(client.v1.files.uploadUrls, "create");
142
+ const result = yield client.v1.files.uploadFile(filePath);
143
+ expect(result).toBe("api-assets/12345/image.jpg");
144
+ expect(createSpy).toHaveBeenCalled();
145
+ createSpy.mockRestore();
146
+ }));
147
+ });
103
148
  describe("File type detection", () => {
104
149
  // MSW handles the uploadUrls.create call automatically
105
150
  test("should detect video file types correctly", () => __awaiter(void 0, void 0, void 0, function* () {
@@ -9,7 +9,7 @@ export type CreateRequest = {
9
9
  */
10
10
  assets: V1ImageBackgroundRemoverCreateBodyAssets;
11
11
  /**
12
- * The name of image. This value is mainly used for your own identification of the image.
12
+ * Give your image a custom name for easy identification.
13
13
  */
14
14
  name?: string | undefined;
15
15
  };