magic-hour 0.83.1 → 0.85.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 (100) hide show
  1. package/README.md +37 -0
  2. package/dist/environment.d.ts +1 -1
  3. package/dist/environment.js +1 -1
  4. package/dist/helpers/download-error.d.ts +16 -0
  5. package/dist/helpers/download-error.js +15 -0
  6. package/dist/helpers/download.js +22 -2
  7. package/dist/resources/v1/ai-music-generator/index.d.ts +2 -0
  8. package/dist/resources/v1/ai-music-generator/index.js +5 -0
  9. package/dist/resources/v1/ai-music-generator/request-types.d.ts +32 -0
  10. package/dist/resources/v1/ai-music-generator/request-types.js +78 -0
  11. package/dist/resources/v1/ai-music-generator/resource-client.d.ts +31 -0
  12. package/dist/resources/v1/ai-music-generator/resource-client.js +78 -0
  13. package/dist/resources/v1/ai-talking-photo/request-types.d.ts +10 -1
  14. package/dist/resources/v1/ai-talking-photo/request-types.js +4 -0
  15. package/dist/resources/v1/ai-ugc-ad/index.d.ts +2 -0
  16. package/dist/resources/v1/ai-ugc-ad/index.js +5 -0
  17. package/dist/resources/v1/ai-ugc-ad/request-types.d.ts +50 -0
  18. package/dist/resources/v1/ai-ugc-ad/request-types.js +86 -0
  19. package/dist/resources/v1/ai-ugc-ad/resource-client.d.ts +41 -0
  20. package/dist/resources/v1/ai-ugc-ad/resource-client.js +81 -0
  21. package/dist/resources/v1/ai-video-editor/resource-client.d.ts +2 -2
  22. package/dist/resources/v1/ai-video-editor/resource-client.js +2 -2
  23. package/dist/resources/v1/ai-video-translator/resource-client.d.ts +2 -2
  24. package/dist/resources/v1/ai-video-translator/resource-client.js +2 -2
  25. package/dist/resources/v1/ai-video-upscaler/index.d.ts +2 -0
  26. package/dist/resources/v1/ai-video-upscaler/index.js +5 -0
  27. package/dist/resources/v1/ai-video-upscaler/request-types.d.ts +43 -0
  28. package/dist/resources/v1/ai-video-upscaler/request-types.js +84 -0
  29. package/dist/resources/v1/ai-video-upscaler/resource-client.d.ts +60 -0
  30. package/dist/resources/v1/ai-video-upscaler/resource-client.js +103 -0
  31. package/dist/resources/v1/audio-projects/resource-client.d.ts +5 -0
  32. package/dist/resources/v1/audio-projects/resource-client.js +14 -2
  33. package/dist/resources/v1/audio-to-video/resource-client.d.ts +2 -2
  34. package/dist/resources/v1/audio-to-video/resource-client.js +2 -2
  35. package/dist/resources/v1/character-replace/resource-client.d.ts +2 -2
  36. package/dist/resources/v1/character-replace/resource-client.js +2 -2
  37. package/dist/resources/v1/face-detection/resource-client.d.ts +5 -0
  38. package/dist/resources/v1/face-detection/resource-client.js +17 -5
  39. package/dist/resources/v1/face-swap/resource-client.d.ts +2 -2
  40. package/dist/resources/v1/face-swap/resource-client.js +2 -2
  41. package/dist/resources/v1/image-projects/resource-client.d.ts +5 -0
  42. package/dist/resources/v1/image-projects/resource-client.js +14 -2
  43. package/dist/resources/v1/image-to-video/request-types.d.ts +6 -2
  44. package/dist/resources/v1/image-to-video/request-types.js +2 -0
  45. package/dist/resources/v1/image-to-video/resource-client.d.ts +2 -2
  46. package/dist/resources/v1/image-to-video/resource-client.js +2 -2
  47. package/dist/resources/v1/index.d.ts +3 -0
  48. package/dist/resources/v1/index.js +4 -1
  49. package/dist/resources/v1/lip-sync/resource-client.d.ts +2 -2
  50. package/dist/resources/v1/lip-sync/resource-client.js +2 -2
  51. package/dist/resources/v1/resource-client.d.ts +9 -0
  52. package/dist/resources/v1/resource-client.js +17 -0
  53. package/dist/resources/v1/text-to-video/request-types.d.ts +11 -3
  54. package/dist/resources/v1/text-to-video/request-types.js +2 -0
  55. package/dist/resources/v1/text-to-video/resource-client.d.ts +2 -2
  56. package/dist/resources/v1/text-to-video/resource-client.js +2 -2
  57. package/dist/resources/v1/video-projects/resource-client.d.ts +5 -0
  58. package/dist/resources/v1/video-projects/resource-client.js +14 -2
  59. package/dist/resources/v1/video-to-video/resource-client.d.ts +2 -2
  60. package/dist/resources/v1/video-to-video/resource-client.js +2 -2
  61. package/dist/types/index.d.ts +13 -0
  62. package/dist/types/v1-ai-music-generator-create-body-style.d.ts +34 -0
  63. package/dist/types/v1-ai-music-generator-create-body-style.js +77 -0
  64. package/dist/types/v1-ai-music-generator-create-body.d.ts +32 -0
  65. package/dist/types/v1-ai-music-generator-create-body.js +78 -0
  66. package/dist/types/v1-ai-music-generator-create-response.d.ts +29 -0
  67. package/dist/types/v1-ai-music-generator-create-response.js +71 -0
  68. package/dist/types/v1-ai-talking-photo-create-body-resolution-enum.d.ts +4 -0
  69. package/dist/types/v1-ai-talking-photo-create-body-resolution-enum.js +2 -0
  70. package/dist/types/v1-ai-talking-photo-create-body.d.ts +10 -1
  71. package/dist/types/v1-ai-talking-photo-create-body.js +4 -0
  72. package/dist/types/v1-ai-ugc-ad-create-body-assets.d.ts +29 -0
  73. package/dist/types/v1-ai-ugc-ad-create-body-assets.js +69 -0
  74. package/dist/types/v1-ai-ugc-ad-create-body-model-enum.d.ts +4 -0
  75. package/dist/types/v1-ai-ugc-ad-create-body-model-enum.js +2 -0
  76. package/dist/types/v1-ai-ugc-ad-create-body-resolution-enum.d.ts +4 -0
  77. package/dist/types/v1-ai-ugc-ad-create-body-resolution-enum.js +2 -0
  78. package/dist/types/v1-ai-ugc-ad-create-body.d.ts +50 -0
  79. package/dist/types/v1-ai-ugc-ad-create-body.js +86 -0
  80. package/dist/types/v1-ai-ugc-ad-create-response.d.ts +36 -0
  81. package/dist/types/v1-ai-ugc-ad-create-response.js +75 -0
  82. package/dist/types/v1-ai-video-upscaler-create-body-assets.d.ts +27 -0
  83. package/dist/types/v1-ai-video-upscaler-create-body-assets.js +67 -0
  84. package/dist/types/v1-ai-video-upscaler-create-body-resolution-enum.d.ts +4 -0
  85. package/dist/types/v1-ai-video-upscaler-create-body-resolution-enum.js +2 -0
  86. package/dist/types/v1-ai-video-upscaler-create-body.d.ts +43 -0
  87. package/dist/types/v1-ai-video-upscaler-create-body.js +84 -0
  88. package/dist/types/v1-ai-video-upscaler-create-response.d.ts +36 -0
  89. package/dist/types/v1-ai-video-upscaler-create-response.js +75 -0
  90. package/dist/types/v1-image-to-video-create-body-assets.d.ts +2 -1
  91. package/dist/types/v1-image-to-video-create-body-model-enum.d.ts +2 -1
  92. package/dist/types/v1-image-to-video-create-body-resolution-enum.d.ts +1 -0
  93. package/dist/types/v1-image-to-video-create-body.d.ts +6 -2
  94. package/dist/types/v1-image-to-video-create-body.js +2 -0
  95. package/dist/types/v1-text-to-video-create-body-aspect-ratio-enum.d.ts +2 -1
  96. package/dist/types/v1-text-to-video-create-body-model-enum.d.ts +2 -1
  97. package/dist/types/v1-text-to-video-create-body-resolution-enum.d.ts +1 -0
  98. package/dist/types/v1-text-to-video-create-body.d.ts +11 -3
  99. package/dist/types/v1-text-to-video-create-body.js +2 -0
  100. package/package.json +4 -3
