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.
- package/README.md +37 -0
- package/dist/environment.d.ts +1 -1
- package/dist/environment.js +1 -1
- package/dist/helpers/download-error.d.ts +16 -0
- package/dist/helpers/download-error.js +15 -0
- package/dist/helpers/download.js +22 -2
- package/dist/resources/v1/ai-music-generator/index.d.ts +2 -0
- package/dist/resources/v1/ai-music-generator/index.js +5 -0
- package/dist/resources/v1/ai-music-generator/request-types.d.ts +32 -0
- package/dist/resources/v1/ai-music-generator/request-types.js +78 -0
- package/dist/resources/v1/ai-music-generator/resource-client.d.ts +31 -0
- package/dist/resources/v1/ai-music-generator/resource-client.js +78 -0
- package/dist/resources/v1/ai-talking-photo/request-types.d.ts +10 -1
- package/dist/resources/v1/ai-talking-photo/request-types.js +4 -0
- package/dist/resources/v1/ai-ugc-ad/index.d.ts +2 -0
- package/dist/resources/v1/ai-ugc-ad/index.js +5 -0
- package/dist/resources/v1/ai-ugc-ad/request-types.d.ts +50 -0
- package/dist/resources/v1/ai-ugc-ad/request-types.js +86 -0
- package/dist/resources/v1/ai-ugc-ad/resource-client.d.ts +41 -0
- package/dist/resources/v1/ai-ugc-ad/resource-client.js +81 -0
- package/dist/resources/v1/ai-video-editor/resource-client.d.ts +2 -2
- package/dist/resources/v1/ai-video-editor/resource-client.js +2 -2
- package/dist/resources/v1/ai-video-translator/resource-client.d.ts +2 -2
- package/dist/resources/v1/ai-video-translator/resource-client.js +2 -2
- package/dist/resources/v1/ai-video-upscaler/index.d.ts +2 -0
- package/dist/resources/v1/ai-video-upscaler/index.js +5 -0
- package/dist/resources/v1/ai-video-upscaler/request-types.d.ts +43 -0
- package/dist/resources/v1/ai-video-upscaler/request-types.js +84 -0
- package/dist/resources/v1/ai-video-upscaler/resource-client.d.ts +60 -0
- package/dist/resources/v1/ai-video-upscaler/resource-client.js +103 -0
- package/dist/resources/v1/audio-projects/resource-client.d.ts +5 -0
- package/dist/resources/v1/audio-projects/resource-client.js +14 -2
- package/dist/resources/v1/audio-to-video/resource-client.d.ts +2 -2
- package/dist/resources/v1/audio-to-video/resource-client.js +2 -2
- package/dist/resources/v1/character-replace/resource-client.d.ts +2 -2
- package/dist/resources/v1/character-replace/resource-client.js +2 -2
- package/dist/resources/v1/face-detection/resource-client.d.ts +5 -0
- package/dist/resources/v1/face-detection/resource-client.js +17 -5
- package/dist/resources/v1/face-swap/resource-client.d.ts +2 -2
- package/dist/resources/v1/face-swap/resource-client.js +2 -2
- package/dist/resources/v1/image-projects/resource-client.d.ts +5 -0
- package/dist/resources/v1/image-projects/resource-client.js +14 -2
- package/dist/resources/v1/image-to-video/request-types.d.ts +6 -2
- package/dist/resources/v1/image-to-video/request-types.js +2 -0
- package/dist/resources/v1/image-to-video/resource-client.d.ts +2 -2
- package/dist/resources/v1/image-to-video/resource-client.js +2 -2
- package/dist/resources/v1/index.d.ts +3 -0
- package/dist/resources/v1/index.js +4 -1
- package/dist/resources/v1/lip-sync/resource-client.d.ts +2 -2
- package/dist/resources/v1/lip-sync/resource-client.js +2 -2
- package/dist/resources/v1/resource-client.d.ts +9 -0
- package/dist/resources/v1/resource-client.js +17 -0
- package/dist/resources/v1/text-to-video/request-types.d.ts +11 -3
- package/dist/resources/v1/text-to-video/request-types.js +2 -0
- package/dist/resources/v1/text-to-video/resource-client.d.ts +2 -2
- package/dist/resources/v1/text-to-video/resource-client.js +2 -2
- package/dist/resources/v1/video-projects/resource-client.d.ts +5 -0
- package/dist/resources/v1/video-projects/resource-client.js +14 -2
- package/dist/resources/v1/video-to-video/resource-client.d.ts +2 -2
- package/dist/resources/v1/video-to-video/resource-client.js +2 -2
- package/dist/types/index.d.ts +13 -0
- package/dist/types/v1-ai-music-generator-create-body-style.d.ts +34 -0
- package/dist/types/v1-ai-music-generator-create-body-style.js +77 -0
- package/dist/types/v1-ai-music-generator-create-body.d.ts +32 -0
- package/dist/types/v1-ai-music-generator-create-body.js +78 -0
- package/dist/types/v1-ai-music-generator-create-response.d.ts +29 -0
- package/dist/types/v1-ai-music-generator-create-response.js +71 -0
- package/dist/types/v1-ai-talking-photo-create-body-resolution-enum.d.ts +4 -0
- package/dist/types/v1-ai-talking-photo-create-body-resolution-enum.js +2 -0
- package/dist/types/v1-ai-talking-photo-create-body.d.ts +10 -1
- package/dist/types/v1-ai-talking-photo-create-body.js +4 -0
- package/dist/types/v1-ai-ugc-ad-create-body-assets.d.ts +29 -0
- package/dist/types/v1-ai-ugc-ad-create-body-assets.js +69 -0
- package/dist/types/v1-ai-ugc-ad-create-body-model-enum.d.ts +4 -0
- package/dist/types/v1-ai-ugc-ad-create-body-model-enum.js +2 -0
- package/dist/types/v1-ai-ugc-ad-create-body-resolution-enum.d.ts +4 -0
- package/dist/types/v1-ai-ugc-ad-create-body-resolution-enum.js +2 -0
- package/dist/types/v1-ai-ugc-ad-create-body.d.ts +50 -0
- package/dist/types/v1-ai-ugc-ad-create-body.js +86 -0
- package/dist/types/v1-ai-ugc-ad-create-response.d.ts +36 -0
- package/dist/types/v1-ai-ugc-ad-create-response.js +75 -0
- package/dist/types/v1-ai-video-upscaler-create-body-assets.d.ts +27 -0
- package/dist/types/v1-ai-video-upscaler-create-body-assets.js +67 -0
- package/dist/types/v1-ai-video-upscaler-create-body-resolution-enum.d.ts +4 -0
- package/dist/types/v1-ai-video-upscaler-create-body-resolution-enum.js +2 -0
- package/dist/types/v1-ai-video-upscaler-create-body.d.ts +43 -0
- package/dist/types/v1-ai-video-upscaler-create-body.js +84 -0
- package/dist/types/v1-ai-video-upscaler-create-response.d.ts +36 -0
- package/dist/types/v1-ai-video-upscaler-create-response.js +75 -0
- package/dist/types/v1-image-to-video-create-body-assets.d.ts +2 -1
- package/dist/types/v1-image-to-video-create-body-model-enum.d.ts +2 -1
- package/dist/types/v1-image-to-video-create-body-resolution-enum.d.ts +1 -0
- package/dist/types/v1-image-to-video-create-body.d.ts +6 -2
- package/dist/types/v1-image-to-video-create-body.js +2 -0
- package/dist/types/v1-text-to-video-create-body-aspect-ratio-enum.d.ts +2 -1
- package/dist/types/v1-text-to-video-create-body-model-enum.d.ts +2 -1
- package/dist/types/v1-text-to-video-create-body-resolution-enum.d.ts +1 -0
- package/dist/types/v1-text-to-video-create-body.d.ts +11 -3
- package/dist/types/v1-text-to-video-create-body.js +2 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -89,6 +89,29 @@ console.log(`Status: ${response.status}`);
|
|
|
89
89
|
console.log(`Downloaded files: ${response.downloadedPaths}`);
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
+
### Recovering a local download failure
|
|
93
|
+
|
|
94
|
+
A completed generation remains complete if its files cannot be saved locally. The
|
|
95
|
+
result retains its project ID, status and remote download URLs; `downloadedPaths`
|
|
96
|
+
contains any files that were saved, and `downloadErrors` describes each directory
|
|
97
|
+
or file failure. A partial download therefore does not mean the generation failed.
|
|
98
|
+
|
|
99
|
+
Fix the local directory or network issue, then retry the existing project without
|
|
100
|
+
creating or paying for another generation:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const recovered = await client.v1.imageProjects.checkResult(
|
|
104
|
+
{ id: response.id },
|
|
105
|
+
{ downloadDirectory: "./outputs" },
|
|
106
|
+
);
|
|
107
|
+
console.log(recovered.downloadedPaths, recovered.downloadErrors);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Use `videoProjects` or `audioProjects` for those project types. The remote URLs
|
|
111
|
+
include expiration times: retrieve the same project again if you need current URLs.
|
|
112
|
+
Face detection returns the same local download errors alongside its face URLs;
|
|
113
|
+
retry those URLs directly rather than submitting another face detection task.
|
|
114
|
+
|
|
92
115
|
### Create Function
|
|
93
116
|
|
|
94
117
|
The `create()` function provides granular control:
|
|
@@ -245,6 +268,11 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
|
|
|
245
268
|
- [create](src/resources/v1/ai-meme-generator/README.md#create) - AI Meme Generator
|
|
246
269
|
- [generate](src/resources/v1/ai-meme-generator/README.md#generate) - AI Meme Generator Generate Workflow
|
|
247
270
|
|
|
271
|
+
### [v1.aiMusicGenerator](src/resources/v1/ai-music-generator/README.md)
|
|
272
|
+
|
|
273
|
+
- [create](src/resources/v1/ai-music-generator/README.md#create) - AI Music Generator
|
|
274
|
+
- [generate](src/resources/v1/ai-music-generator/README.md#generate) - AI Music Generator workflow
|
|
275
|
+
|
|
248
276
|
### [v1.aiQrCodeGenerator](src/resources/v1/ai-qr-code-generator/README.md)
|
|
249
277
|
|
|
250
278
|
- [create](src/resources/v1/ai-qr-code-generator/README.md#create) - AI QR Code Generator
|
|
@@ -255,6 +283,10 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
|
|
|
255
283
|
- [create](src/resources/v1/ai-talking-photo/README.md#create) - AI Talking Photo
|
|
256
284
|
- [generate](src/resources/v1/ai-talking-photo/README.md#generate) - AI Talking Photo Generate Workflow
|
|
257
285
|
|
|
286
|
+
### [v1.aiUgcAd](src/resources/v1/ai-ugc-ad/README.md)
|
|
287
|
+
|
|
288
|
+
- [create](src/resources/v1/ai-ugc-ad/README.md#create) - AI UGC Ad Generator
|
|
289
|
+
|
|
258
290
|
### [v1.aiVideoEditor](src/resources/v1/ai-video-editor/README.md)
|
|
259
291
|
|
|
260
292
|
- [create](src/resources/v1/ai-video-editor/README.md#create) - AI Video Editor
|
|
@@ -265,6 +297,11 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
|
|
|
265
297
|
- [create](src/resources/v1/ai-video-translator/README.md#create) - AI Video Translator
|
|
266
298
|
- [generate](src/resources/v1/ai-video-translator/README.md#generate) - Generate video translation
|
|
267
299
|
|
|
300
|
+
### [v1.aiVideoUpscaler](src/resources/v1/ai-video-upscaler/README.md)
|
|
301
|
+
|
|
302
|
+
- [create](src/resources/v1/ai-video-upscaler/README.md#create) - AI Video Upscaler
|
|
303
|
+
- [generate](src/resources/v1/ai-video-upscaler/README.md#generate) - AI Video Upscaler workflow
|
|
304
|
+
|
|
268
305
|
### [v1.aiVoiceCloner](src/resources/v1/ai-voice-cloner/README.md)
|
|
269
306
|
|
|
270
307
|
- [create](src/resources/v1/ai-voice-cloner/README.md#create) - AI Voice Cloner
|
package/dist/environment.d.ts
CHANGED
package/dist/environment.js
CHANGED
|
@@ -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.
|
|
7
|
+
Environment["MockServer"] = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.89.0";
|
|
8
8
|
})(Environment || (exports.Environment = Environment = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A local download failure after a project has completed remotely.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DownloadError extends Error {
|
|
5
|
+
readonly downloadedPaths: string[];
|
|
6
|
+
readonly downloadErrors: {
|
|
7
|
+
stage: "directory" | "file";
|
|
8
|
+
message: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
}[];
|
|
11
|
+
constructor(downloadedPaths: string[], downloadErrors: {
|
|
12
|
+
stage: "directory" | "file";
|
|
13
|
+
message: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}[]);
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DownloadError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A local download failure after a project has completed remotely.
|
|
6
|
+
*/
|
|
7
|
+
class DownloadError extends Error {
|
|
8
|
+
constructor(downloadedPaths, downloadErrors) {
|
|
9
|
+
super("Generated outputs could not all be downloaded. Retry the download URLs without generating again.");
|
|
10
|
+
this.downloadedPaths = downloadedPaths;
|
|
11
|
+
this.downloadErrors = downloadErrors;
|
|
12
|
+
this.name = "DownloadError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.DownloadError = DownloadError;
|
package/dist/helpers/download.js
CHANGED
|
@@ -50,17 +50,29 @@ const fs = __importStar(require("fs"));
|
|
|
50
50
|
const path = __importStar(require("path"));
|
|
51
51
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
52
52
|
const logger_1 = require("../logger.js");
|
|
53
|
+
const download_error_1 = require("./download-error.js");
|
|
53
54
|
/**
|
|
54
55
|
* Download files from the given download URLs
|
|
55
56
|
*/
|
|
56
57
|
function downloadFiles(downloads, downloadDirectory) {
|
|
57
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
59
|
const downloadedPaths = [];
|
|
60
|
+
const downloadErrors = [];
|
|
59
61
|
// Use current working directory if no download directory specified
|
|
60
62
|
const baseDir = downloadDirectory || process.cwd();
|
|
61
63
|
// Ensure the download directory exists
|
|
62
|
-
|
|
63
|
-
fs.
|
|
64
|
+
try {
|
|
65
|
+
if (!fs.existsSync(baseDir)) {
|
|
66
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw new download_error_1.DownloadError([], [
|
|
71
|
+
{
|
|
72
|
+
stage: "directory",
|
|
73
|
+
message: error instanceof Error ? error.message : String(error),
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
64
76
|
}
|
|
65
77
|
(0, logger_1.getLogger)().debug(`Downloading outputs to ${baseDir}`);
|
|
66
78
|
for (const download of downloads) {
|
|
@@ -80,9 +92,17 @@ function downloadFiles(downloads, downloadDirectory) {
|
|
|
80
92
|
downloadedPaths.push(filePath);
|
|
81
93
|
}
|
|
82
94
|
catch (error) {
|
|
95
|
+
downloadErrors.push({
|
|
96
|
+
stage: "file",
|
|
97
|
+
url: download.url,
|
|
98
|
+
message: error instanceof Error ? error.message : String(error),
|
|
99
|
+
});
|
|
83
100
|
(0, logger_1.getLogger)().error(`Error downloading file from ${download.url}: ${error}`);
|
|
84
101
|
}
|
|
85
102
|
}
|
|
103
|
+
if (downloadErrors.length > 0) {
|
|
104
|
+
throw new download_error_1.DownloadError(downloadedPaths, downloadErrors);
|
|
105
|
+
}
|
|
86
106
|
return downloadedPaths;
|
|
87
107
|
});
|
|
88
108
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiMusicGeneratorClient = void 0;
|
|
4
|
+
var resource_client_1 = require("./resource-client");
|
|
5
|
+
Object.defineProperty(exports, "AiMusicGeneratorClient", { enumerable: true, get: function () { return resource_client_1.AiMusicGeneratorClient; } });
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { External$V1AiMusicGeneratorCreateBodyStyle, V1AiMusicGeneratorCreateBodyStyle } from "../../../types/v1-ai-music-generator-create-body-style.js";
|
|
3
|
+
/**
|
|
4
|
+
* CreateRequest
|
|
5
|
+
*/
|
|
6
|
+
export type CreateRequest = {
|
|
7
|
+
/**
|
|
8
|
+
* Requested track duration in seconds, from 15 to 300. Determines credits charged.
|
|
9
|
+
*/
|
|
10
|
+
duration: number;
|
|
11
|
+
/**
|
|
12
|
+
* Give your audio a custom name for easy identification.
|
|
13
|
+
*/
|
|
14
|
+
name?: string | undefined;
|
|
15
|
+
style: V1AiMusicGeneratorCreateBodyStyle;
|
|
16
|
+
[additionalProperty: string]: number | (string | undefined) | V1AiMusicGeneratorCreateBodyStyle | any | null | undefined;
|
|
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
|
+
duration: number;
|
|
25
|
+
name?: string | undefined;
|
|
26
|
+
style: External$V1AiMusicGeneratorCreateBodyStyle;
|
|
27
|
+
[additionalProperty: string]: number | (string | undefined) | External$V1AiMusicGeneratorCreateBodyStyle | External$CreateRequest | null | undefined;
|
|
28
|
+
};
|
|
29
|
+
export declare const Schemas$CreateRequest: {
|
|
30
|
+
in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
|
|
31
|
+
out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
|
|
32
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
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_music_generator_create_body_style_1 = require("../../../types/v1-ai-music-generator-create-body-style.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
|
+
duration: z.number().int(),
|
|
46
|
+
name: z.string().optional(),
|
|
47
|
+
style: v1_ai_music_generator_create_body_style_1.Schemas$V1AiMusicGeneratorCreateBodyStyle.in,
|
|
48
|
+
})
|
|
49
|
+
.catchall(make_api_request_js_1.zodRequiredAny)
|
|
50
|
+
.transform((obj) => {
|
|
51
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
52
|
+
duration: "duration",
|
|
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
|
+
duration: z.number().int(),
|
|
64
|
+
name: z.string().optional(),
|
|
65
|
+
style: v1_ai_music_generator_create_body_style_1.Schemas$V1AiMusicGeneratorCreateBodyStyle.out,
|
|
66
|
+
})
|
|
67
|
+
.catchall(make_api_request_js_1.zodRequiredAny)
|
|
68
|
+
.transform((obj) => {
|
|
69
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
70
|
+
duration: "duration",
|
|
71
|
+
name: "name",
|
|
72
|
+
style: "style",
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
exports.Schemas$CreateRequest = {
|
|
76
|
+
in: SchemaIn$CreateRequest,
|
|
77
|
+
out: SchemaOut$CreateRequest,
|
|
78
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
|
|
2
|
+
import { GenerateOptions } from "../../../helpers/generate-type.js";
|
|
3
|
+
import * as requests from "./request-types.js";
|
|
4
|
+
import * as types from "../../../types/index.js";
|
|
5
|
+
export declare class AiMusicGeneratorClient extends CoreResourceClient {
|
|
6
|
+
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
7
|
+
/**
|
|
8
|
+
* Generate music with automatic polling and downloads.
|
|
9
|
+
*
|
|
10
|
+
* Accepts the same request fields as create(). By default, waits for completion
|
|
11
|
+
* and downloads outputs. Use opts to disable waiting or downloading, or set
|
|
12
|
+
* the download directory.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const result = await client.v1.aiMusicGenerator.generate({
|
|
17
|
+
* duration: 120,
|
|
18
|
+
* style: { prompt: "Dreamy synthwave with warm bass" },
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
generate(request: requests.CreateRequest, opts?: GenerateOptions): Promise<import("../audio-projects/resource-client").V1AudioProjectsGetResponseWithDownloads>;
|
|
23
|
+
/**
|
|
24
|
+
* AI Music Generator
|
|
25
|
+
*
|
|
26
|
+
* Generate music from a description, with optional custom lyrics or instrumental-only output. Costs 1 credits per requested second. Returns a project ID; poll GET /v1/audio-projects/{id} for status and downloads.
|
|
27
|
+
*
|
|
28
|
+
* POST /v1/ai-music-generator
|
|
29
|
+
*/
|
|
30
|
+
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiMusicGeneratorCreateResponse>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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.AiMusicGeneratorClient = void 0;
|
|
24
|
+
const make_api_request_js_1 = require("make-api-request-js");
|
|
25
|
+
const logger_1 = require("../../../logger.js");
|
|
26
|
+
const audio_projects_1 = require("../audio-projects/index.js");
|
|
27
|
+
const v1_ai_music_generator_create_body_1 = require("../../../types/v1-ai-music-generator-create-body.js");
|
|
28
|
+
const v1_ai_music_generator_create_response_1 = require("../../../types/v1-ai-music-generator-create-response.js");
|
|
29
|
+
class AiMusicGeneratorClient extends make_api_request_js_1.CoreResourceClient {
|
|
30
|
+
constructor(coreClient, opts) {
|
|
31
|
+
super(coreClient, opts);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Generate music with automatic polling and downloads.
|
|
35
|
+
*
|
|
36
|
+
* Accepts the same request fields as create(). By default, waits for completion
|
|
37
|
+
* and downloads outputs. Use opts to disable waiting or downloading, or set
|
|
38
|
+
* the download directory.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const result = await client.v1.aiMusicGenerator.generate({
|
|
43
|
+
* duration: 120,
|
|
44
|
+
* style: { prompt: "Dreamy synthwave with warm bass" },
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
generate(request_1) {
|
|
49
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
50
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
51
|
+
const createResponse = yield this.create(request, createOpts);
|
|
52
|
+
(0, logger_1.getLogger)().info(`Created ai-music-generator project ${createResponse.id}`);
|
|
53
|
+
const projectsClient = new audio_projects_1.AudioProjectsClient(this._client, this._opts);
|
|
54
|
+
return projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
55
|
+
downloadOutputs,
|
|
56
|
+
downloadDirectory }, createOpts));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* AI Music Generator
|
|
61
|
+
*
|
|
62
|
+
* Generate music from a description, with optional custom lyrics or instrumental-only output. Costs 1 credits per requested second. Returns a project ID; poll GET /v1/audio-projects/{id} for status and downloads.
|
|
63
|
+
*
|
|
64
|
+
* POST /v1/ai-music-generator
|
|
65
|
+
*/
|
|
66
|
+
create(request, opts) {
|
|
67
|
+
return this._client.makeRequest({
|
|
68
|
+
method: "post",
|
|
69
|
+
path: "/v1/ai-music-generator",
|
|
70
|
+
auth: ["bearerAuth"],
|
|
71
|
+
contentType: "application/json",
|
|
72
|
+
body: v1_ai_music_generator_create_body_1.Schemas$V1AiMusicGeneratorCreateBody.out.parse(request),
|
|
73
|
+
responseSchema: v1_ai_music_generator_create_response_1.Schemas$V1AiMusicGeneratorCreateResponse.in,
|
|
74
|
+
opts,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.AiMusicGeneratorClient = AiMusicGeneratorClient;
|
|
@@ -14,13 +14,21 @@ export type CreateRequest = {
|
|
|
14
14
|
*/
|
|
15
15
|
endSeconds: number;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Deprecated: use `resolution`. Still accepted as a larger-dimension cap, limited by your plan. Ignored when `resolution` is provided.
|
|
18
|
+
*
|
|
19
|
+
* After plan capping:
|
|
20
|
+
* * Below 1280 maps to `480p` (intermediate values round down).
|
|
21
|
+
* * 1280 or above maps to `720p`.
|
|
18
22
|
*/
|
|
19
23
|
maxResolution?: number | undefined;
|
|
20
24
|
/**
|
|
21
25
|
* Give your video a custom name for easy identification.
|
|
22
26
|
*/
|
|
23
27
|
name?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Output preset. Overrides `max_resolution`. Defaults to 480p in prompted mode; realistic mode uses the mapped plan maximum.
|
|
30
|
+
*/
|
|
31
|
+
resolution?: ("480p" | "720p") | undefined;
|
|
24
32
|
/**
|
|
25
33
|
* The start time of the input audio in seconds. Maximum clip length depends on style.generation_mode: realistic 300s, prompted 45s.
|
|
26
34
|
*/
|
|
@@ -40,6 +48,7 @@ export type External$CreateRequest = {
|
|
|
40
48
|
end_seconds: number;
|
|
41
49
|
max_resolution?: number | undefined;
|
|
42
50
|
name?: string | undefined;
|
|
51
|
+
resolution?: ("480p" | "720p") | undefined;
|
|
43
52
|
start_seconds: number;
|
|
44
53
|
style?: External$V1AiTalkingPhotoCreateBodyStyle | undefined;
|
|
45
54
|
};
|
|
@@ -47,6 +47,7 @@ const SchemaIn$CreateRequest = z
|
|
|
47
47
|
end_seconds: z.number(),
|
|
48
48
|
max_resolution: z.number().int().optional(),
|
|
49
49
|
name: z.string().optional(),
|
|
50
|
+
resolution: z.enum(["480p", "720p"]).optional(),
|
|
50
51
|
start_seconds: z.number(),
|
|
51
52
|
style: v1_ai_talking_photo_create_body_style_1.Schemas$V1AiTalkingPhotoCreateBodyStyle.in.optional(),
|
|
52
53
|
})
|
|
@@ -56,6 +57,7 @@ const SchemaIn$CreateRequest = z
|
|
|
56
57
|
end_seconds: "endSeconds",
|
|
57
58
|
max_resolution: "maxResolution",
|
|
58
59
|
name: "name",
|
|
60
|
+
resolution: "resolution",
|
|
59
61
|
start_seconds: "startSeconds",
|
|
60
62
|
style: "style",
|
|
61
63
|
});
|
|
@@ -70,6 +72,7 @@ const SchemaOut$CreateRequest = z
|
|
|
70
72
|
endSeconds: z.number(),
|
|
71
73
|
maxResolution: z.number().int().optional(),
|
|
72
74
|
name: z.string().optional(),
|
|
75
|
+
resolution: z.enum(["480p", "720p"]).optional(),
|
|
73
76
|
startSeconds: z.number(),
|
|
74
77
|
style: v1_ai_talking_photo_create_body_style_1.Schemas$V1AiTalkingPhotoCreateBodyStyle.out.optional(),
|
|
75
78
|
})
|
|
@@ -79,6 +82,7 @@ const SchemaOut$CreateRequest = z
|
|
|
79
82
|
endSeconds: "end_seconds",
|
|
80
83
|
maxResolution: "max_resolution",
|
|
81
84
|
name: "name",
|
|
85
|
+
resolution: "resolution",
|
|
82
86
|
startSeconds: "start_seconds",
|
|
83
87
|
style: "style",
|
|
84
88
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiUgcAdClient = void 0;
|
|
4
|
+
var resource_client_1 = require("./resource-client");
|
|
5
|
+
Object.defineProperty(exports, "AiUgcAdClient", { enumerable: true, get: function () { return resource_client_1.AiUgcAdClient; } });
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { External$V1AiUgcAdCreateBodyAssets, V1AiUgcAdCreateBodyAssets } from "../../../types/v1-ai-ugc-ad-create-body-assets.js";
|
|
3
|
+
/**
|
|
4
|
+
* CreateRequest
|
|
5
|
+
*/
|
|
6
|
+
export type CreateRequest = {
|
|
7
|
+
assets: V1AiUgcAdCreateBodyAssets;
|
|
8
|
+
/**
|
|
9
|
+
* Video duration in seconds. Supported values by model:
|
|
10
|
+
* * kling-3.0: 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 seconds.
|
|
11
|
+
* * ltx-2.5: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 seconds.
|
|
12
|
+
* * veo3.1: 4, 6, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 120, 127, 134, 141 seconds.
|
|
13
|
+
* Free plans are limited to 5 seconds unless a credit pack has been purchased.
|
|
14
|
+
*/
|
|
15
|
+
endSeconds: number;
|
|
16
|
+
/**
|
|
17
|
+
* Defaults to kling-3.0 on paid plans and ltx-2.5 on free plans.
|
|
18
|
+
*/
|
|
19
|
+
model?: ("kling-3.0" | "ltx-2.5" | "veo3.1") | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Defaults to 720p on paid plans and 480p on free plans. Unsupported model/resolution combinations and resolutions unavailable for your plan are rejected.
|
|
22
|
+
*/
|
|
23
|
+
resolution?: ("1080p" | "480p" | "720p") | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The words the actor should speak. Character limits apply after trimming:
|
|
26
|
+
* * kling-3.0: 2500 characters.
|
|
27
|
+
* * ltx-2.5: 1804 characters.
|
|
28
|
+
* * veo3.1: 2500 characters.
|
|
29
|
+
* LTX's dialogue wrapper counts toward its model prompt limit.
|
|
30
|
+
*/
|
|
31
|
+
script: string;
|
|
32
|
+
[additionalProperty: string]: V1AiUgcAdCreateBodyAssets | number | (("kling-3.0" | "ltx-2.5" | "veo3.1") | undefined) | (("1080p" | "480p" | "720p") | undefined) | string | any | null | undefined;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
* CreateRequest without any key transformation, this is what
|
|
37
|
+
* we expect to come in as network data
|
|
38
|
+
*/
|
|
39
|
+
export type External$CreateRequest = {
|
|
40
|
+
assets: External$V1AiUgcAdCreateBodyAssets;
|
|
41
|
+
end_seconds: number;
|
|
42
|
+
model?: ("kling-3.0" | "ltx-2.5" | "veo3.1") | undefined;
|
|
43
|
+
resolution?: ("1080p" | "480p" | "720p") | undefined;
|
|
44
|
+
script: string;
|
|
45
|
+
[additionalProperty: string]: External$V1AiUgcAdCreateBodyAssets | number | (("kling-3.0" | "ltx-2.5" | "veo3.1") | undefined) | (("1080p" | "480p" | "720p") | undefined) | string | External$CreateRequest | null | undefined;
|
|
46
|
+
};
|
|
47
|
+
export declare const Schemas$CreateRequest: {
|
|
48
|
+
in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
|
|
49
|
+
out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
|
|
50
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
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_ugc_ad_create_body_assets_1 = require("../../../types/v1-ai-ugc-ad-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_ugc_ad_create_body_assets_1.Schemas$V1AiUgcAdCreateBodyAssets.in,
|
|
46
|
+
end_seconds: z.number(),
|
|
47
|
+
model: z.enum(["kling-3.0", "ltx-2.5", "veo3.1"]).optional(),
|
|
48
|
+
resolution: z.enum(["1080p", "480p", "720p"]).optional(),
|
|
49
|
+
script: z.string(),
|
|
50
|
+
})
|
|
51
|
+
.catchall(make_api_request_js_1.zodRequiredAny)
|
|
52
|
+
.transform((obj) => {
|
|
53
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
54
|
+
assets: "assets",
|
|
55
|
+
end_seconds: "endSeconds",
|
|
56
|
+
model: "model",
|
|
57
|
+
resolution: "resolution",
|
|
58
|
+
script: "script",
|
|
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_ugc_ad_create_body_assets_1.Schemas$V1AiUgcAdCreateBodyAssets.out,
|
|
68
|
+
endSeconds: z.number(),
|
|
69
|
+
model: z.enum(["kling-3.0", "ltx-2.5", "veo3.1"]).optional(),
|
|
70
|
+
resolution: z.enum(["1080p", "480p", "720p"]).optional(),
|
|
71
|
+
script: z.string(),
|
|
72
|
+
})
|
|
73
|
+
.catchall(make_api_request_js_1.zodRequiredAny)
|
|
74
|
+
.transform((obj) => {
|
|
75
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
76
|
+
assets: "assets",
|
|
77
|
+
endSeconds: "end_seconds",
|
|
78
|
+
model: "model",
|
|
79
|
+
resolution: "resolution",
|
|
80
|
+
script: "script",
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
exports.Schemas$CreateRequest = {
|
|
84
|
+
in: SchemaIn$CreateRequest,
|
|
85
|
+
out: SchemaOut$CreateRequest,
|
|
86
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
|
|
2
|
+
import { GenerateOptions } from "../../../helpers/generate-type.js";
|
|
3
|
+
import * as requests from "./request-types.js";
|
|
4
|
+
import * as types from "../../../types/index.js";
|
|
5
|
+
type GenerateRequest = requests.CreateRequest & {
|
|
6
|
+
assets: {
|
|
7
|
+
/**
|
|
8
|
+
* Prepared image to animate. Accepts a local image path or a direct URL.
|
|
9
|
+
* Paths beginning with `api-assets` are already uploaded and reused as is.
|
|
10
|
+
*/
|
|
11
|
+
imageFilePath: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare class AiUgcAdClient extends CoreResourceClient {
|
|
15
|
+
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Generate a UGC ad with automatic image upload, polling, and downloads.
|
|
18
|
+
*
|
|
19
|
+
* Accepts the same request fields as create(), including model and resolution.
|
|
20
|
+
* The prepared image may be a local path, URL, or existing api-assets path.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const result = await client.v1.aiUgcAd.generate({
|
|
25
|
+
* assets: { imageFilePath: "path/to/image.jpg" },
|
|
26
|
+
* endSeconds: 4,
|
|
27
|
+
* script: "Meet your new everyday essential.",
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../video-projects/resource-client").V1VideoProjectsGetResponseWithDownloads>;
|
|
32
|
+
/**
|
|
33
|
+
* AI UGC Ad Generator
|
|
34
|
+
*
|
|
35
|
+
* 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.
|
|
36
|
+
*
|
|
37
|
+
* POST /v1/ai-ugc-ad
|
|
38
|
+
*/
|
|
39
|
+
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiUgcAdCreateResponse>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|