magic-hour 0.43.1 → 0.45.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 (167) hide show
  1. package/README.md +82 -77
  2. package/dist/core/api-error.d.ts +6 -0
  3. package/dist/core/api-error.js +11 -0
  4. package/dist/core/api-promise.d.ts +28 -0
  5. package/dist/core/api-promise.js +252 -0
  6. package/dist/core/auth.d.ts +76 -0
  7. package/dist/core/auth.js +232 -0
  8. package/dist/core/binary-response.d.ts +6 -0
  9. package/dist/core/binary-response.js +10 -0
  10. package/dist/core/content-type.d.ts +4 -0
  11. package/dist/core/content-type.js +12 -0
  12. package/dist/core/core-client.d.ts +58 -0
  13. package/dist/core/core-client.js +168 -0
  14. package/dist/core/form-data.d.ts +26 -0
  15. package/dist/core/form-data.js +83 -0
  16. package/dist/core/index.d.ts +9 -0
  17. package/dist/core/index.js +28 -0
  18. package/dist/core/logger.d.ts +48 -0
  19. package/dist/core/logger.js +82 -0
  20. package/dist/core/query.d.ts +8 -0
  21. package/dist/core/query.js +77 -0
  22. package/dist/core/runtime.d.ts +4 -0
  23. package/dist/core/runtime.js +20 -0
  24. package/dist/core/zod.d.ts +13 -0
  25. package/dist/core/zod.js +60 -0
  26. package/dist/environment.d.ts +1 -1
  27. package/dist/environment.js +1 -1
  28. package/dist/examples/logging-example.d.ts +10 -0
  29. package/dist/examples/logging-example.js +137 -0
  30. package/dist/logging-client.d.ts +39 -0
  31. package/dist/logging-client.js +116 -0
  32. package/dist/resources/v1/ai-clothes-changer/request-types.d.ts +1 -1
  33. package/dist/resources/v1/ai-face-editor/request-types.d.ts +1 -1
  34. package/dist/resources/v1/ai-gif-generator/request-types.d.ts +1 -1
  35. package/dist/resources/v1/ai-headshot-generator/request-types.d.ts +1 -1
  36. package/dist/resources/v1/ai-image-editor/request-types.d.ts +1 -1
  37. package/dist/resources/v1/ai-image-editor/resource-client.d.ts +1 -1
  38. package/dist/resources/v1/ai-image-editor/resource-client.js +1 -1
  39. package/dist/resources/v1/ai-image-generator/request-types.d.ts +1 -1
  40. package/dist/resources/v1/ai-image-upscaler/request-types.d.ts +1 -1
  41. package/dist/resources/v1/ai-photo-editor/request-types.d.ts +1 -1
  42. package/dist/resources/v1/ai-qr-code-generator/request-types.d.ts +1 -1
  43. package/dist/resources/v1/ai-talking-photo/request-types.d.ts +1 -1
  44. package/dist/resources/v1/ai-voice-cloner/index.d.ts +2 -0
  45. package/dist/resources/v1/ai-voice-cloner/index.js +5 -0
  46. package/dist/resources/v1/ai-voice-cloner/request-types.d.ts +31 -0
  47. package/dist/resources/v1/ai-voice-cloner/request-types.js +77 -0
  48. package/dist/resources/v1/ai-voice-cloner/resource-client.d.ts +55 -0
  49. package/dist/resources/v1/ai-voice-cloner/resource-client.js +99 -0
  50. package/dist/resources/v1/ai-voice-generator/request-types.d.ts +1 -1
  51. package/dist/resources/v1/animation/request-types.d.ts +1 -1
  52. package/dist/resources/v1/audio-projects/resource-client.d.ts +9 -10
  53. package/dist/resources/v1/audio-projects/resource-client.js +8 -9
  54. package/dist/resources/v1/auto-subtitle-generator/request-types.d.ts +3 -3
  55. package/dist/resources/v1/face-swap/request-types.d.ts +3 -3
  56. package/dist/resources/v1/face-swap/resource-client.d.ts +20 -2
  57. package/dist/resources/v1/face-swap/resource-client.js +20 -2
  58. package/dist/resources/v1/face-swap-photo/request-types.d.ts +1 -1
  59. package/dist/resources/v1/files/resource-client.d.ts +13 -3
  60. package/dist/resources/v1/files/resource-client.js +54 -3
  61. package/dist/resources/v1/files/resource-client.test.js +45 -0
  62. package/dist/resources/v1/image-background-remover/request-types.d.ts +1 -1
  63. package/dist/resources/v1/image-projects/resource-client.d.ts +9 -10
  64. package/dist/resources/v1/image-projects/resource-client.js +8 -9
  65. package/dist/resources/v1/image-to-video/request-types.d.ts +1 -1
  66. package/dist/resources/v1/image-to-video/resource-client.d.ts +20 -2
  67. package/dist/resources/v1/image-to-video/resource-client.js +20 -2
  68. package/dist/resources/v1/index.d.ts +1 -0
  69. package/dist/resources/v1/index.js +2 -1
  70. package/dist/resources/v1/lip-sync/request-types.d.ts +3 -3
  71. package/dist/resources/v1/lip-sync/resource-client.d.ts +20 -2
  72. package/dist/resources/v1/lip-sync/resource-client.js +20 -2
  73. package/dist/resources/v1/photo-colorizer/request-types.d.ts +1 -1
  74. package/dist/resources/v1/photo-colorizer/resource-client.d.ts +1 -1
  75. package/dist/resources/v1/photo-colorizer/resource-client.js +1 -1
  76. package/dist/resources/v1/resource-client.d.ts +3 -0
  77. package/dist/resources/v1/resource-client.js +6 -0
  78. package/dist/resources/v1/text-to-video/request-types.d.ts +1 -1
  79. package/dist/resources/v1/text-to-video/resource-client.d.ts +20 -2
  80. package/dist/resources/v1/text-to-video/resource-client.js +20 -2
  81. package/dist/resources/v1/video-projects/resource-client.d.ts +9 -10
  82. package/dist/resources/v1/video-projects/resource-client.js +8 -9
  83. package/dist/resources/v1/video-to-video/request-types.d.ts +3 -3
  84. package/dist/resources/v1/video-to-video/resource-client.d.ts +20 -2
  85. package/dist/resources/v1/video-to-video/resource-client.js +20 -2
  86. package/dist/types/index.d.ts +4 -0
  87. package/dist/types/v1-ai-clothes-changer-create-body-assets-garment-type-enum.d.ts +6 -2
  88. package/dist/types/v1-ai-clothes-changer-create-body-assets.d.ts +9 -5
  89. package/dist/types/v1-ai-clothes-changer-create-body-assets.js +6 -2
  90. package/dist/types/v1-ai-clothes-changer-create-body.d.ts +1 -1
  91. package/dist/types/v1-ai-clothes-changer-create-response.d.ts +1 -1
  92. package/dist/types/v1-ai-face-editor-create-body-assets.d.ts +1 -1
  93. package/dist/types/v1-ai-face-editor-create-body.d.ts +1 -1
  94. package/dist/types/v1-ai-face-editor-create-response.d.ts +1 -1
  95. package/dist/types/v1-ai-gif-generator-create-body.d.ts +1 -1
  96. package/dist/types/v1-ai-gif-generator-create-response.d.ts +1 -1
  97. package/dist/types/v1-ai-headshot-generator-create-body-assets.d.ts +1 -1
  98. package/dist/types/v1-ai-headshot-generator-create-body.d.ts +1 -1
  99. package/dist/types/v1-ai-headshot-generator-create-response.d.ts +1 -1
  100. package/dist/types/v1-ai-image-editor-create-body-assets.d.ts +2 -2
  101. package/dist/types/v1-ai-image-editor-create-body.d.ts +1 -1
  102. package/dist/types/v1-ai-image-editor-create-response.d.ts +1 -1
  103. package/dist/types/v1-ai-image-generator-create-body.d.ts +1 -1
  104. package/dist/types/v1-ai-image-generator-create-response.d.ts +1 -1
  105. package/dist/types/v1-ai-image-upscaler-create-body-assets.d.ts +1 -1
  106. package/dist/types/v1-ai-image-upscaler-create-body.d.ts +1 -1
  107. package/dist/types/v1-ai-image-upscaler-create-response.d.ts +1 -1
  108. package/dist/types/v1-ai-meme-generator-create-response.d.ts +1 -1
  109. package/dist/types/v1-ai-photo-editor-create-body-assets.d.ts +1 -1
  110. package/dist/types/v1-ai-photo-editor-create-body.d.ts +1 -1
  111. package/dist/types/v1-ai-photo-editor-create-response.d.ts +1 -1
  112. package/dist/types/v1-ai-qr-code-generator-create-body.d.ts +1 -1
  113. package/dist/types/v1-ai-qr-code-generator-create-response.d.ts +1 -1
  114. package/dist/types/v1-ai-talking-photo-create-body-assets.d.ts +2 -2
  115. package/dist/types/v1-ai-talking-photo-create-body.d.ts +1 -1
  116. package/dist/types/v1-ai-talking-photo-create-response.d.ts +1 -1
  117. package/dist/types/v1-ai-voice-cloner-create-body-assets.d.ts +27 -0
  118. package/dist/types/v1-ai-voice-cloner-create-body-assets.js +67 -0
  119. package/dist/types/v1-ai-voice-cloner-create-body-style.d.ts +22 -0
  120. package/dist/types/v1-ai-voice-cloner-create-body-style.js +67 -0
  121. package/dist/types/v1-ai-voice-cloner-create-body.d.ts +31 -0
  122. package/dist/types/v1-ai-voice-cloner-create-body.js +77 -0
  123. package/dist/types/v1-ai-voice-cloner-create-response.d.ts +29 -0
  124. package/dist/types/v1-ai-voice-cloner-create-response.js +71 -0
  125. package/dist/types/v1-ai-voice-generator-create-body.d.ts +1 -1
  126. package/dist/types/v1-ai-voice-generator-create-response.d.ts +1 -1
  127. package/dist/types/v1-animation-create-body-assets.d.ts +2 -2
  128. package/dist/types/v1-animation-create-body.d.ts +1 -1
  129. package/dist/types/v1-animation-create-response.d.ts +1 -1
  130. package/dist/types/v1-audio-projects-get-response.d.ts +2 -2
  131. package/dist/types/v1-auto-subtitle-generator-create-body-assets.d.ts +1 -1
  132. package/dist/types/v1-auto-subtitle-generator-create-body.d.ts +3 -3
  133. package/dist/types/v1-auto-subtitle-generator-create-response.d.ts +1 -1
  134. package/dist/types/v1-face-detection-create-body-assets.d.ts +1 -1
  135. package/dist/types/v1-face-swap-create-body-assets-face-mappings-item.d.ts +1 -1
  136. package/dist/types/v1-face-swap-create-body-assets-face-swap-mode-enum.d.ts +3 -3
  137. package/dist/types/v1-face-swap-create-body-assets-video-source-enum.d.ts +1 -1
  138. package/dist/types/v1-face-swap-create-body-assets.d.ts +10 -7
  139. package/dist/types/v1-face-swap-create-body.d.ts +3 -3
  140. package/dist/types/v1-face-swap-create-response.d.ts +1 -1
  141. package/dist/types/v1-face-swap-photo-create-body-assets-face-mappings-item.d.ts +1 -1
  142. package/dist/types/v1-face-swap-photo-create-body-assets-face-swap-mode-enum.d.ts +3 -3
  143. package/dist/types/v1-face-swap-photo-create-body-assets.d.ts +5 -5
  144. package/dist/types/v1-face-swap-photo-create-body.d.ts +1 -1
  145. package/dist/types/v1-face-swap-photo-create-response.d.ts +1 -1
  146. package/dist/types/v1-image-background-remover-create-body-assets.d.ts +2 -2
  147. package/dist/types/v1-image-background-remover-create-body.d.ts +1 -1
  148. package/dist/types/v1-image-background-remover-create-response.d.ts +1 -1
  149. package/dist/types/v1-image-projects-get-response.d.ts +2 -2
  150. package/dist/types/v1-image-to-video-create-body-assets.d.ts +1 -1
  151. package/dist/types/v1-image-to-video-create-body.d.ts +1 -1
  152. package/dist/types/v1-image-to-video-create-response.d.ts +1 -1
  153. package/dist/types/v1-lip-sync-create-body-assets-video-source-enum.d.ts +1 -1
  154. package/dist/types/v1-lip-sync-create-body-assets.d.ts +7 -4
  155. package/dist/types/v1-lip-sync-create-body.d.ts +3 -3
  156. package/dist/types/v1-lip-sync-create-response.d.ts +1 -1
  157. package/dist/types/v1-photo-colorizer-create-body-assets.d.ts +1 -1
  158. package/dist/types/v1-photo-colorizer-create-body.d.ts +1 -1
  159. package/dist/types/v1-photo-colorizer-create-response.d.ts +1 -1
  160. package/dist/types/v1-text-to-video-create-body.d.ts +1 -1
  161. package/dist/types/v1-text-to-video-create-response.d.ts +1 -1
  162. package/dist/types/v1-video-projects-get-response.d.ts +4 -4
  163. package/dist/types/v1-video-to-video-create-body-assets-video-source-enum.d.ts +1 -1
  164. package/dist/types/v1-video-to-video-create-body-assets.d.ts +6 -3
  165. package/dist/types/v1-video-to-video-create-body.d.ts +3 -3
  166. package/dist/types/v1-video-to-video-create-response.d.ts +1 -1
  167. package/package.json +2 -2
