@blinkdotnew/sdk 2.1.1 → 2.2.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/dist/index.d.mts +128 -0
- package/dist/index.d.ts +128 -0
- package/dist/index.js +136 -0
- package/dist/index.mjs +136 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -481,6 +481,45 @@ interface TranscriptionRequest {
|
|
|
481
481
|
response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
|
|
482
482
|
signal?: AbortSignal;
|
|
483
483
|
}
|
|
484
|
+
interface VideoGenerationRequest {
|
|
485
|
+
prompt: string;
|
|
486
|
+
model?: string;
|
|
487
|
+
image_url?: string;
|
|
488
|
+
duration?: string;
|
|
489
|
+
aspect_ratio?: string;
|
|
490
|
+
resolution?: string;
|
|
491
|
+
negative_prompt?: string;
|
|
492
|
+
generate_audio?: boolean;
|
|
493
|
+
seed?: number;
|
|
494
|
+
cfg_scale?: number;
|
|
495
|
+
signal?: AbortSignal;
|
|
496
|
+
}
|
|
497
|
+
interface VideoGenerationResponse {
|
|
498
|
+
result: {
|
|
499
|
+
video: {
|
|
500
|
+
url: string;
|
|
501
|
+
content_type?: string;
|
|
502
|
+
file_name?: string;
|
|
503
|
+
file_size?: number;
|
|
504
|
+
};
|
|
505
|
+
seed?: number;
|
|
506
|
+
video_id?: string;
|
|
507
|
+
thumbnail?: {
|
|
508
|
+
url: string;
|
|
509
|
+
};
|
|
510
|
+
};
|
|
511
|
+
metadata?: {
|
|
512
|
+
projectId: string;
|
|
513
|
+
timestamp: string;
|
|
514
|
+
provider: string;
|
|
515
|
+
model: string;
|
|
516
|
+
};
|
|
517
|
+
usage?: {
|
|
518
|
+
creditsCharged: number;
|
|
519
|
+
costUSD: number;
|
|
520
|
+
model: string;
|
|
521
|
+
};
|
|
522
|
+
}
|
|
484
523
|
interface TranscriptionResponse {
|
|
485
524
|
text: string;
|
|
486
525
|
transcript?: string;
|
|
@@ -519,6 +558,7 @@ interface BlinkAI {
|
|
|
519
558
|
background?: "auto" | "transparent" | "opaque";
|
|
520
559
|
signal?: AbortSignal;
|
|
521
560
|
}): Promise<ImageGenerationResponse>;
|
|
561
|
+
generateVideo(options: VideoGenerationRequest): Promise<VideoGenerationResponse>;
|
|
522
562
|
generateSpeech(options: SpeechGenerationRequest): Promise<SpeechGenerationResponse>;
|
|
523
563
|
transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
|
|
524
564
|
}
|
|
@@ -936,6 +976,18 @@ declare class HttpClient {
|
|
|
936
976
|
response_format?: string;
|
|
937
977
|
signal?: AbortSignal;
|
|
938
978
|
}): Promise<BlinkResponse<any>>;
|
|
979
|
+
aiVideo(prompt: string, options?: {
|
|
980
|
+
model?: string;
|
|
981
|
+
image_url?: string;
|
|
982
|
+
duration?: string;
|
|
983
|
+
aspect_ratio?: string;
|
|
984
|
+
resolution?: string;
|
|
985
|
+
negative_prompt?: string;
|
|
986
|
+
generate_audio?: boolean;
|
|
987
|
+
seed?: number;
|
|
988
|
+
cfg_scale?: number;
|
|
989
|
+
signal?: AbortSignal;
|
|
990
|
+
}): Promise<BlinkResponse<any>>;
|
|
939
991
|
/**
|
|
940
992
|
* Data-specific requests
|
|
941
993
|
*/
|
|
@@ -2209,6 +2261,82 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
2209
2261
|
n?: number;
|
|
2210
2262
|
signal?: AbortSignal;
|
|
2211
2263
|
}): Promise<ImageGenerationResponse>;
|
|
2264
|
+
/**
|
|
2265
|
+
* Generates videos from text prompts or images using AI video generation models.
|
|
2266
|
+
*
|
|
2267
|
+
* @param options - Object containing:
|
|
2268
|
+
* - `prompt`: Text description of the video to generate (required)
|
|
2269
|
+
* - `model`: Video model to use (optional). Available models:
|
|
2270
|
+
* **Text-to-Video Models:**
|
|
2271
|
+
* - `"fal-ai/veo3.1"` - Google Veo 3.1 (best quality)
|
|
2272
|
+
* - `"fal-ai/veo3.1/fast"` (default) - Veo 3.1 fast mode (faster, cheaper)
|
|
2273
|
+
* - `"fal-ai/sora-2/text-to-video/pro"` - OpenAI Sora 2
|
|
2274
|
+
* - `"fal-ai/kling-video/v2.6/pro/text-to-video"` - Kling 2.6
|
|
2275
|
+
* **Image-to-Video Models:**
|
|
2276
|
+
* - `"fal-ai/veo3.1/image-to-video"` - Veo 3.1 I2V
|
|
2277
|
+
* - `"fal-ai/veo3.1/fast/image-to-video"` - Veo 3.1 fast I2V
|
|
2278
|
+
* - `"fal-ai/sora-2/image-to-video/pro"` - Sora 2 I2V
|
|
2279
|
+
* - `"fal-ai/kling-video/v2.6/pro/image-to-video"` - Kling 2.6 I2V
|
|
2280
|
+
* - `image_url`: Source image URL for image-to-video (required for I2V models)
|
|
2281
|
+
* - `duration`: Video duration ("4s", "5s", "6s", "8s", "10s", "12s")
|
|
2282
|
+
* - `aspect_ratio`: Aspect ratio ("16:9", "9:16", "1:1")
|
|
2283
|
+
* - `resolution`: Resolution ("720p", "1080p") - Veo/Sora only
|
|
2284
|
+
* - `negative_prompt`: What to avoid in generation - Veo/Kling only
|
|
2285
|
+
* - `generate_audio`: Generate audio with video (default: true)
|
|
2286
|
+
* - `seed`: For reproducibility - Veo only
|
|
2287
|
+
* - `cfg_scale`: Guidance scale (0-1) - Kling only
|
|
2288
|
+
* - Plus optional signal parameter
|
|
2289
|
+
*
|
|
2290
|
+
* @example
|
|
2291
|
+
* ```ts
|
|
2292
|
+
* // Basic text-to-video generation (uses default fast model)
|
|
2293
|
+
* const { result } = await blink.ai.generateVideo({
|
|
2294
|
+
* prompt: "A serene sunset over the ocean with gentle waves"
|
|
2295
|
+
* });
|
|
2296
|
+
* console.log("Video URL:", result.video.url);
|
|
2297
|
+
*
|
|
2298
|
+
* // High quality with Veo 3.1
|
|
2299
|
+
* const { result } = await blink.ai.generateVideo({
|
|
2300
|
+
* prompt: "A cinematic shot of a futuristic city at night",
|
|
2301
|
+
* model: "fal-ai/veo3.1",
|
|
2302
|
+
* resolution: "1080p",
|
|
2303
|
+
* aspect_ratio: "16:9"
|
|
2304
|
+
* });
|
|
2305
|
+
*
|
|
2306
|
+
* // Image-to-video animation
|
|
2307
|
+
* const { result } = await blink.ai.generateVideo({
|
|
2308
|
+
* prompt: "Animate this image with gentle camera movement",
|
|
2309
|
+
* model: "fal-ai/veo3.1/fast/image-to-video",
|
|
2310
|
+
* image_url: "https://example.com/my-image.jpg",
|
|
2311
|
+
* duration: "5s"
|
|
2312
|
+
* });
|
|
2313
|
+
*
|
|
2314
|
+
* // Using Sora 2 for creative videos
|
|
2315
|
+
* const { result } = await blink.ai.generateVideo({
|
|
2316
|
+
* prompt: "A magical forest with glowing fireflies",
|
|
2317
|
+
* model: "fal-ai/sora-2/text-to-video/pro",
|
|
2318
|
+
* duration: "8s"
|
|
2319
|
+
* });
|
|
2320
|
+
*
|
|
2321
|
+
* // Using Kling for detailed videos
|
|
2322
|
+
* const { result, usage } = await blink.ai.generateVideo({
|
|
2323
|
+
* prompt: "A professional cooking tutorial scene",
|
|
2324
|
+
* model: "fal-ai/kling-video/v2.6/pro/text-to-video",
|
|
2325
|
+
* negative_prompt: "blur, distort, low quality",
|
|
2326
|
+
* cfg_scale: 0.7
|
|
2327
|
+
* });
|
|
2328
|
+
* console.log("Credits charged:", usage?.creditsCharged);
|
|
2329
|
+
* ```
|
|
2330
|
+
*
|
|
2331
|
+
* @returns Promise<VideoGenerationResponse> - Object containing:
|
|
2332
|
+
* - `result.video.url`: URL to the generated video
|
|
2333
|
+
* - `result.video.content_type`: MIME type (video/mp4)
|
|
2334
|
+
* - `result.video.file_name`: Generated filename
|
|
2335
|
+
* - `result.video.file_size`: File size in bytes
|
|
2336
|
+
* - `metadata`: Generation metadata (projectId, timestamp, model)
|
|
2337
|
+
* - `usage`: Credits charged and cost information
|
|
2338
|
+
*/
|
|
2339
|
+
generateVideo(options: VideoGenerationRequest): Promise<VideoGenerationResponse>;
|
|
2212
2340
|
/**
|
|
2213
2341
|
* Converts text to speech using AI voice synthesis models.
|
|
2214
2342
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -481,6 +481,45 @@ interface TranscriptionRequest {
|
|
|
481
481
|
response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
|
|
482
482
|
signal?: AbortSignal;
|
|
483
483
|
}
|
|
484
|
+
interface VideoGenerationRequest {
|
|
485
|
+
prompt: string;
|
|
486
|
+
model?: string;
|
|
487
|
+
image_url?: string;
|
|
488
|
+
duration?: string;
|
|
489
|
+
aspect_ratio?: string;
|
|
490
|
+
resolution?: string;
|
|
491
|
+
negative_prompt?: string;
|
|
492
|
+
generate_audio?: boolean;
|
|
493
|
+
seed?: number;
|
|
494
|
+
cfg_scale?: number;
|
|
495
|
+
signal?: AbortSignal;
|
|
496
|
+
}
|
|
497
|
+
interface VideoGenerationResponse {
|
|
498
|
+
result: {
|
|
499
|
+
video: {
|
|
500
|
+
url: string;
|
|
501
|
+
content_type?: string;
|
|
502
|
+
file_name?: string;
|
|
503
|
+
file_size?: number;
|
|
504
|
+
};
|
|
505
|
+
seed?: number;
|
|
506
|
+
video_id?: string;
|
|
507
|
+
thumbnail?: {
|
|
508
|
+
url: string;
|
|
509
|
+
};
|
|
510
|
+
};
|
|
511
|
+
metadata?: {
|
|
512
|
+
projectId: string;
|
|
513
|
+
timestamp: string;
|
|
514
|
+
provider: string;
|
|
515
|
+
model: string;
|
|
516
|
+
};
|
|
517
|
+
usage?: {
|
|
518
|
+
creditsCharged: number;
|
|
519
|
+
costUSD: number;
|
|
520
|
+
model: string;
|
|
521
|
+
};
|
|
522
|
+
}
|
|
484
523
|
interface TranscriptionResponse {
|
|
485
524
|
text: string;
|
|
486
525
|
transcript?: string;
|
|
@@ -519,6 +558,7 @@ interface BlinkAI {
|
|
|
519
558
|
background?: "auto" | "transparent" | "opaque";
|
|
520
559
|
signal?: AbortSignal;
|
|
521
560
|
}): Promise<ImageGenerationResponse>;
|
|
561
|
+
generateVideo(options: VideoGenerationRequest): Promise<VideoGenerationResponse>;
|
|
522
562
|
generateSpeech(options: SpeechGenerationRequest): Promise<SpeechGenerationResponse>;
|
|
523
563
|
transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
|
|
524
564
|
}
|
|
@@ -936,6 +976,18 @@ declare class HttpClient {
|
|
|
936
976
|
response_format?: string;
|
|
937
977
|
signal?: AbortSignal;
|
|
938
978
|
}): Promise<BlinkResponse<any>>;
|
|
979
|
+
aiVideo(prompt: string, options?: {
|
|
980
|
+
model?: string;
|
|
981
|
+
image_url?: string;
|
|
982
|
+
duration?: string;
|
|
983
|
+
aspect_ratio?: string;
|
|
984
|
+
resolution?: string;
|
|
985
|
+
negative_prompt?: string;
|
|
986
|
+
generate_audio?: boolean;
|
|
987
|
+
seed?: number;
|
|
988
|
+
cfg_scale?: number;
|
|
989
|
+
signal?: AbortSignal;
|
|
990
|
+
}): Promise<BlinkResponse<any>>;
|
|
939
991
|
/**
|
|
940
992
|
* Data-specific requests
|
|
941
993
|
*/
|
|
@@ -2209,6 +2261,82 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
2209
2261
|
n?: number;
|
|
2210
2262
|
signal?: AbortSignal;
|
|
2211
2263
|
}): Promise<ImageGenerationResponse>;
|
|
2264
|
+
/**
|
|
2265
|
+
* Generates videos from text prompts or images using AI video generation models.
|
|
2266
|
+
*
|
|
2267
|
+
* @param options - Object containing:
|
|
2268
|
+
* - `prompt`: Text description of the video to generate (required)
|
|
2269
|
+
* - `model`: Video model to use (optional). Available models:
|
|
2270
|
+
* **Text-to-Video Models:**
|
|
2271
|
+
* - `"fal-ai/veo3.1"` - Google Veo 3.1 (best quality)
|
|
2272
|
+
* - `"fal-ai/veo3.1/fast"` (default) - Veo 3.1 fast mode (faster, cheaper)
|
|
2273
|
+
* - `"fal-ai/sora-2/text-to-video/pro"` - OpenAI Sora 2
|
|
2274
|
+
* - `"fal-ai/kling-video/v2.6/pro/text-to-video"` - Kling 2.6
|
|
2275
|
+
* **Image-to-Video Models:**
|
|
2276
|
+
* - `"fal-ai/veo3.1/image-to-video"` - Veo 3.1 I2V
|
|
2277
|
+
* - `"fal-ai/veo3.1/fast/image-to-video"` - Veo 3.1 fast I2V
|
|
2278
|
+
* - `"fal-ai/sora-2/image-to-video/pro"` - Sora 2 I2V
|
|
2279
|
+
* - `"fal-ai/kling-video/v2.6/pro/image-to-video"` - Kling 2.6 I2V
|
|
2280
|
+
* - `image_url`: Source image URL for image-to-video (required for I2V models)
|
|
2281
|
+
* - `duration`: Video duration ("4s", "5s", "6s", "8s", "10s", "12s")
|
|
2282
|
+
* - `aspect_ratio`: Aspect ratio ("16:9", "9:16", "1:1")
|
|
2283
|
+
* - `resolution`: Resolution ("720p", "1080p") - Veo/Sora only
|
|
2284
|
+
* - `negative_prompt`: What to avoid in generation - Veo/Kling only
|
|
2285
|
+
* - `generate_audio`: Generate audio with video (default: true)
|
|
2286
|
+
* - `seed`: For reproducibility - Veo only
|
|
2287
|
+
* - `cfg_scale`: Guidance scale (0-1) - Kling only
|
|
2288
|
+
* - Plus optional signal parameter
|
|
2289
|
+
*
|
|
2290
|
+
* @example
|
|
2291
|
+
* ```ts
|
|
2292
|
+
* // Basic text-to-video generation (uses default fast model)
|
|
2293
|
+
* const { result } = await blink.ai.generateVideo({
|
|
2294
|
+
* prompt: "A serene sunset over the ocean with gentle waves"
|
|
2295
|
+
* });
|
|
2296
|
+
* console.log("Video URL:", result.video.url);
|
|
2297
|
+
*
|
|
2298
|
+
* // High quality with Veo 3.1
|
|
2299
|
+
* const { result } = await blink.ai.generateVideo({
|
|
2300
|
+
* prompt: "A cinematic shot of a futuristic city at night",
|
|
2301
|
+
* model: "fal-ai/veo3.1",
|
|
2302
|
+
* resolution: "1080p",
|
|
2303
|
+
* aspect_ratio: "16:9"
|
|
2304
|
+
* });
|
|
2305
|
+
*
|
|
2306
|
+
* // Image-to-video animation
|
|
2307
|
+
* const { result } = await blink.ai.generateVideo({
|
|
2308
|
+
* prompt: "Animate this image with gentle camera movement",
|
|
2309
|
+
* model: "fal-ai/veo3.1/fast/image-to-video",
|
|
2310
|
+
* image_url: "https://example.com/my-image.jpg",
|
|
2311
|
+
* duration: "5s"
|
|
2312
|
+
* });
|
|
2313
|
+
*
|
|
2314
|
+
* // Using Sora 2 for creative videos
|
|
2315
|
+
* const { result } = await blink.ai.generateVideo({
|
|
2316
|
+
* prompt: "A magical forest with glowing fireflies",
|
|
2317
|
+
* model: "fal-ai/sora-2/text-to-video/pro",
|
|
2318
|
+
* duration: "8s"
|
|
2319
|
+
* });
|
|
2320
|
+
*
|
|
2321
|
+
* // Using Kling for detailed videos
|
|
2322
|
+
* const { result, usage } = await blink.ai.generateVideo({
|
|
2323
|
+
* prompt: "A professional cooking tutorial scene",
|
|
2324
|
+
* model: "fal-ai/kling-video/v2.6/pro/text-to-video",
|
|
2325
|
+
* negative_prompt: "blur, distort, low quality",
|
|
2326
|
+
* cfg_scale: 0.7
|
|
2327
|
+
* });
|
|
2328
|
+
* console.log("Credits charged:", usage?.creditsCharged);
|
|
2329
|
+
* ```
|
|
2330
|
+
*
|
|
2331
|
+
* @returns Promise<VideoGenerationResponse> - Object containing:
|
|
2332
|
+
* - `result.video.url`: URL to the generated video
|
|
2333
|
+
* - `result.video.content_type`: MIME type (video/mp4)
|
|
2334
|
+
* - `result.video.file_name`: Generated filename
|
|
2335
|
+
* - `result.video.file_size`: File size in bytes
|
|
2336
|
+
* - `metadata`: Generation metadata (projectId, timestamp, model)
|
|
2337
|
+
* - `usage`: Credits charged and cost information
|
|
2338
|
+
*/
|
|
2339
|
+
generateVideo(options: VideoGenerationRequest): Promise<VideoGenerationResponse>;
|
|
2212
2340
|
/**
|
|
2213
2341
|
* Converts text to speech using AI voice synthesis models.
|
|
2214
2342
|
*
|
package/dist/index.js
CHANGED
|
@@ -885,6 +885,17 @@ var HttpClient = class {
|
|
|
885
885
|
signal
|
|
886
886
|
});
|
|
887
887
|
}
|
|
888
|
+
async aiVideo(prompt, options = {}) {
|
|
889
|
+
const { signal, ...body } = options;
|
|
890
|
+
return this.request(`/api/ai/${this.projectId}/video`, {
|
|
891
|
+
method: "POST",
|
|
892
|
+
body: {
|
|
893
|
+
prompt,
|
|
894
|
+
...body
|
|
895
|
+
},
|
|
896
|
+
signal
|
|
897
|
+
});
|
|
898
|
+
}
|
|
888
899
|
/**
|
|
889
900
|
* Data-specific requests
|
|
890
901
|
*/
|
|
@@ -4279,6 +4290,131 @@ var BlinkAIImpl = class {
|
|
|
4279
4290
|
);
|
|
4280
4291
|
}
|
|
4281
4292
|
}
|
|
4293
|
+
/**
|
|
4294
|
+
* Generates videos from text prompts or images using AI video generation models.
|
|
4295
|
+
*
|
|
4296
|
+
* @param options - Object containing:
|
|
4297
|
+
* - `prompt`: Text description of the video to generate (required)
|
|
4298
|
+
* - `model`: Video model to use (optional). Available models:
|
|
4299
|
+
* **Text-to-Video Models:**
|
|
4300
|
+
* - `"fal-ai/veo3.1"` - Google Veo 3.1 (best quality)
|
|
4301
|
+
* - `"fal-ai/veo3.1/fast"` (default) - Veo 3.1 fast mode (faster, cheaper)
|
|
4302
|
+
* - `"fal-ai/sora-2/text-to-video/pro"` - OpenAI Sora 2
|
|
4303
|
+
* - `"fal-ai/kling-video/v2.6/pro/text-to-video"` - Kling 2.6
|
|
4304
|
+
* **Image-to-Video Models:**
|
|
4305
|
+
* - `"fal-ai/veo3.1/image-to-video"` - Veo 3.1 I2V
|
|
4306
|
+
* - `"fal-ai/veo3.1/fast/image-to-video"` - Veo 3.1 fast I2V
|
|
4307
|
+
* - `"fal-ai/sora-2/image-to-video/pro"` - Sora 2 I2V
|
|
4308
|
+
* - `"fal-ai/kling-video/v2.6/pro/image-to-video"` - Kling 2.6 I2V
|
|
4309
|
+
* - `image_url`: Source image URL for image-to-video (required for I2V models)
|
|
4310
|
+
* - `duration`: Video duration ("4s", "5s", "6s", "8s", "10s", "12s")
|
|
4311
|
+
* - `aspect_ratio`: Aspect ratio ("16:9", "9:16", "1:1")
|
|
4312
|
+
* - `resolution`: Resolution ("720p", "1080p") - Veo/Sora only
|
|
4313
|
+
* - `negative_prompt`: What to avoid in generation - Veo/Kling only
|
|
4314
|
+
* - `generate_audio`: Generate audio with video (default: true)
|
|
4315
|
+
* - `seed`: For reproducibility - Veo only
|
|
4316
|
+
* - `cfg_scale`: Guidance scale (0-1) - Kling only
|
|
4317
|
+
* - Plus optional signal parameter
|
|
4318
|
+
*
|
|
4319
|
+
* @example
|
|
4320
|
+
* ```ts
|
|
4321
|
+
* // Basic text-to-video generation (uses default fast model)
|
|
4322
|
+
* const { result } = await blink.ai.generateVideo({
|
|
4323
|
+
* prompt: "A serene sunset over the ocean with gentle waves"
|
|
4324
|
+
* });
|
|
4325
|
+
* console.log("Video URL:", result.video.url);
|
|
4326
|
+
*
|
|
4327
|
+
* // High quality with Veo 3.1
|
|
4328
|
+
* const { result } = await blink.ai.generateVideo({
|
|
4329
|
+
* prompt: "A cinematic shot of a futuristic city at night",
|
|
4330
|
+
* model: "fal-ai/veo3.1",
|
|
4331
|
+
* resolution: "1080p",
|
|
4332
|
+
* aspect_ratio: "16:9"
|
|
4333
|
+
* });
|
|
4334
|
+
*
|
|
4335
|
+
* // Image-to-video animation
|
|
4336
|
+
* const { result } = await blink.ai.generateVideo({
|
|
4337
|
+
* prompt: "Animate this image with gentle camera movement",
|
|
4338
|
+
* model: "fal-ai/veo3.1/fast/image-to-video",
|
|
4339
|
+
* image_url: "https://example.com/my-image.jpg",
|
|
4340
|
+
* duration: "5s"
|
|
4341
|
+
* });
|
|
4342
|
+
*
|
|
4343
|
+
* // Using Sora 2 for creative videos
|
|
4344
|
+
* const { result } = await blink.ai.generateVideo({
|
|
4345
|
+
* prompt: "A magical forest with glowing fireflies",
|
|
4346
|
+
* model: "fal-ai/sora-2/text-to-video/pro",
|
|
4347
|
+
* duration: "8s"
|
|
4348
|
+
* });
|
|
4349
|
+
*
|
|
4350
|
+
* // Using Kling for detailed videos
|
|
4351
|
+
* const { result, usage } = await blink.ai.generateVideo({
|
|
4352
|
+
* prompt: "A professional cooking tutorial scene",
|
|
4353
|
+
* model: "fal-ai/kling-video/v2.6/pro/text-to-video",
|
|
4354
|
+
* negative_prompt: "blur, distort, low quality",
|
|
4355
|
+
* cfg_scale: 0.7
|
|
4356
|
+
* });
|
|
4357
|
+
* console.log("Credits charged:", usage?.creditsCharged);
|
|
4358
|
+
* ```
|
|
4359
|
+
*
|
|
4360
|
+
* @returns Promise<VideoGenerationResponse> - Object containing:
|
|
4361
|
+
* - `result.video.url`: URL to the generated video
|
|
4362
|
+
* - `result.video.content_type`: MIME type (video/mp4)
|
|
4363
|
+
* - `result.video.file_name`: Generated filename
|
|
4364
|
+
* - `result.video.file_size`: File size in bytes
|
|
4365
|
+
* - `metadata`: Generation metadata (projectId, timestamp, model)
|
|
4366
|
+
* - `usage`: Credits charged and cost information
|
|
4367
|
+
*/
|
|
4368
|
+
async generateVideo(options) {
|
|
4369
|
+
try {
|
|
4370
|
+
if (!options.prompt) {
|
|
4371
|
+
throw new BlinkAIError("Prompt is required");
|
|
4372
|
+
}
|
|
4373
|
+
const i2vModels = [
|
|
4374
|
+
"fal-ai/veo3.1/image-to-video",
|
|
4375
|
+
"fal-ai/veo3.1/fast/image-to-video",
|
|
4376
|
+
"fal-ai/sora-2/image-to-video/pro",
|
|
4377
|
+
"fal-ai/kling-video/v2.6/pro/image-to-video"
|
|
4378
|
+
];
|
|
4379
|
+
if (options.model && i2vModels.includes(options.model) && !options.image_url) {
|
|
4380
|
+
throw new BlinkAIError("image_url is required for image-to-video models");
|
|
4381
|
+
}
|
|
4382
|
+
if (options.image_url) {
|
|
4383
|
+
const validation = this.validateImageUrl(options.image_url);
|
|
4384
|
+
if (!validation.isValid) {
|
|
4385
|
+
throw new BlinkAIError(`Invalid image_url: ${validation.error}`);
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
const response = await this.httpClient.aiVideo(
|
|
4389
|
+
options.prompt,
|
|
4390
|
+
{
|
|
4391
|
+
model: options.model,
|
|
4392
|
+
image_url: options.image_url,
|
|
4393
|
+
duration: options.duration,
|
|
4394
|
+
aspect_ratio: options.aspect_ratio,
|
|
4395
|
+
resolution: options.resolution,
|
|
4396
|
+
negative_prompt: options.negative_prompt,
|
|
4397
|
+
generate_audio: options.generate_audio,
|
|
4398
|
+
seed: options.seed,
|
|
4399
|
+
cfg_scale: options.cfg_scale,
|
|
4400
|
+
signal: options.signal
|
|
4401
|
+
}
|
|
4402
|
+
);
|
|
4403
|
+
if (!response.data?.result?.video?.url) {
|
|
4404
|
+
throw new BlinkAIError("Invalid response format: missing video URL");
|
|
4405
|
+
}
|
|
4406
|
+
return response.data;
|
|
4407
|
+
} catch (error) {
|
|
4408
|
+
if (error instanceof BlinkAIError) {
|
|
4409
|
+
throw error;
|
|
4410
|
+
}
|
|
4411
|
+
throw new BlinkAIError(
|
|
4412
|
+
`Video generation failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
4413
|
+
void 0,
|
|
4414
|
+
{ originalError: error }
|
|
4415
|
+
);
|
|
4416
|
+
}
|
|
4417
|
+
}
|
|
4282
4418
|
/**
|
|
4283
4419
|
* Converts text to speech using AI voice synthesis models.
|
|
4284
4420
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -883,6 +883,17 @@ var HttpClient = class {
|
|
|
883
883
|
signal
|
|
884
884
|
});
|
|
885
885
|
}
|
|
886
|
+
async aiVideo(prompt, options = {}) {
|
|
887
|
+
const { signal, ...body } = options;
|
|
888
|
+
return this.request(`/api/ai/${this.projectId}/video`, {
|
|
889
|
+
method: "POST",
|
|
890
|
+
body: {
|
|
891
|
+
prompt,
|
|
892
|
+
...body
|
|
893
|
+
},
|
|
894
|
+
signal
|
|
895
|
+
});
|
|
896
|
+
}
|
|
886
897
|
/**
|
|
887
898
|
* Data-specific requests
|
|
888
899
|
*/
|
|
@@ -4277,6 +4288,131 @@ var BlinkAIImpl = class {
|
|
|
4277
4288
|
);
|
|
4278
4289
|
}
|
|
4279
4290
|
}
|
|
4291
|
+
/**
|
|
4292
|
+
* Generates videos from text prompts or images using AI video generation models.
|
|
4293
|
+
*
|
|
4294
|
+
* @param options - Object containing:
|
|
4295
|
+
* - `prompt`: Text description of the video to generate (required)
|
|
4296
|
+
* - `model`: Video model to use (optional). Available models:
|
|
4297
|
+
* **Text-to-Video Models:**
|
|
4298
|
+
* - `"fal-ai/veo3.1"` - Google Veo 3.1 (best quality)
|
|
4299
|
+
* - `"fal-ai/veo3.1/fast"` (default) - Veo 3.1 fast mode (faster, cheaper)
|
|
4300
|
+
* - `"fal-ai/sora-2/text-to-video/pro"` - OpenAI Sora 2
|
|
4301
|
+
* - `"fal-ai/kling-video/v2.6/pro/text-to-video"` - Kling 2.6
|
|
4302
|
+
* **Image-to-Video Models:**
|
|
4303
|
+
* - `"fal-ai/veo3.1/image-to-video"` - Veo 3.1 I2V
|
|
4304
|
+
* - `"fal-ai/veo3.1/fast/image-to-video"` - Veo 3.1 fast I2V
|
|
4305
|
+
* - `"fal-ai/sora-2/image-to-video/pro"` - Sora 2 I2V
|
|
4306
|
+
* - `"fal-ai/kling-video/v2.6/pro/image-to-video"` - Kling 2.6 I2V
|
|
4307
|
+
* - `image_url`: Source image URL for image-to-video (required for I2V models)
|
|
4308
|
+
* - `duration`: Video duration ("4s", "5s", "6s", "8s", "10s", "12s")
|
|
4309
|
+
* - `aspect_ratio`: Aspect ratio ("16:9", "9:16", "1:1")
|
|
4310
|
+
* - `resolution`: Resolution ("720p", "1080p") - Veo/Sora only
|
|
4311
|
+
* - `negative_prompt`: What to avoid in generation - Veo/Kling only
|
|
4312
|
+
* - `generate_audio`: Generate audio with video (default: true)
|
|
4313
|
+
* - `seed`: For reproducibility - Veo only
|
|
4314
|
+
* - `cfg_scale`: Guidance scale (0-1) - Kling only
|
|
4315
|
+
* - Plus optional signal parameter
|
|
4316
|
+
*
|
|
4317
|
+
* @example
|
|
4318
|
+
* ```ts
|
|
4319
|
+
* // Basic text-to-video generation (uses default fast model)
|
|
4320
|
+
* const { result } = await blink.ai.generateVideo({
|
|
4321
|
+
* prompt: "A serene sunset over the ocean with gentle waves"
|
|
4322
|
+
* });
|
|
4323
|
+
* console.log("Video URL:", result.video.url);
|
|
4324
|
+
*
|
|
4325
|
+
* // High quality with Veo 3.1
|
|
4326
|
+
* const { result } = await blink.ai.generateVideo({
|
|
4327
|
+
* prompt: "A cinematic shot of a futuristic city at night",
|
|
4328
|
+
* model: "fal-ai/veo3.1",
|
|
4329
|
+
* resolution: "1080p",
|
|
4330
|
+
* aspect_ratio: "16:9"
|
|
4331
|
+
* });
|
|
4332
|
+
*
|
|
4333
|
+
* // Image-to-video animation
|
|
4334
|
+
* const { result } = await blink.ai.generateVideo({
|
|
4335
|
+
* prompt: "Animate this image with gentle camera movement",
|
|
4336
|
+
* model: "fal-ai/veo3.1/fast/image-to-video",
|
|
4337
|
+
* image_url: "https://example.com/my-image.jpg",
|
|
4338
|
+
* duration: "5s"
|
|
4339
|
+
* });
|
|
4340
|
+
*
|
|
4341
|
+
* // Using Sora 2 for creative videos
|
|
4342
|
+
* const { result } = await blink.ai.generateVideo({
|
|
4343
|
+
* prompt: "A magical forest with glowing fireflies",
|
|
4344
|
+
* model: "fal-ai/sora-2/text-to-video/pro",
|
|
4345
|
+
* duration: "8s"
|
|
4346
|
+
* });
|
|
4347
|
+
*
|
|
4348
|
+
* // Using Kling for detailed videos
|
|
4349
|
+
* const { result, usage } = await blink.ai.generateVideo({
|
|
4350
|
+
* prompt: "A professional cooking tutorial scene",
|
|
4351
|
+
* model: "fal-ai/kling-video/v2.6/pro/text-to-video",
|
|
4352
|
+
* negative_prompt: "blur, distort, low quality",
|
|
4353
|
+
* cfg_scale: 0.7
|
|
4354
|
+
* });
|
|
4355
|
+
* console.log("Credits charged:", usage?.creditsCharged);
|
|
4356
|
+
* ```
|
|
4357
|
+
*
|
|
4358
|
+
* @returns Promise<VideoGenerationResponse> - Object containing:
|
|
4359
|
+
* - `result.video.url`: URL to the generated video
|
|
4360
|
+
* - `result.video.content_type`: MIME type (video/mp4)
|
|
4361
|
+
* - `result.video.file_name`: Generated filename
|
|
4362
|
+
* - `result.video.file_size`: File size in bytes
|
|
4363
|
+
* - `metadata`: Generation metadata (projectId, timestamp, model)
|
|
4364
|
+
* - `usage`: Credits charged and cost information
|
|
4365
|
+
*/
|
|
4366
|
+
async generateVideo(options) {
|
|
4367
|
+
try {
|
|
4368
|
+
if (!options.prompt) {
|
|
4369
|
+
throw new BlinkAIError("Prompt is required");
|
|
4370
|
+
}
|
|
4371
|
+
const i2vModels = [
|
|
4372
|
+
"fal-ai/veo3.1/image-to-video",
|
|
4373
|
+
"fal-ai/veo3.1/fast/image-to-video",
|
|
4374
|
+
"fal-ai/sora-2/image-to-video/pro",
|
|
4375
|
+
"fal-ai/kling-video/v2.6/pro/image-to-video"
|
|
4376
|
+
];
|
|
4377
|
+
if (options.model && i2vModels.includes(options.model) && !options.image_url) {
|
|
4378
|
+
throw new BlinkAIError("image_url is required for image-to-video models");
|
|
4379
|
+
}
|
|
4380
|
+
if (options.image_url) {
|
|
4381
|
+
const validation = this.validateImageUrl(options.image_url);
|
|
4382
|
+
if (!validation.isValid) {
|
|
4383
|
+
throw new BlinkAIError(`Invalid image_url: ${validation.error}`);
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4386
|
+
const response = await this.httpClient.aiVideo(
|
|
4387
|
+
options.prompt,
|
|
4388
|
+
{
|
|
4389
|
+
model: options.model,
|
|
4390
|
+
image_url: options.image_url,
|
|
4391
|
+
duration: options.duration,
|
|
4392
|
+
aspect_ratio: options.aspect_ratio,
|
|
4393
|
+
resolution: options.resolution,
|
|
4394
|
+
negative_prompt: options.negative_prompt,
|
|
4395
|
+
generate_audio: options.generate_audio,
|
|
4396
|
+
seed: options.seed,
|
|
4397
|
+
cfg_scale: options.cfg_scale,
|
|
4398
|
+
signal: options.signal
|
|
4399
|
+
}
|
|
4400
|
+
);
|
|
4401
|
+
if (!response.data?.result?.video?.url) {
|
|
4402
|
+
throw new BlinkAIError("Invalid response format: missing video URL");
|
|
4403
|
+
}
|
|
4404
|
+
return response.data;
|
|
4405
|
+
} catch (error) {
|
|
4406
|
+
if (error instanceof BlinkAIError) {
|
|
4407
|
+
throw error;
|
|
4408
|
+
}
|
|
4409
|
+
throw new BlinkAIError(
|
|
4410
|
+
`Video generation failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
4411
|
+
void 0,
|
|
4412
|
+
{ originalError: error }
|
|
4413
|
+
);
|
|
4414
|
+
}
|
|
4415
|
+
}
|
|
4280
4416
|
/**
|
|
4281
4417
|
* Converts text to speech using AI voice synthesis models.
|
|
4282
4418
|
*
|
package/package.json
CHANGED