UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

120 lines (119 loc) 5.17 kB
/** * Vertex AI Video Generation Handler * * Standalone module for Veo 3.1 video generation via Vertex AI. * Generates videos from an input image and text prompt. * * Based on Vertex AI Veo 3.1 video generation API * * @module adapters/video/vertexVideoHandler * @see https://cloud.google.com/vertex-ai/generative-ai/docs/video/generate-videos */ import { ErrorCategory, ErrorSeverity } from "../../constants/enums.js"; import { VIDEO_ERROR_CODES } from "../../constants/videoErrors.js"; import type { VideoGenerationResult, VideoOutputOptions } from "../../types/index.js"; import { NeuroLinkError } from "../../utils/errorHandling.js"; /** * Video error codes - re-exported from constants module for backward compatibility. * @see {@link VIDEO_ERROR_CODES} in constants/videoErrors.ts for definitions */ export { VIDEO_ERROR_CODES }; /** * Video generation error class * Extends NeuroLinkError for consistent error handling across the SDK */ export declare class VideoError extends NeuroLinkError { constructor(options: { code: string; message: string; category?: ErrorCategory; severity?: ErrorSeverity; retriable?: boolean; context?: Record<string, unknown>; originalError?: Error; }); } /** * Check if Vertex AI is configured for video generation * * @returns True if Google Cloud credentials are available * * @example * ```typescript * if (!isVertexVideoConfigured()) { * console.error("Set GOOGLE_APPLICATION_CREDENTIALS to enable video generation"); * } * ``` */ export declare function isVertexVideoConfigured(): boolean; /** * Generate video using Vertex AI Veo 3.1 * * Creates a video from an input image and text prompt using Google's Veo 3.1 model. * The video is generated with optional audio and can be customized for resolution, * duration, and aspect ratio. * * @param image - Input image buffer (JPEG, PNG, or WebP) * @param prompt - Text prompt describing desired video motion/content (max 500 chars) * @param options - Video output options (resolution, length, aspect ratio, audio) * @returns VideoGenerationResult with video buffer and metadata * * @throws {VideoError} When credentials are not configured (PROVIDER_NOT_CONFIGURED) * @throws {VideoError} When API returns an error (GENERATION_FAILED) * @throws {VideoError} When polling times out (POLL_TIMEOUT) * * @example * ```typescript * import { generateVideoWithVertex } from "@juspay/neurolink/adapters/video/vertexVideoHandler"; * import { readFileSync, writeFileSync } from "fs"; * * const image = readFileSync("./input.png"); * const result = await generateVideoWithVertex( * image, * "Smooth cinematic camera movement with dramatic lighting", * { resolution: "720p", length: 6, aspectRatio: "16:9", audio: true } * ); * * writeFileSync("output.mp4", result.data); * ``` */ export declare function generateVideoWithVertex(image: Buffer, prompt: string, options?: VideoOutputOptions, region?: string): Promise<VideoGenerationResult>; /** * Generate a transition clip using Veo 3.1 Fast's first-and-last-frame interpolation. * * This calls the Veo API with both `image` (first frame) and `lastFrame` (last frame), * producing a video that smoothly interpolates between the two frames. * * @param firstFrame - JPEG buffer of the first frame (last frame of clip N) * @param lastFrame - JPEG buffer of the last frame (first frame of clip N+1) * @param prompt - Transition prompt describing desired visual flow * @param options - Video output options (resolution, aspect ratio, audio) * @param durationSeconds - Duration of the transition clip (4, 6, or 8) * @param region - Vertex AI region override * @returns Video buffer of the transition clip * * @throws {VideoError} When API returns an error or polling times out */ export declare function generateTransitionWithVertex(firstFrame: Buffer, lastFrame: Buffer, prompt: string, options?: { aspectRatio?: "9:16" | "16:9" | "1:1" | string; resolution?: "720p" | "1080p"; audio?: boolean; }, durationSeconds?: 4 | 6 | 8, region?: string): Promise<Buffer>; import type { VideoHandler, VideoTransitionOptions } from "../../types/index.js"; /** * Class wrapper around the standalone Vertex Veo functions, conforming to * the `VideoHandler` contract so it can register with `VideoProcessor`. * * The free functions (`generateVideoWithVertex`, `generateTransitionWithVertex`, * `isVertexVideoConfigured`) are kept exported for backward compatibility — * external callers (Director's `directorPipeline.ts`, test scripts) reference * them directly. */ export declare class VertexVideoHandler implements VideoHandler { readonly maxDurationSeconds = 8; readonly supportedAspectRatios: readonly ("9:16" | "16:9")[]; readonly supportedResolutions: readonly ("720p" | "1080p")[]; isConfigured(): boolean; generate(image: Buffer, prompt: string, options: VideoOutputOptions, region?: string): Promise<VideoGenerationResult>; generateTransition(firstFrame: Buffer, lastFrame: Buffer, prompt: string, options?: VideoTransitionOptions, region?: string): Promise<Buffer>; }