@@ -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,7 @@ 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
+ * Give your image a custom name for easy identification.
18
18
  */
19
19
  name?: string | undefined;
20
20
  /**
@@ -0,0 +1,2 @@
1
+ export { CreateRequest } from "./request-types";
2
+ export { AiVoiceClonerClient } from "./resource-client";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiVoiceClonerClient = void 0;
4
+ var resource_client_1 = require("./resource-client");
5
+ Object.defineProperty(exports, "AiVoiceClonerClient", { enumerable: true, get: function () { return resource_client_1.AiVoiceClonerClient; } });
@@ -0,0 +1,31 @@
1
+ import * as z from "zod";
2
+ import { External$V1AiVoiceClonerCreateBodyAssets, V1AiVoiceClonerCreateBodyAssets } from "../../../types/v1-ai-voice-cloner-create-body-assets";
3
+ import { External$V1AiVoiceClonerCreateBodyStyle, V1AiVoiceClonerCreateBodyStyle } from "../../../types/v1-ai-voice-cloner-create-body-style";
4
+ /**
5
+ * CreateRequest
6
+ */
7
+ export type CreateRequest = {
8
+ /**
9
+ * Provide the assets for voice cloning.
10
+ */
11
+ assets: V1AiVoiceClonerCreateBodyAssets;
12
+ /**
13
+ * Give your audio a custom name for easy identification.
14
+ */
15
+ name?: string | undefined;
16
+ style: V1AiVoiceClonerCreateBodyStyle;
17
+ };
18
+ /**
19
+ * @internal
20
+ * CreateRequest without any key transformation, this is what
21
+ * we expect to come in as network data
22
+ */
23
+ export type External$CreateRequest = {
24
+ assets: External$V1AiVoiceClonerCreateBodyAssets;
25
+ name?: string | undefined;
26
+ style: External$V1AiVoiceClonerCreateBodyStyle;
27
+ };
28
+ export declare const Schemas$CreateRequest: {
29
+ in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
30
+ out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
31
+ };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Schemas$CreateRequest = void 0;
37
+ const make_api_request_js_1 = require("make-api-request-js");
38
+ const z = __importStar(require("zod"));
39
+ const v1_ai_voice_cloner_create_body_assets_1 = require("../../../types/v1-ai-voice-cloner-create-body-assets");
40
+ const v1_ai_voice_cloner_create_body_style_1 = require("../../../types/v1-ai-voice-cloner-create-body-style");
41
+ /**
42
+ * Takes network data, validates it, and transforms keys to match typescript object CreateRequest
43
+ */
44
+ const SchemaIn$CreateRequest = z
45
+ .object({
46
+ assets: v1_ai_voice_cloner_create_body_assets_1.Schemas$V1AiVoiceClonerCreateBodyAssets.in,
47
+ name: z.string().optional(),
48
+ style: v1_ai_voice_cloner_create_body_style_1.Schemas$V1AiVoiceClonerCreateBodyStyle.in,
49
+ })
50
+ .transform((obj) => {
51
+ return (0, make_api_request_js_1.zodTransform)(obj, {
52
+ assets: "assets",
53
+ name: "name",
54
+ style: "style",
55
+ });
56
+ });
57
+ /**
58
+ * @internal
59
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$CreateRequest
60
+ */
61
+ const SchemaOut$CreateRequest = z
62
+ .object({
63
+ assets: v1_ai_voice_cloner_create_body_assets_1.Schemas$V1AiVoiceClonerCreateBodyAssets.out,
64
+ name: z.string().optional(),
65
+ style: v1_ai_voice_cloner_create_body_style_1.Schemas$V1AiVoiceClonerCreateBodyStyle.out,
66
+ })
67
+ .transform((obj) => {
68
+ return (0, make_api_request_js_1.zodTransform)(obj, {
69
+ assets: "assets",
70
+ name: "name",
71
+ style: "style",
72
+ });
73
+ });
74
+ exports.Schemas$CreateRequest = {
75
+ in: SchemaIn$CreateRequest,
76
+ out: SchemaOut$CreateRequest,
77
+ };
@@ -0,0 +1,55 @@
1
+ import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
2
+ import { types } from "../../../index.js";
3
+ import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
4
+ import * as requests from "../../../resources/v1/ai-voice-cloner/request-types";
5
+ type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
6
+ /**
7
+ * The audio used to clone the voice. This value is either
8
+ * - a direct URL to the audio file
9
+ * - a path to a local file
10
+ *
11
+ * Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
12
+ */
13
+ audioFilePath: string;
14
+ }>;
15
+ export declare class AiVoiceClonerClient extends CoreResourceClient {
16
+ constructor(coreClient: CoreClient, opts: ResourceClientOptions);
17
+ /**
18
+ * AI Voice Cloner
19
+ *
20
+ * Clone a voice from an audio sample and generate speech.
21
+ *
22
+ * This method provides a convenient way to create a request and automatically wait for completion and download outputs.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * import Client from "../../../index.js";
27
+ *
28
+ * const client = new Client({ token: process.env["API_TOKEN"]!! });
29
+ * const res = await client.v1.aiVoiceCloner.generate(
30
+ * {
31
+ * assets: { audioFilePath: "/path/to/audio.mp3" },
32
+ * name: "Voice Cloner audio",
33
+ * style: { prompt: "Hello, how are you?" },
34
+ * },
35
+ * {
36
+ * waitForCompletion: true,
37
+ * downloadOutputs: true,
38
+ * downloadDirectory: "outputs",
39
+ * },
40
+ * );
41
+ * ```
42
+ */
43
+ generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../image-projects/resource-client").V1ImageProjectsGetResponseWithDownloads>;
44
+ /**
45
+ * AI Voice Cloner
46
+ *
47
+ * Clone a voice from an audio sample and generate speech.
48
+ * * Each character costs 0.05 credits.
49
+ * * The cost is rounded up to the nearest whole number
50
+ *
51
+ * POST /v1/ai-voice-cloner
52
+ */
53
+ create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiVoiceClonerCreateResponse>;
54
+ }
55
+ export {};
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.AiVoiceClonerClient = void 0;
24
+ const make_api_request_js_1 = require("make-api-request-js");
25
+ const logger_1 = require("../../../logger");
26
+ const files_1 = require("../../../resources/v1/files");
27
+ const image_projects_1 = require("../../../resources/v1/image-projects");
28
+ const v1_ai_voice_cloner_create_body_1 = require("../../../types/v1-ai-voice-cloner-create-body");
29
+ const v1_ai_voice_cloner_create_response_1 = require("../../../types/v1-ai-voice-cloner-create-response");
30
+ class AiVoiceClonerClient extends make_api_request_js_1.CoreResourceClient {
31
+ constructor(coreClient, opts) {
32
+ super(coreClient, opts);
33
+ }
34
+ /**
35
+ * AI Voice Cloner
36
+ *
37
+ * Clone a voice from an audio sample and generate speech.
38
+ *
39
+ * This method provides a convenient way to create a request and automatically wait for completion and download outputs.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import Client from "../../../index.js";
44
+ *
45
+ * const client = new Client({ token: process.env["API_TOKEN"]!! });
46
+ * const res = await client.v1.aiVoiceCloner.generate(
47
+ * {
48
+ * assets: { audioFilePath: "/path/to/audio.mp3" },
49
+ * name: "Voice Cloner audio",
50
+ * style: { prompt: "Hello, how are you?" },
51
+ * },
52
+ * {
53
+ * waitForCompletion: true,
54
+ * downloadOutputs: true,
55
+ * downloadDirectory: "outputs",
56
+ * },
57
+ * );
58
+ * ```
59
+ */
60
+ generate(request_1) {
61
+ return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
62
+ const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
63
+ const fileClient = new files_1.FilesClient(this._client, this._opts);
64
+ const _a = request.assets, { audioFilePath } = _a, restAssets = __rest(_a, ["audioFilePath"]);
65
+ (0, logger_1.getLogger)().debug(`Uploading file ${audioFilePath} to Magic Hour's storage`);
66
+ const uploadedAudioFilePath = yield fileClient.uploadFile(audioFilePath);
67
+ (0, logger_1.getLogger)().info(`Uploaded file ${audioFilePath} to Magic Hour's storage as ${uploadedAudioFilePath}`);
68
+ const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { audioFilePath: uploadedAudioFilePath }) }), createOpts);
69
+ (0, logger_1.getLogger)().info(`Created AiVoiceClonerClient project ${createResponse.id}`);
70
+ const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
71
+ (0, logger_1.getLogger)().debug(`Checking result for AiVoiceClonerClient project ${createResponse.id}`);
72
+ const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
73
+ downloadOutputs,
74
+ downloadDirectory }, createOpts));
75
+ return result;
76
+ });
77
+ }
78
+ /**
79
+ * AI Voice Cloner
80
+ *
81
+ * Clone a voice from an audio sample and generate speech.
82
+ * * Each character costs 0.05 credits.
83
+ * * The cost is rounded up to the nearest whole number
84
+ *
85
+ * POST /v1/ai-voice-cloner
86
+ */
87
+ create(request, opts) {
88
+ return this._client.makeRequest({
89
+ method: "post",
90
+ path: "/v1/ai-voice-cloner",
91
+ auth: ["bearerAuth"],
92
+ contentType: "application/json",
93
+ body: v1_ai_voice_cloner_create_body_1.Schemas$V1AiVoiceClonerCreateBody.out.parse(request),
94
+ responseSchema: v1_ai_voice_cloner_create_response_1.Schemas$V1AiVoiceClonerCreateResponse.in,
95
+ opts,
96
+ });
97
+ }
98
+ }
99
+ exports.AiVoiceClonerClient = AiVoiceClonerClient;
@@ -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 },