UNPKG

assetmax

Version:

Manifest-driven asset management system with contract-based generation

78 lines 2.43 kB
"use strict"; /** * Veo 3 Fast model integration (TypeScript version) */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.VeoModel = void 0; const replicate_1 = __importDefault(require("replicate")); class VeoModel { client; modelName = 'google-deepmind/veo-3-fast'; aspectRatios = ['16:9', '9:16', '1:1', '4:3', '3:4']; constructor(apiToken) { const token = apiToken || process.env.REPLICATE_API_TOKEN; if (!token) { throw new Error('REPLICATE_API_TOKEN environment variable is required'); } this.client = new replicate_1.default({ auth: token }); } /** * Generate video using Veo 3 Fast */ async generate(options) { const { prompt, aspectRatio = '16:9', duration = 5, seed = null } = options; // Validate inputs if (!this.aspectRatios.includes(aspectRatio)) { throw new Error(`Invalid aspect ratio: ${aspectRatio}`); } if (duration < 1 || duration > 30) { throw new Error('Duration must be between 1 and 30 seconds'); } // Prepare model inputs const modelInput = { prompt, aspect_ratio: aspectRatio, duration }; // Add seed if provided if (seed !== null) { modelInput.seed = seed; } try { // Run the model const output = await this.client.run(this.modelName, { input: modelInput }); let outputUrl; if (Array.isArray(output)) { outputUrl = output[0]; } else { outputUrl = output; } if (!outputUrl) { throw new Error('Model returned no output'); } return outputUrl; } catch (error) { throw new Error(`Model execution failed: ${error.message}`); } } /** * Get model information */ getModelInfo() { return { name: this.modelName, supportedAspectRatios: this.aspectRatios, maxDuration: 30, costPerVideo: 0.050 // $0.050 per video }; } } exports.VeoModel = VeoModel; //# sourceMappingURL=veo.js.map