@devvibex/aiflow 1.15.0 → 1.15.1

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 CHANGED
@@ -148,9 +148,13 @@ page. The module default is set with `admin.updateConfig({ imageBackground })`.
148
148
  Returns `{ videoUrl, usage: { creditsUsed } }`. Pass `image` for image-to-video
149
149
  or `video` for video-to-video; omit both for pure text-to-video.
150
150
 
151
- `image` is the clip's first frame. On **Seedance**, add `lastFrame` to fix the
152
- frame the clip ends on as well — the video moves from `image` to `lastFrame`.
153
- `lastFrame` requires `image`; Gemini Omni and Veo ignore it.
151
+ `image` is the clip's first frame. On **Seedance** and **Kling**, add `lastFrame`
152
+ to fix the frame the clip ends on as well — the video moves from `image` to
153
+ `lastFrame`. `lastFrame` requires `image`; Gemini Omni and Veo ignore it.
154
+
155
+ **Kling** (`model: 'kling'`, Kling 3.0): 3–15s clips (`duration`), 720p or
156
+ 1080p, 16:9 / 9:16 / 1:1, JPG / PNG images only. Silent unless
157
+ `generateAudio: true`, which costs more per second.
154
158
 
155
159
  ```js
156
160
  const clip = await aiflow.generateVideo({
@@ -340,19 +344,23 @@ job's `videoUrl` is the timeline and `segmentUrl` the new tail.
340
344
  Every turn is billed separately (Omni prices by output token), and
341
345
  `session.usage.creditsUsed` is the running total for the whole session.
342
346
 
343
- ### `aiflow.generateAudio({ prompt, model?, images?, format?, negativePrompt?, seed?, signal?, timeout? })`
347
+ ### `aiflow.generateAudio({ prompt, model?, images?, durationSeconds?, format?, negativePrompt?, seed?, signal?, timeout? })`
344
348
 
345
349
  Generate music from a text prompt with Google **Lyria 3.5**. Returns
346
350
  `{ audioUrl, model, durationSeconds, lyrics, usage: { creditsUsed } }`;
347
351
  `audioUrl` is a hosted mp3 on the CDN. `prompt` is a musical description (mood,
348
- genre, tempo/BPM, instrumentation), and length or exclusions go in it too
349
- ("about 30 seconds, seamless loop", "no vocals"). Lyria treats length as a
350
- guide, so read `durationSeconds` for the real one. Custom lyrics go in the
351
- prompt with section tags (`[Verse]`, `[Chorus]`, `[Bridge]`).
352
-
352
+ genre, tempo/BPM, instrumentation) and exclusions ("no vocals"). Custom lyrics
353
+ go in the prompt with section tags (`[Verse]`, `[Chorus]`, `[Bridge]`).
354
+
355
+ - `durationSeconds` — song length, 5–180. Lyria 3.5 has no length setting and
356
+ runs long (a 30s request measured 44–63s), so the gateway lays the song out
357
+ to this length and cuts it to exactly this length with a 1–3s fade-out.
358
+ Without it the song is as long as the model makes it, usually one to three
359
+ minutes. A length written only in `prompt` is a loose suggestion. Needs
360
+ ≥ 1.15.1: 1.15.0 and older drop `durationSeconds` from music requests.
353
361
  - `images` — up to 10 https:// or data: URLs for the music to be inspired by,
354
362
  on the models in `config.audioImageInputModels`.
355
- - `format` — `'mp3'` (default) or `'wav'` (44.1 kHz stereo, about 10 MB per
363
+ - `format` — `'mp3'` (default) or `'wav'` (48 kHz stereo, about 11.5 MB per
356
364
  minute — offer it as a download).
357
365
  - `negativePrompt` — what the music must not contain; appended to the prompt
358
366
  as an exclusion, since Lyria 3.5 has no separate field for it.
@@ -365,9 +373,11 @@ prompt with section tags (`[Verse]`, `[Chorus]`, `[Bridge]`).
365
373
  const song = await aiflow.generateAudio({
366
374
  prompt: 'Bright acoustic pop, 100 BPM, female vocal. [Verse] Morning light on the harbour ... [Chorus] ...',
367
375
  images: [coverPhotoUrl],
376
+ durationSeconds: 30,
368
377
  format: 'wav',
369
378
  });
370
- song.audioUrl; // .wav on the CDN
379
+ song.audioUrl; // .wav on the CDN
380
+ song.durationSeconds; // ~30
371
381
  song.lyrics; // "Morning light on the harbour…\n\n…"
372
382
  ```
