magic-hour 0.66.0 → 0.68.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 (61) hide show
  1. package/README.md +10 -0
  2. package/dist/environment.d.ts +1 -1
  3. package/dist/environment.js +1 -1
  4. package/dist/resources/v1/ai-image-upscaler/request-types.d.ts +3 -3
  5. package/dist/resources/v1/ai-image-upscaler/request-types.js +2 -2
  6. package/dist/resources/v1/ai-image-upscaler/resource-client.d.ts +1 -1
  7. package/dist/resources/v1/ai-image-upscaler/resource-client.js +1 -1
  8. package/dist/resources/v1/ai-video-editor/index.d.ts +2 -0
  9. package/dist/resources/v1/ai-video-editor/index.js +5 -0
  10. package/dist/resources/v1/ai-video-editor/request-types.d.ts +41 -0
  11. package/dist/resources/v1/ai-video-editor/request-types.js +85 -0
  12. package/dist/resources/v1/ai-video-editor/resource-client.d.ts +76 -0
  13. package/dist/resources/v1/ai-video-editor/resource-client.js +120 -0
  14. package/dist/resources/v1/body-swap/resource-client.d.ts +1 -1
  15. package/dist/resources/v1/body-swap/resource-client.js +1 -1
  16. package/dist/resources/v1/character-replace/index.d.ts +2 -0
  17. package/dist/resources/v1/character-replace/index.js +5 -0
  18. package/dist/resources/v1/character-replace/request-types.d.ts +49 -0
  19. package/dist/resources/v1/character-replace/request-types.js +89 -0
  20. package/dist/resources/v1/character-replace/resource-client.d.ts +88 -0
  21. package/dist/resources/v1/character-replace/resource-client.js +129 -0
  22. package/dist/resources/v1/files/upload-urls/resource-client.d.ts +2 -2
  23. package/dist/resources/v1/files/upload-urls/resource-client.js +2 -2
  24. package/dist/resources/v1/index.d.ts +2 -0
  25. package/dist/resources/v1/index.js +3 -1
  26. package/dist/resources/v1/resource-client.d.ts +6 -0
  27. package/dist/resources/v1/resource-client.js +12 -0
  28. package/dist/types/index.d.ts +12 -0
  29. package/dist/types/v1-ai-image-upscaler-create-body-style-enhancement-enum.d.ts +1 -1
  30. package/dist/types/v1-ai-image-upscaler-create-body-style-mode-enum.d.ts +2 -2
  31. package/dist/types/v1-ai-image-upscaler-create-body-style.d.ts +8 -5
  32. package/dist/types/v1-ai-image-upscaler-create-body-style.js +2 -2
  33. package/dist/types/v1-ai-image-upscaler-create-body.d.ts +3 -3
  34. package/dist/types/v1-ai-image-upscaler-create-body.js +2 -2
  35. package/dist/types/v1-ai-video-editor-create-body-assets.d.ts +27 -0
  36. package/dist/types/v1-ai-video-editor-create-body-assets.js +67 -0
  37. package/dist/types/v1-ai-video-editor-create-body-style.d.ts +22 -0
  38. package/dist/types/v1-ai-video-editor-create-body-style.js +67 -0
  39. package/dist/types/v1-ai-video-editor-create-body.d.ts +41 -0
  40. package/dist/types/v1-ai-video-editor-create-body.js +85 -0
  41. package/dist/types/v1-ai-video-editor-create-response.d.ts +36 -0
  42. package/dist/types/v1-ai-video-editor-create-response.js +75 -0
  43. package/dist/types/v1-body-swap-create-body-assets.d.ts +1 -1
  44. package/dist/types/v1-character-replace-create-body-assets.d.ts +37 -0
  45. package/dist/types/v1-character-replace-create-body-assets.js +71 -0
  46. package/dist/types/v1-character-replace-create-body-resolution-enum.d.ts +4 -0
  47. package/dist/types/v1-character-replace-create-body-resolution-enum.js +2 -0
  48. package/dist/types/v1-character-replace-create-body-style-mode-enum.d.ts +4 -0
  49. package/dist/types/v1-character-replace-create-body-style-mode-enum.js +2 -0
  50. package/dist/types/v1-character-replace-create-body-style-points-item.d.ts +32 -0
  51. package/dist/types/v1-character-replace-create-body-style-points-item.js +75 -0
  52. package/dist/types/v1-character-replace-create-body-style-selection-mode-enum.d.ts +4 -0
  53. package/dist/types/v1-character-replace-create-body-style-selection-mode-enum.js +2 -0
  54. package/dist/types/v1-character-replace-create-body-style.d.ts +33 -0
  55. package/dist/types/v1-character-replace-create-body-style.js +80 -0
  56. package/dist/types/v1-character-replace-create-body.d.ts +49 -0
  57. package/dist/types/v1-character-replace-create-body.js +89 -0
  58. package/dist/types/v1-character-replace-create-response.d.ts +36 -0
  59. package/dist/types/v1-character-replace-create-response.js +75 -0
  60. package/dist/types/v1-files-upload-urls-create-body-items-item.d.ts +1 -1
  61. package/package.json +1 -1