@@ -0,0 +1,81 @@
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.AiUgcAdClient = void 0;
24
+ const make_api_request_js_1 = require("make-api-request-js");
25
+ const logger_1 = require("../../../logger.js");
26
+ const files_1 = require("../files/index.js");
27
+ const video_projects_1 = require("../video-projects/index.js");
28
+ const v1_ai_ugc_ad_create_body_1 = require("../../../types/v1-ai-ugc-ad-create-body.js");
29
+ const v1_ai_ugc_ad_create_response_1 = require("../../../types/v1-ai-ugc-ad-create-response.js");
30
+ class AiUgcAdClient extends make_api_request_js_1.CoreResourceClient {
31
+ constructor(coreClient, opts) {
32
+ super(coreClient, opts);
33
+ }
34
+ /**
35
+ * Generate a UGC ad with automatic image upload, polling, and downloads.
36
+ *
37
+ * Accepts the same request fields as create(), including model and resolution.
38
+ * The prepared image may be a local path, URL, or existing api-assets path.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const result = await client.v1.aiUgcAd.generate({
43
+ * assets: { imageFilePath: "path/to/image.jpg" },
44
+ * endSeconds: 4,
45
+ * script: "Meet your new everyday essential.",
46
+ * });
47
+ * ```
48
+ */
49
+ generate(request_1) {
50
+ return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
51
+ const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
52
+ const fileClient = new files_1.FilesClient(this._client, this._opts);
53
+ const uploadedImageFilePath = yield fileClient.uploadFile(request.assets.imageFilePath);
54
+ const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, request.assets), { imageFilePath: uploadedImageFilePath }) }), createOpts);
55
+ (0, logger_1.getLogger)().info(`Created AiUgcAdClient project ${createResponse.id}`);
56
+ const projectsClient = new video_projects_1.VideoProjectsClient(this._client, this._opts);
57
+ return projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
58
+ downloadOutputs,
59
+ downloadDirectory }, createOpts));
60
+ });
61
+ }
62
+ /**
63
+ * AI UGC Ad Generator
64
+ *
65
+ * Create a spoken UGC video from a prepared image and script. Returns a project ID; poll GET /v1/video-projects/{id} for status and downloads. To compose an image, generate the image separately with the Image Editor API and supply its download URL.
66
+ *
67
+ * POST /v1/ai-ugc-ad
68
+ */
69
+ create(request, opts) {
70
+ return this._client.makeRequest({
71
+ method: "post",
72
+ path: "/v1/ai-ugc-ad",
73
+ auth: ["bearerAuth"],
74
+ contentType: "application/json",
75
+ body: v1_ai_ugc_ad_create_body_1.Schemas$V1AiUgcAdCreateBody.out.parse(request),
76
+ responseSchema: v1_ai_ugc_ad_create_response_1.Schemas$V1AiUgcAdCreateResponse.in,
77
+ opts,
78
+ });
79
+ }
80
+ }
81
+ exports.AiUgcAdClient = AiUgcAdClient;
@@ -61,11 +61,11 @@ export declare class AiVideoEditorClient extends CoreResourceClient {
61
61
  *
62
62
  * **Key options**
63
63
  * - Inputs: usually a file, sometimes a YouTube link, depending on project type
64
- * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
64
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
65
65
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
66
66
  *
67
67
  * **Cost**
68
- * 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.
68
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
69
69
  *
70
70
  * For detailed examples, see the [product page](https://magichour.ai/products/ai-video-editor).
71
71
  *
@@ -95,11 +95,11 @@ class AiVideoEditorClient extends make_api_request_js_1.CoreResourceClient {
95
95
  *
96
96
  * **Key options**
97
97
  * - Inputs: usually a file, sometimes a YouTube link, depending on project type
98
- * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
98
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
99
99
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
100
100
  *
101
101
  * **Cost**
102
- * 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.
102
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
103
103
  *
104
104
  * For detailed examples, see the [product page](https://magichour.ai/products/ai-video-editor).
105
105
  *
@@ -28,11 +28,11 @@ export declare class AiVideoTranslatorClient extends CoreResourceClient {
28
28
  *
29
29
  * **Key options**
30
30
  * - Inputs: usually a file, sometimes a YouTube link, depending on project type
31
- * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
31
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
32
32
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
33
33
  *
34
34
  * **Cost**
35
- * 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.
35
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
36
36
  *
37
37
  * For detailed examples, see the [product page](https://magichour.ai/products/ai-video-translator).
38
38
  *
@@ -59,11 +59,11 @@ class AiVideoTranslatorClient extends make_api_request_js_1.CoreResourceClient {
59
59
  *
60
60
  * **Key options**
61
61
  * - Inputs: usually a file, sometimes a YouTube link, depending on project type
62
- * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
62
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
63
63
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
64
64
  *
65
65
  * **Cost**
66
- * 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.
66
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
67
67
  *
68
68
  * For detailed examples, see the [product page](https://magichour.ai/products/ai-video-translator).
69
69
  *
@@ -0,0 +1,2 @@
1
+ export { CreateRequest } from "./request-types";
2
+ export { AiVideoUpscalerClient } from "./resource-client";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiVideoUpscalerClient = void 0;
4
+ var resource_client_1 = require("./resource-client");
5
+ Object.defineProperty(exports, "AiVideoUpscalerClient", { enumerable: true, get: function () { return resource_client_1.AiVideoUpscalerClient; } });
@@ -0,0 +1,43 @@
1
+ import * as z from "zod";
2
+ import { External$V1AiVideoUpscalerCreateBodyAssets, V1AiVideoUpscalerCreateBodyAssets } from "../../../types/v1-ai-video-upscaler-create-body-assets.js";
3
+ /**
4
+ * CreateRequest
5
+ */
6
+ export type CreateRequest = {
7
+ /**
8
+ * Source video for the upscale job.
9
+ */
10
+ assets: V1AiVideoUpscalerCreateBodyAssets;
11
+ /**
12
+ * End time of your clip (seconds). Must be greater than start_seconds.
13
+ */
14
+ endSeconds: number;
15
+ /**
16
+ * Give your video a custom name for easy identification.
17
+ */
18
+ name?: string | undefined;
19
+ /**
20
+ * Output resolution. `720p` and `1080p` set the output's short side, `2k` and `4k` its long side; the aspect ratio is kept. Requires a paid plan.
21
+ */
22
+ resolution: "1080p" | "2k" | "4k" | "720p";
23
+ /**
24
+ * Start time of your clip (seconds). Must be ≥ 0.
25
+ */
26
+ startSeconds?: number | undefined;
27
+ };
28
+ /**
29
+ * @internal
30
+ * CreateRequest without any key transformation, this is what
31
+ * we expect to come in as network data
32
+ */
33
+ export type External$CreateRequest = {
34
+ assets: External$V1AiVideoUpscalerCreateBodyAssets;
35
+ end_seconds: number;
36
+ name?: string | undefined;
37
+ resolution: "1080p" | "2k" | "4k" | "720p";
38
+ start_seconds?: number | undefined;
39
+ };
40
+ export declare const Schemas$CreateRequest: {
41
+ in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
42
+ out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
43
+ };
@@ -0,0 +1,84 @@
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_video_upscaler_create_body_assets_1 = require("../../../types/v1-ai-video-upscaler-create-body-assets.js");
40
+ /**
41
+ * Takes network data, validates it, and transforms keys to match typescript object CreateRequest
42
+ */
43
+ const SchemaIn$CreateRequest = z
44
+ .object({
45
+ assets: v1_ai_video_upscaler_create_body_assets_1.Schemas$V1AiVideoUpscalerCreateBodyAssets.in,
46
+ end_seconds: z.number(),
47
+ name: z.string().optional(),
48
+ resolution: z.enum(["1080p", "2k", "4k", "720p"]),
49
+ start_seconds: z.number().optional(),
50
+ })
51
+ .transform((obj) => {
52
+ return (0, make_api_request_js_1.zodTransform)(obj, {
53
+ assets: "assets",
54
+ end_seconds: "endSeconds",
55
+ name: "name",
56
+ resolution: "resolution",
57
+ start_seconds: "startSeconds",
58
+ });
59
+ });
60
+ /**
61
+ * @internal
62
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$CreateRequest
63
+ */
64
+ const SchemaOut$CreateRequest = z
65
+ .object({
66
+ assets: v1_ai_video_upscaler_create_body_assets_1.Schemas$V1AiVideoUpscalerCreateBodyAssets.out,
67
+ endSeconds: z.number(),
68
+ name: z.string().optional(),
69
+ resolution: z.enum(["1080p", "2k", "4k", "720p"]),
70
+ startSeconds: z.number().optional(),
71
+ })
72
+ .transform((obj) => {
73
+ return (0, make_api_request_js_1.zodTransform)(obj, {
74
+ assets: "assets",
75
+ endSeconds: "end_seconds",
76
+ name: "name",
77
+ resolution: "resolution",
78
+ startSeconds: "start_seconds",
79
+ });
80
+ });
81
+ exports.Schemas$CreateRequest = {
82
+ in: SchemaIn$CreateRequest,
83
+ out: SchemaOut$CreateRequest,
84
+ };
@@ -0,0 +1,60 @@
1
+ import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
2
+ import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type.js";
3
+ import * as requests from "./request-types.js";
4
+ import * as types from "../../../types/index.js";
5
+ type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
6
+ /**
7
+ * Video to upscale. Accepts a local path, URL, or existing api-assets path.
8
+ */
9
+ videoFilePath: string;
10
+ }>;
11
+ export declare class AiVideoUpscalerClient extends CoreResourceClient {
12
+ constructor(coreClient: CoreClient, opts: ResourceClientOptions);
13
+ /**
14
+ * Generate upscaled video with automatic upload, polling and downloads.
15
+ *
16
+ * Accepts the same request fields as create(). By default, waits for completion
17
+ * and downloads outputs. Use opts to disable waiting or downloading, or set
18
+ * the download directory.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const result = await client.v1.aiVideoUpscaler.generate({
23
+ * assets: { videoFilePath: "path/to/video.mp4" },
24
+ * endSeconds: 5,
25
+ * resolution: "1080p",
26
+ * });
27
+ * ```
28
+ */
29
+ generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../video-projects/resource-client").V1VideoProjectsGetResponseWithDownloads>;
30
+ /**
31
+ * AI Video Upscaler
32
+ *
33
+ * **What this API does**
34
+ *
35
+ * Create the same Video Upscaler 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.
36
+ *
37
+ * **Good for**
38
+ * - Automation and batch processing
39
+ * - Adding video upscaler into apps, pipelines, or tools
40
+ *
41
+ * **How it works (3 steps)**
42
+ * 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`.
43
+ * 2) Send a request to create a video upscaler job with the basic fields.
44
+ * 3) Check the job status until it's `complete`, then download the result from `downloads`.
45
+ *
46
+ * **Key options**
47
+ * - Inputs: usually a file, sometimes a YouTube link, depending on project type
48
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
49
+ * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
50
+ *
51
+ * **Cost**
52
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
53
+ *
54
+ * For detailed examples, see the [product page](https://magichour.ai/products/video-upscaler).
55
+ *
56
+ * POST /v1/ai-video-upscaler
57
+ */
58
+ create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiVideoUpscalerCreateResponse>;
59
+ }
60
+ export {};
@@ -0,0 +1,103 @@
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.AiVideoUpscalerClient = void 0;
24
+ const make_api_request_js_1 = require("make-api-request-js");
25
+ const logger_1 = require("../../../logger.js");
26
+ const files_1 = require("../files/index.js");
27
+ const video_projects_1 = require("../video-projects/index.js");
28
+ const v1_ai_video_upscaler_create_body_1 = require("../../../types/v1-ai-video-upscaler-create-body.js");
29
+ const v1_ai_video_upscaler_create_response_1 = require("../../../types/v1-ai-video-upscaler-create-response.js");
30
+ class AiVideoUpscalerClient extends make_api_request_js_1.CoreResourceClient {
31
+ constructor(coreClient, opts) {
32
+ super(coreClient, opts);
33
+ }
34
+ /**
35
+ * Generate upscaled video with automatic upload, polling and downloads.
36
+ *
37
+ * Accepts the same request fields as create(). By default, waits for completion
38
+ * and downloads outputs. Use opts to disable waiting or downloading, or set
39
+ * the download directory.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const result = await client.v1.aiVideoUpscaler.generate({
44
+ * assets: { videoFilePath: "path/to/video.mp4" },
45
+ * endSeconds: 5,
46
+ * resolution: "1080p",
47
+ * });
48
+ * ```
49
+ */
50
+ generate(request_1) {
51
+ return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
52
+ const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
53
+ const fileClient = new files_1.FilesClient(this._client, this._opts);
54
+ const uploadedVideoFilePath = yield fileClient.uploadFile(request.assets.videoFilePath);
55
+ const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, request.assets), { videoFilePath: uploadedVideoFilePath }) }), createOpts);
56
+ (0, logger_1.getLogger)().info(`Created ai-video-upscaler project ${createResponse.id}`);
57
+ const projectsClient = new video_projects_1.VideoProjectsClient(this._client, this._opts);
58
+ return projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
59
+ downloadOutputs,
60
+ downloadDirectory }, createOpts));
61
+ });
62
+ }
63
+ /**
64
+ * AI Video Upscaler
65
+ *
66
+ * **What this API does**
67
+ *
68
+ * Create the same Video Upscaler 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.
69
+ *
70
+ * **Good for**
71
+ * - Automation and batch processing
72
+ * - Adding video upscaler into apps, pipelines, or tools
73
+ *
74
+ * **How it works (3 steps)**
75
+ * 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`.
76
+ * 2) Send a request to create a video upscaler job with the basic fields.
77
+ * 3) Check the job status until it's `complete`, then download the result from `downloads`.
78
+ *
79
+ * **Key options**
80
+ * - Inputs: usually a file, sometimes a YouTube link, depending on project type
81
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
82
+ * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
83
+ *
84
+ * **Cost**
85
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
86
+ *
87
+ * For detailed examples, see the [product page](https://magichour.ai/products/video-upscaler).
88
+ *
89
+ * POST /v1/ai-video-upscaler
90
+ */
91
+ create(request, opts) {
92
+ return this._client.makeRequest({
93
+ method: "post",
94
+ path: "/v1/ai-video-upscaler",
95
+ auth: ["bearerAuth"],
96
+ contentType: "application/json",
97
+ body: v1_ai_video_upscaler_create_body_1.Schemas$V1AiVideoUpscalerCreateBody.out.parse(request),
98
+ responseSchema: v1_ai_video_upscaler_create_response_1.Schemas$V1AiVideoUpscalerCreateResponse.in,
99
+ opts,
100
+ });
101
+ }
102
+ }
103
+ exports.AiVideoUpscalerClient = AiVideoUpscalerClient;
@@ -1,5 +1,6 @@
1
1
  import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