373
383
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvibex/aiflow",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "First-party LLM gateway SDK for apps generated on the VibeX platform — chat, streaming, image, video (including stateful multi-turn video extension with Gemini Omni), music (Lyria), sound effects (ElevenLabs), embeddings and real-time speech translation (Gemini Live) without shipping any third-party API key.",
5
5
  "keywords": [
6
6
  "ai",
package/src/index.d.ts CHANGED
@@ -201,27 +201,28 @@ export interface ImageBatchResponse {
201
201
  export interface VideoRequest {
202
202
  prompt: string;
203
203
  /**
204
- * Video model: `'gemini-omni'` | `'veo'` | `'seedance'`. Defaults to the
204
+ * Video model: `'gemini-omni'` | `'veo'` | `'seedance'` | `'kling'`. Defaults to the
205
205
  * app's configured model, which is Gemini Omni unless the module was pinned
206
206
  * to another one. Omni clips always have sound and are the only ones that
207
207
  * can be extended (see {@link AIFlowClient.createVideoSession}).
208
208
  */
209
209
  model?: string;
210
210
  /**
211
- * Output aspect ratio. Gemini Omni supports 16:9 / 9:16 only; Veo also 1:1;
212
- * Seedance also 1:1 / 4:3 / 3:4 / 21:9. An unsupported ratio is mapped to
213
- * 16:9 by the server.
211
+ * Output aspect ratio. Gemini Omni supports 16:9 / 9:16 only; Veo and Kling
212
+ * also 1:1 (Kling image-to-video keeps the image's ratio); Seedance also
213
+ * 1:1 / 4:3 / 3:4 / 21:9. An unsupported ratio is mapped to 16:9 by the
214
+ * server.
214
215
  */
215
216
  aspectRatio?: '16:9' | '9:16' | '1:1' | '4:3' | '3:4' | '21:9' | string;
216
217
  /**
217
- * Output resolution: '720p' (default) | '1080p' on Gemini Omni and
218
- * Seedance; Seedance also '480p' (Omni treats it as 720p). Lower generates
218
+ * Output resolution: '720p' (default) | '1080p' on Gemini Omni, Seedance
219
+ * and Kling; Seedance also '480p' (Omni and Kling treat it as 720p). Lower generates
219
220
  * faster and, on Omni, costs less. Ignored by Veo.
220
221
  */
221
222
  resolution?: '480p' | '720p' | '1080p' | string;
222
223
  /**
223
- * Clip length in seconds — Seedance only: an integer 4–15 on Seedance 2.0,
224
- * 4–30 on 2.5 (clamped to that range, default 5). Gemini Omni takes no
224
+ * Clip length in seconds — Seedance and Kling: an integer 4–15 on Seedance
225
+ * 2.0, 4–30 on 2.5, 3–15 on Kling (clamped to that range, default 5). Gemini Omni takes no
225
226
  * length and returns a ~10s clip (longer:
226
227
  * {@link AIFlowClient.generateLongVideo}); Veo uses a fixed length.
227
228
  */
@@ -235,8 +236,9 @@ export interface VideoRequest {
235
236
  image?: string;
236
237
  /**
237
238
  * Image the clip must END on (first + last frame). Same formats as `image`
238
- * and requires it. Seedance only — Gemini Omni and Veo ignore it, so the
239
- * module must be pinned to Seedance. Needs `@devvibex/aiflow` ≥ 1.15.0.
239
+ * and requires it. Seedance and Kling — Gemini Omni and Veo ignore it, so
240
+ * the module must be pinned to one of them. Kling takes JPG / PNG only.
241
+ * Needs `@devvibex/aiflow` ≥ 1.15.0.
240
242
  */
241
243
  lastFrame?: string;
242
244
  video?: string;
@@ -261,8 +263,9 @@ export interface VideoRequest {
261
263
  */
262
264
  referenceAudios?: string[];
263
265
  /**
264
- * Seedance only — `false` for a silent clip. Omitted, Seedance generates
265
- * synchronized sound (voice, effects, music).
266
+ * Seedance and Kling — whether the clip gets synchronized sound (voice,
267
+ * effects, music). Omitted: on for Seedance, off for Kling (where sound
268
+ * costs more per second).
266
269
  */
267
270
  generateAudio?: boolean;
268
271
  signal?: AbortSignal;
@@ -542,8 +545,9 @@ export interface VideoExtendSubmitResponse extends VideoJobSubmitResponse {
542
545
 
543
546
  export interface AudioRequest {
544
547
  /**
545
- * Musical description — mood, genre, tempo (BPM), instrumentation, texture,
546
- * length ("about 30 seconds") and exclusions ("no vocals").
548
+ * Musical description — mood, genre, tempo (BPM), instrumentation, texture
549
+ * and exclusions ("no vocals"). Put a set length in `durationSeconds`, not
550
+ * here: Lyria treats a length in the prompt as a loose suggestion.
547
551
  */
548
552
  prompt: string;
549
553
  model?: string;
@@ -554,7 +558,15 @@ export interface AudioRequest {
554
558
  */
555
559
  images?: string[];
556
560
  /**
557
- * `'mp3'` (default) or `'wav'` — 44.1 kHz stereo, about 10 MB per minute,
561
+ * Song length in seconds, 5–180. Lyria 3.5 has no length setting and runs
562
+ * long, so the gateway lays the song out to this length and cuts it to
563
+ * exactly this length with a short fade-out; a shorter song is returned as
564
+ * is. Read the real length from `durationSeconds` in the response. Needs
565
+ * `@devvibex/aiflow` ≥ 1.15.1 — 1.15.0 and older drop it.
566
+ */
567
+ durationSeconds?: number;
568
+ /**
569
+ * `'mp3'` (default) or `'wav'` — 48 kHz stereo, about 11.5 MB per minute,
558
570
  * so offer WAV as a download rather than for in-page playback. Needs
559
571
  * `@devvibex/aiflow` ≥ 1.15.0.
560
572
  */
package/src/index.js CHANGED
@@ -1037,15 +1037,18 @@ export class AIFlowClient {
1037
1037
  /**
1038
1038
  * Generate music / background audio from a text prompt (Lyria 3.5),
1039
1039
  * optionally inspired by up to 10 reference `images` (https:// or data:
1040
- * URLs) on the models in `config.audioImageInputModels`. `format: 'wav'`
1041
- * returns a WAV file instead of MP3; `lyrics` in the result holds the
1042
- * sung words (null for an instrumental).
1040
+ * URLs) on the models in `config.audioImageInputModels`.
1041
+ * `durationSeconds` (5–180) fixes the length: Lyria has no length setting
1042
+ * and runs long, so the gateway plans the song to it and trims the rest
1043
+ * with a fade-out. `format: 'wav'` returns a WAV file instead of MP3;
1044
+ * `lyrics` in the result holds the sung words (null for an instrumental).
1043
1045
  * @returns {Promise<{audioUrl:string, model:string, durationSeconds:number|null, lyrics:string|null, prompt?:string, usage:{creditsUsed:number}}>}
1044
1046
  */
1045
1047
  async generateAudio({
1046
1048
  prompt,
1047
1049
  model,
1048
1050
  images,
1051
+ durationSeconds,
1049
1052
  format,
1050
1053
  negativePrompt,
1051
1054
  seed,
@@ -1066,6 +1069,8 @@ export class AIFlowClient {
1066
1069
  model: resolvedModel,
1067
1070
  prompt,
1068
1071
  images: images?.length ? images : undefined,
1072
+ // 5–180s; the gateway plans the song to it and trims overshoot.
1073
+ durationSeconds,
1069
1074
  format,
1070
1075
  negativePrompt,
1071
1076
  seed,