package/README.md CHANGED
@@ -251,6 +251,11 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
251
251
  - [create](src/resources/v1/ai-talking-photo/README.md#create) - AI Talking Photo
252
252
  - [generate](src/resources/v1/ai-talking-photo/README.md#generate) - AI Talking Photo Generate Workflow
253
253
 
254
+ ### [v1.aiVideoEditor](src/resources/v1/ai-video-editor/README.md)
255
+
256
+ - [create](src/resources/v1/ai-video-editor/README.md#create) - AI Video Editor
257
+ - [generate](src/resources/v1/ai-video-editor/README.md#generate) - AI Video Editor Generate Workflow
258
+
254
259
  ### [v1.aiVoiceCloner](src/resources/v1/ai-voice-cloner/README.md)
255
260
 
256
261
  - [create](src/resources/v1/ai-voice-cloner/README.md#create) - AI Voice Cloner
@@ -287,6 +292,11 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
287
292
  - [create](src/resources/v1/body-swap/README.md#create) - Body Swap
288
293
  - [generate](src/resources/v1/body-swap/README.md#generate) - Body Swap Generate Workflow
289
294
 
295
+ ### [v1.characterReplace](src/resources/v1/character-replace/README.md)
296
+
297
+ - [create](src/resources/v1/character-replace/README.md#create) - Character Replace
298
+ - [generate](src/resources/v1/character-replace/README.md#generate) - Character Replace Generate Workflow
299
+
290
300
  ### [v1.faceDetection](src/resources/v1/face-detection/README.md)
291
301
 
292
302
  - [create](src/resources/v1/face-detection/README.md#create) - Face Detection
@@ -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.67.0"
3
+ MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.69.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.67.0";
7
+ Environment["MockServer"] = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.69.0";
8
8
  })(Environment || (exports.Environment = Environment = {}));
@@ -20,9 +20,9 @@ export type CreateRequest = {
20
20
  */
21
21
  scaleFactor: number;
22
22
  /**
23
- * Style settings for the upscale. Use `mode` to select between `"pro"` (faster, no enhancement required) and `"creative"` (defaults to `"Balanced"` enhancement). Defaults to `"creative"`.
23
+ * Style settings for the upscale. Use `mode` (`"preserve"`, `"balanced"`, or `"creative"`). Defaults to `"balanced"`.
24
24
  */
25
- style: V1AiImageUpscalerCreateBodyStyle;
25
+ style?: V1AiImageUpscalerCreateBodyStyle | undefined;
26
26
  };
27
27
  /**
28
28
  * @internal
@@ -33,7 +33,7 @@ export type External$CreateRequest = {
33
33
  assets: External$V1AiImageUpscalerCreateBodyAssets;
34
34
  name?: string | undefined;
35
35
  scale_factor: number;
36
- style: External$V1AiImageUpscalerCreateBodyStyle;
36
+ style?: External$V1AiImageUpscalerCreateBodyStyle | undefined;
37
37
  };
38
38
  export declare const Schemas$CreateRequest: {
39
39
  in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
@@ -46,7 +46,7 @@ const SchemaIn$CreateRequest = z
46
46
  assets: v1_ai_image_upscaler_create_body_assets_1.Schemas$V1AiImageUpscalerCreateBodyAssets.in,
47
47
  name: z.string().optional(),
48
48
  scale_factor: z.number(),
49
- style: v1_ai_image_upscaler_create_body_style_1.Schemas$V1AiImageUpscalerCreateBodyStyle.in,
49
+ style: v1_ai_image_upscaler_create_body_style_1.Schemas$V1AiImageUpscalerCreateBodyStyle.in.optional(),
50
50
  })
51
51
  .transform((obj) => {
52
52
  return (0, make_api_request_js_1.zodTransform)(obj, {
@@ -65,7 +65,7 @@ const SchemaOut$CreateRequest = z
65
65
  assets: v1_ai_image_upscaler_create_body_assets_1.Schemas$V1AiImageUpscalerCreateBodyAssets.out,
66
66
  name: z.string().optional(),
67
67
  scaleFactor: z.number(),
68
- style: v1_ai_image_upscaler_create_body_style_1.Schemas$V1AiImageUpscalerCreateBodyStyle.out,
68
+ style: v1_ai_image_upscaler_create_body_style_1.Schemas$V1AiImageUpscalerCreateBodyStyle.out.optional(),
69
69
  })
70
70
  .transform((obj) => {
71
71
  return (0, make_api_request_js_1.zodTransform)(obj, {
@@ -45,7 +45,7 @@ export declare class AiImageUpscalerClient extends CoreResourceClient {
45
45
  /**
46
46
  * AI Image Upscaler
47
47
  *
48
- * Upscale your image using AI. Each 2x upscale costs 50 credits, and 4x upscale costs 200 credits.
48
+ * Upscale your image using AI. Each 2x upscale costs 50 credits for balanced/creative modes, and 25 credits for preserve. 4x upscale costs 200 and 100 credits respectively.
49
49
  *
50
50
  * POST /v1/ai-image-upscaler
51
51
  */
@@ -81,7 +81,7 @@ class AiImageUpscalerClient extends make_api_request_js_1.CoreResourceClient {
81
81
  /**
82
82
  * AI Image Upscaler
83
83
  *
84
- * Upscale your image using AI. Each 2x upscale costs 50 credits, and 4x upscale costs 200 credits.
84
+ * Upscale your image using AI. Each 2x upscale costs 50 credits for balanced/creative modes, and 25 credits for preserve. 4x upscale costs 200 and 100 credits respectively.
85
85
  *
86
86
  * POST /v1/ai-image-upscaler
87
87
  */
@@ -0,0 +1,2 @@
1
+ export { CreateRequest } from "./request-types";
2
+ export { AiVideoEditorClient } from "./resource-client";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiVideoEditorClient = void 0;
4
+ var resource_client_1 = require("./resource-client");
5
+ Object.defineProperty(exports, "AiVideoEditorClient", { enumerable: true, get: function () { return resource_client_1.AiVideoEditorClient; } });
@@ -0,0 +1,41 @@
1
+ import * as z from "zod";
2
+ import { External$V1AiVideoEditorCreateBodyAssets, V1AiVideoEditorCreateBodyAssets } from "../../../types/v1-ai-video-editor-create-body-assets";
3
+ import { External$V1AiVideoEditorCreateBodyStyle, V1AiVideoEditorCreateBodyStyle } from "../../../types/v1-ai-video-editor-create-body-style";
4
+ /**
5
+ * CreateRequest
6
+ */
7
+ export type CreateRequest = {
8
+ /**
9
+ * Provide the assets for video editing.
10
+ */
11
+ assets: V1AiVideoEditorCreateBodyAssets;
12
+ /**
13
+ * End time of your clip in seconds. Must be greater than `start_seconds`. Duration must be between 3 and 10 seconds.
14
+ */
15
+ endSeconds: number;
16
+ /**
17
+ * Give your video a custom name for easy identification.
18
+ */
19
+ name?: string | undefined;
20
+ /**
21
+ * Start time of your clip (seconds). Must be ≥ 0.
22
+ */
23
+ startSeconds?: number | undefined;
24
+ style: V1AiVideoEditorCreateBodyStyle;
25
+ };
26
+ /**
27
+ * @internal
28
+ * CreateRequest without any key transformation, this is what
29
+ * we expect to come in as network data
30
+ */
31
+ export type External$CreateRequest = {
32
+ assets: External$V1AiVideoEditorCreateBodyAssets;
33
+ end_seconds: number;
34
+ name?: string | undefined;
35
+ start_seconds?: number | undefined;
36
+ style: External$V1AiVideoEditorCreateBodyStyle;
37
+ };
38
+ export declare const Schemas$CreateRequest: {
39
+ in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
40
+ out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
41
+ };
@@ -0,0 +1,85 @@
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_editor_create_body_assets_1 = require("../../../types/v1-ai-video-editor-create-body-assets");
40
+ const v1_ai_video_editor_create_body_style_1 = require("../../../types/v1-ai-video-editor-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_video_editor_create_body_assets_1.Schemas$V1AiVideoEditorCreateBodyAssets.in,
47
+ end_seconds: z.number(),
48
+ name: z.string().optional(),
49
+ start_seconds: z.number().optional(),
50
+ style: v1_ai_video_editor_create_body_style_1.Schemas$V1AiVideoEditorCreateBodyStyle.in,
51
+ })
52
+ .transform((obj) => {
53
+ return (0, make_api_request_js_1.zodTransform)(obj, {
54
+ assets: "assets",
55
+ end_seconds: "endSeconds",
56
+ name: "name",
57
+ start_seconds: "startSeconds",
58
+ style: "style",
59
+ });
60
+ });
61
+ /**
62
+ * @internal
63
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$CreateRequest
64
+ */
65
+ const SchemaOut$CreateRequest = z
66
+ .object({
67
+ assets: v1_ai_video_editor_create_body_assets_1.Schemas$V1AiVideoEditorCreateBodyAssets.out,
68
+ endSeconds: z.number(),
69
+ name: z.string().optional(),
70
+ startSeconds: z.number().optional(),
71
+ style: v1_ai_video_editor_create_body_style_1.Schemas$V1AiVideoEditorCreateBodyStyle.out,
72
+ })
73
+ .transform((obj) => {
74
+ return (0, make_api_request_js_1.zodTransform)(obj, {
75
+ assets: "assets",
76
+ endSeconds: "end_seconds",
77
+ name: "name",
78
+ startSeconds: "start_seconds",
79
+ style: "style",
80
+ });
81
+ });
82
+ exports.Schemas$CreateRequest = {
83
+ in: SchemaIn$CreateRequest,
84
+ out: SchemaOut$CreateRequest,
85
+ };
@@ -0,0 +1,76 @@
1
+ import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
2
+ import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
3
+ import * as requests from "../../../resources/v1/ai-video-editor/request-types";
4
+ import * as types from "../../../types";
5
+ type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
6
+ /**
7
+ * The video to edit. This value is either
8
+ * - a direct URL to the video 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
+ videoFilePath: string;
14
+ }>;
15
+ export declare class AiVideoEditorClient extends CoreResourceClient {
16
+ constructor(coreClient: CoreClient, opts: ResourceClientOptions);
17
+ /**
18
+ * AI Video Editor
19
+ *
20
+ * Create a Video Editor video
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.aiVideoEditor.generate(
30
+ * {
31
+ * assets: { videoFilePath: "/path/to/1234.mp4" },
32
+ * endSeconds: 5.0,
33
+ * name: "My Video Editor video",
34
+ * startSeconds: 0.0,
35
+ * style: { prompt: "Change the car color to blue" },
36
+ * },
37
+ * {
38
+ * waitForCompletion: true,
39
+ * downloadOutputs: true,
40
+ * downloadDirectory: ".",
41
+ * },
42
+ * );
43
+ * ```
44
+ */
45
+ generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../video-projects/resource-client").V1VideoProjectsGetResponseWithDownloads>;
46
+ /**
47
+ * AI Video Editor
48
+ *
49
+ * **What this API does**
50
+ *
51
+ * Create the same Video Editor 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.
52
+ *
53
+ * **Good for**
54
+ * - Automation and batch processing
55
+ * - Adding video editor into apps, pipelines, or tools
56
+ *
57
+ * **How it works (3 steps)**
58
+ * 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`.
59
+ * 2) Send a request to create a video editor job with the basic fields.
60
+ * 3) Check the job status until it's `complete`, then download the result from `downloads`.
61
+ *
62
+ * **Key options**
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
65
+ * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
66
+ *
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.
69
+ *
70
+ * For detailed examples, see the [product page](https://magichour.ai/products/video-editor).
71
+ *
72
+ * POST /v1/ai-video-editor
73
+ */
74
+ create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiVideoEditorCreateResponse>;
75
+ }
76
+ export {};
@@ -0,0 +1,120 @@
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.AiVideoEditorClient = 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 video_projects_1 = require("../../../resources/v1/video-projects");
28
+ const v1_ai_video_editor_create_body_1 = require("../../../types/v1-ai-video-editor-create-body");
29
+ const v1_ai_video_editor_create_response_1 = require("../../../types/v1-ai-video-editor-create-response");
30
+ class AiVideoEditorClient extends make_api_request_js_1.CoreResourceClient {
31
+ constructor(coreClient, opts) {
32
+ super(coreClient, opts);
33
+ }
34
+ /**
35
+ * AI Video Editor
36
+ *
37
+ * Create a Video Editor video
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.aiVideoEditor.generate(
47
+ * {
48
+ * assets: { videoFilePath: "/path/to/1234.mp4" },
49
+ * endSeconds: 5.0,
50
+ * name: "My Video Editor video",
51
+ * startSeconds: 0.0,
52
+ * style: { prompt: "Change the car color to blue" },
53
+ * },
54
+ * {
55
+ * waitForCompletion: true,
56
+ * downloadOutputs: true,
57
+ * downloadDirectory: ".",
58
+ * },
59
+ * );
60
+ * ```
61
+ */
62
+ generate(request_1) {
63
+ return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
64
+ const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
65
+ const fileClient = new files_1.FilesClient(this._client, this._opts);
66
+ const _a = request.assets, { videoFilePath } = _a, restAssets = __rest(_a, ["videoFilePath"]);
67
+ (0, logger_1.getLogger)().debug(`Uploading file ${videoFilePath} to Magic Hour's storage`);
68
+ const uploadedVideoFilePath = yield fileClient.uploadFile(videoFilePath);
69
+ (0, logger_1.getLogger)().info(`Uploaded file ${videoFilePath} to Magic Hour's storage as ${uploadedVideoFilePath}`);
70
+ const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { videoFilePath: uploadedVideoFilePath }) }), createOpts);
71
+ (0, logger_1.getLogger)().info(`Created AiVideoEditorClient project ${createResponse.id}`);
72
+ const projectsClient = new video_projects_1.VideoProjectsClient(this._client, this._opts);
73
+ (0, logger_1.getLogger)().debug(`Checking result for AiVideoEditorClient project ${createResponse.id}`);
74
+ const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
75
+ downloadOutputs,
76
+ downloadDirectory }, createOpts));
77
+ return result;
78
+ });
79
+ }
80
+ /**
81
+ * AI Video Editor
82
+ *
83
+ * **What this API does**
84
+ *
85
+ * Create the same Video Editor 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.
86
+ *
87
+ * **Good for**
88
+ * - Automation and batch processing
89
+ * - Adding video editor into apps, pipelines, or tools
90
+ *
91
+ * **How it works (3 steps)**
92
+ * 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`.
93
+ * 2) Send a request to create a video editor job with the basic fields.
94
+ * 3) Check the job status until it's `complete`, then download the result from `downloads`.
95
+ *
96
+ * **Key options**
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
99
+ * - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
100
+ *
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.
103
+ *
104
+ * For detailed examples, see the [product page](https://magichour.ai/products/video-editor).
105
+ *
106
+ * POST /v1/ai-video-editor
107
+ */
108
+ create(request, opts) {
109
+ return this._client.makeRequest({
110
+ method: "post",
111
+ path: "/v1/ai-video-editor",
112
+ auth: ["bearerAuth"],
113
+ contentType: "application/json",
114
+ body: v1_ai_video_editor_create_body_1.Schemas$V1AiVideoEditorCreateBody.out.parse(request),
115
+ responseSchema: v1_ai_video_editor_create_response_1.Schemas$V1AiVideoEditorCreateResponse.in,
116
+ opts,
117
+ });
118
+ }
119
+ }
120
+ exports.AiVideoEditorClient = AiVideoEditorClient;
@@ -55,7 +55,7 @@ export declare class BodySwapClient extends CoreResourceClient {
55
55
  /**
56
56
  * Body Swap
57
57
  *
58
- * Swap a person into a scene image using Nano Banana 2. Credits depend on `resolution` (from 100 credits at 640px upward).
58
+ * Swap a person into a scene image using Nano Banana 2. Credits depend on `resolution` (from 50 credits at 640px upward).
59
59
  *
60
60
  * POST /v1/body-swap
61
61
  */
@@ -86,7 +86,7 @@ class BodySwapClient extends make_api_request_js_1.CoreResourceClient {
86
86
  /**
87
87
  * Body Swap
88
88
  *
89
- * Swap a person into a scene image using Nano Banana 2. Credits depend on `resolution` (from 100 credits at 640px upward).
89
+ * Swap a person into a scene image using Nano Banana 2. Credits depend on `resolution` (from 50 credits at 640px upward).
90
90
  *
91
91
  * POST /v1/body-swap
92
92
  */
@@ -0,0 +1,2 @@
1
+ export { CreateRequest } from "./request-types";
2
+ export { CharacterReplaceClient } from "./resource-client";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CharacterReplaceClient = void 0;
4
+ var resource_client_1 = require("./resource-client");
5
+ Object.defineProperty(exports, "CharacterReplaceClient", { enumerable: true, get: function () { return resource_client_1.CharacterReplaceClient; } });
@@ -0,0 +1,49 @@
1
+ import * as z from "zod";
2
+ import { External$V1CharacterReplaceCreateBodyAssets, V1CharacterReplaceCreateBodyAssets } from "../../../types/v1-character-replace-create-body-assets";
3
+ import { External$V1CharacterReplaceCreateBodyStyle, V1CharacterReplaceCreateBodyStyle } from "../../../types/v1-character-replace-create-body-style";
4
+ /**
5
+ * CreateRequest
6
+ */
7
+ export type CreateRequest = {
8
+ /**
9
+ * Source video and reference character image for the job.
10
+ */
11
+ assets: V1CharacterReplaceCreateBodyAssets;
12
+ /**
13
+ * End time of your clip (seconds). Must be greater than start_seconds.
14
+ */
15
+ endSeconds: number;
16
+ /**
17
+ * Give your video a custom name for easy identification.
18
+ */
19
+ name?: string | undefined;
20
+ /**
21
+ * Output video resolution. Defaults to 480p, the lowest resolution available on your plan.
22
+ */
23
+ resolution?: ("480p" | "720p") | undefined;
24
+ /**
25
+ * Start time of your clip (seconds). Must be ≥ 0.
26
+ */
27
+ startSeconds?: number | undefined;
28
+ /**
29
+ * Optional style controls for replace vs animate mode and subject selection.
30
+ */
31
+ style?: V1CharacterReplaceCreateBodyStyle | undefined;
32
+ };
33
+ /**
34
+ * @internal
35
+ * CreateRequest without any key transformation, this is what
36
+ * we expect to come in as network data
37
+ */
38
+ export type External$CreateRequest = {
39
+ assets: External$V1CharacterReplaceCreateBodyAssets;
40
+ end_seconds: number;
41
+ name?: string | undefined;
42
+ resolution?: ("480p" | "720p") | undefined;
43
+ start_seconds?: number | undefined;
44
+ style?: External$V1CharacterReplaceCreateBodyStyle | undefined;
45
+ };
46
+ export declare const Schemas$CreateRequest: {
47
+ in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
48
+ out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
49
+ };
@@ -0,0 +1,89 @@
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_character_replace_create_body_assets_1 = require("../../../types/v1-character-replace-create-body-assets");
40
+ const v1_character_replace_create_body_style_1 = require("../../../types/v1-character-replace-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_character_replace_create_body_assets_1.Schemas$V1CharacterReplaceCreateBodyAssets.in,
47
+ end_seconds: z.number(),
48
+ name: z.string().optional(),
49
+ resolution: z.enum(["480p", "720p"]).optional(),
50
+ start_seconds: z.number().optional(),
51
+ style: v1_character_replace_create_body_style_1.Schemas$V1CharacterReplaceCreateBodyStyle.in.optional(),
52
+ })
53
+ .transform((obj) => {
54
+ return (0, make_api_request_js_1.zodTransform)(obj, {
55
+ assets: "assets",
56
+ end_seconds: "endSeconds",
57
+ name: "name",
58
+ resolution: "resolution",
59
+ start_seconds: "startSeconds",
60
+ style: "style",
61
+ });
62
+ });
63
+ /**
64
+ * @internal
65
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$CreateRequest
66
+ */
67
+ const SchemaOut$CreateRequest = z
68
+ .object({
69
+ assets: v1_character_replace_create_body_assets_1.Schemas$V1CharacterReplaceCreateBodyAssets.out,
70
+ endSeconds: z.number(),
71
+ name: z.string().optional(),
72
+ resolution: z.enum(["480p", "720p"]).optional(),
73
+ startSeconds: z.number().optional(),
74
+ style: v1_character_replace_create_body_style_1.Schemas$V1CharacterReplaceCreateBodyStyle.out.optional(),
75
+ })
76
+ .transform((obj) => {
77
+ return (0, make_api_request_js_1.zodTransform)(obj, {
78
+ assets: "assets",
79
+ endSeconds: "end_seconds",
80
+ name: "name",
81
+ resolution: "resolution",
82
+ startSeconds: "start_seconds",
83
+ style: "style",
84
+ });
85
+ });
86
+ exports.Schemas$CreateRequest = {
87
+ in: SchemaIn$CreateRequest,
88
+ out: SchemaOut$CreateRequest,
89
+ };