2
2
  import { types } from "../../../index.js";
3
+ import { DownloadError } from "../../../helpers/download-error.js";
3
4
  import { GenerateOptions } from "../../../helpers/generate-type.js";
4
5
  import * as requests from "./request-types.js";
5
6
  /**
@@ -11,6 +12,10 @@ export interface V1AudioProjectsGetResponseWithDownloads extends types.V1AudioPr
11
12
  * This field is only populated if `download_outputs` is True and the audio project is complete.
12
13
  */
13
14
  downloadedPaths?: string[];
15
+ /**
16
+ * Local download failures. The completed project and remote download URLs remain available.
17
+ */
18
+ downloadErrors?: DownloadError["downloadErrors"];
14
19
  }
15
20
  export declare class AudioProjectsClient extends CoreResourceClient {
16
21
  constructor(coreClient: CoreClient, opts: ResourceClientOptions);
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.AudioProjectsClient = void 0;
24
24
  const make_api_request_js_1 = require("make-api-request-js");
25
25
  const download_1 = require("../../../helpers/download.js");
26
+ const download_error_1 = require("../../../helpers/download-error.js");
26
27
  const sleep_1 = require("../../../helpers/sleep.js");
27
28
  const logger_1 = require("../../../logger.js");
28
29
  const v1_audio_projects_get_response_1 = require("../../../types/v1-audio-projects-get-response.js");
@@ -70,9 +71,20 @@ class AudioProjectsClient extends make_api_request_js_1.CoreResourceClient {
70
71
  return Object.assign({}, apiResponse);
71
72
  }
72
73
  (0, logger_1.getLogger)().debug(`Downloading outputs for audio project ${request.id} to ${downloadDirectory !== null && downloadDirectory !== void 0 ? downloadDirectory : "current directory"}`);
73
- const downloadedPaths = yield (0, download_1.downloadFiles)(apiResponse.downloads, downloadDirectory);
74
+ let downloadedPaths;
75
+ let downloadErrors = [];
76
+ try {
77
+ downloadedPaths = yield (0, download_1.downloadFiles)(apiResponse.downloads, downloadDirectory);
78
+ }
79
+ catch (error) {
80
+ if (!(error instanceof download_error_1.DownloadError)) {
81
+ throw error;
82
+ }
83
+ downloadedPaths = error.downloadedPaths;
84
+ downloadErrors = error.downloadErrors;
85
+ }
74
86
  (0, logger_1.getLogger)().info(`Downloaded outputs for audio project ${request.id} to ${downloadedPaths}`);
75
- return Object.assign(Object.assign({}, apiResponse), { downloadedPaths });
87
+ return Object.assign(Object.assign(Object.assign({}, apiResponse), { downloadedPaths }), (downloadErrors.length > 0 ? { downloadErrors } : {}));
76
88
  });
77
89
  }
78
90
  /**
@@ -72,11 +72,11 @@ export declare class AudioToVideoClient extends CoreResourceClient {
72
72
  *
73
73
  * **Key options**
74
74
  * - Inputs: usually a file, sometimes a YouTube link, depending on project type
75
- * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
75
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
76
76
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
77
77
  *
78
78
  * **Cost**
79
- * 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.
79
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
80
80
  *
81
81
  * For detailed examples, see the [product page](https://magichour.ai/products/audio-to-video).
82
82
  *
@@ -109,11 +109,11 @@ class AudioToVideoClient extends make_api_request_js_1.CoreResourceClient {
109
109
  *
110
110
  * **Key options**
111
111
  * - Inputs: usually a file, sometimes a YouTube link, depending on project type
112
- * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
112
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
113
113
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
114
114
  *
115
115
  * **Cost**
116
- * 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.
116
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
117
117
  *
118
118
  * For detailed examples, see the [product page](https://magichour.ai/products/audio-to-video).
119
119
  *
@@ -73,11 +73,11 @@ export declare class CharacterReplaceClient extends CoreResourceClient {
73
73
  *
74
74
  * **Key options**
75
75
  * - Inputs: usually a file, sometimes a YouTube link, depending on project type
76
- * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
76
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
77
77
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
78
78
  *
79
79
  * **Cost**
80
- * 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.
80
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
81
81
  *
82
82
  * For detailed examples, see the [product page](https://magichour.ai/products/character-replace).
83
83
  *
@@ -104,11 +104,11 @@ class CharacterReplaceClient extends make_api_request_js_1.CoreResourceClient {
104
104
  *
105
105
  * **Key options**
106
106
  * - Inputs: usually a file, sometimes a YouTube link, depending on project type
107
- * - Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
107
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
108
108
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
109
109
  *
110
110
  * **Cost**
111
- * 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.
111
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
112
112
  *
113
113
  * For detailed examples, see the [product page](https://magichour.ai/products/character-replace).
114
114
  *
@@ -26,6 +26,11 @@ export declare class FaceDetectionClient extends CoreResourceClient {
26
26
  id: string;
27
27
  status: "complete" | "error" | "queued" | "rendering";
28
28
  } | {
29
+ downloadErrors?: {
30
+ stage: "directory" | "file";
31
+ message: string;
32
+ url?: string;
33
+ }[];
29
34
  downloadedPaths: string[];
30
35
  creditsCharged: number;
31
36
  faces: types.V1FaceDetectionGetResponseFacesItem[];
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.FaceDetectionClient = void 0;
24
24
  const make_api_request_js_1 = require("make-api-request-js");
25
25
  const download_1 = require("../../../helpers/download.js");
26
+ const download_error_1 = require("../../../helpers/download-error.js");
26
27
  const sleep_1 = require("../../../helpers/sleep.js");
27
28
  const logger_1 = require("../../../logger.js");
28
29
  const files_1 = require("../files/index.js");
@@ -76,12 +77,23 @@ class FaceDetectionClient extends make_api_request_js_1.CoreResourceClient {
76
77
  return Object.assign({}, apiResponse);
77
78
  }
78
79
  (0, logger_1.getLogger)().debug(`Downloading outputs for face detection ${apiResponse.id} to ${downloadDirectory !== null && downloadDirectory !== void 0 ? downloadDirectory : "current directory"}`);
79
- const downloadedPaths = yield (0, download_1.downloadFiles)(apiResponse.faces.map((f) => ({
80
- url: f.url,
81
- expiresAt: "ignore",
82
- })), downloadDirectory);
80
+ let downloadedPaths;
81
+ let downloadErrors = [];
82
+ try {
83
+ downloadedPaths = yield (0, download_1.downloadFiles)(apiResponse.faces.map((f) => ({
84
+ url: f.url,
85
+ expiresAt: "ignore",
86
+ })), downloadDirectory);
87
+ }
88
+ catch (error) {
89
+ if (!(error instanceof download_error_1.DownloadError)) {
90
+ throw error;
91
+ }
92
+ downloadedPaths = error.downloadedPaths;
93
+ downloadErrors = error.downloadErrors;
94
+ }
83
95
  (0, logger_1.getLogger)().info(`Downloaded outputs for face detection ${apiResponse.id} to ${downloadedPaths}`);
84
- return Object.assign(Object.assign({}, apiResponse), { downloadedPaths });
96
+ return Object.assign(Object.assign(Object.assign({}, apiResponse), { downloadedPaths }), (downloadErrors.length > 0 ? { downloadErrors } : {}));
85
97
  });
86
98
  }
87
99
  /**
@@ -97,11 +97,11 @@ export declare class FaceSwapClient extends CoreResourceClient {
97
97
  *
98
98
  * **Key options**
99
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
100
+ * - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
101
101
  * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
102
102
  *
103
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.
104
+ * Credits are charged when the job is queued (`credits_charged` in the response). Tools billed per frame charge an estimate and settle to the frames that actually render once the job finishes; tools billed per second charge the final amount upfront. Failed jobs are refunded.
105
105
  *
106
106
  * For detailed examples, see the [product page](https://magichour.ai/products/face-swap).
107
107
  *