@runapi.ai/kling 0.2.9 → 0.2.11
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 +107 -18
- package/dist/index.d.ts +107 -18
- package/dist/index.js +326 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +312 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/skills/kling/README.md +5 -0
- package/skills/kling/SKILL.md +4 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-video.ts","../src/contract_gen.ts","../src/resources/image-to-video.ts","../src/resources/ai-avatar.ts","../src/resources/motion-control.ts"],"sourcesContent":["export { KlingClient } from './client';\nexport * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToVideo } from './resources/text-to-video';\nimport { ImageToVideo } from './resources/image-to-video';\nimport { AiAvatar } from './resources/ai-avatar';\nimport { MotionControl } from './resources/motion-control';\n\n/**\n * Kling video generation, AI avatar lip-sync, and motion control API client.\n *\n * @example\n * ```typescript\n * const client = new KlingClient({ apiKey: 'your-api-key' });\n *\n * const result = await client.textToVideo.run({\n * model: 'kling-3.0',\n * prompt: 'A cat walking through a garden',\n * });\n * ```\n */\nexport class KlingClient extends BaseClient {\n /** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */\n public readonly textToVideo: TextToVideo;\n /** Image-to-video animation from a first-frame image guided by a text prompt. */\n public readonly imageToVideo: ImageToVideo;\n /** AI avatar lip-sync: animate a face image to match an audio track. */\n public readonly aiAvatar: AiAvatar;\n /** Transfer motion from a reference video onto a subject image. */\n public readonly motionControl: MotionControl;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToVideo = new TextToVideo(this.http);\n this.imageToVideo = new ImageToVideo(this.http);\n this.aiAvatar = new AiAvatar(this.http);\n this.motionControl = new MotionControl(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { ValidationError, compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedTextToVideoResponse,\n TextToVideoParams,\n TextToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/text_to_video';\nconst V3_TURBO_MODEL = 'kling-v3-turbo-text-to-video';\nconst V3_TURBO_UNSUPPORTED_FIELDS = [\n 'enable_sound',\n 'negative_prompt',\n 'cfg_scale',\n 'multi_shots',\n 'multi_prompt',\n 'first_frame_image_url',\n 'last_frame_image_url',\n 'kling_elements',\n];\n\n/** Generate video from text prompts. Supports multi-shot, sound, first/last frame images, and Kling elements on kling-3.0; negative prompts and cfg_scale on V2.x models. */\nexport class TextToVideo {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video from a text prompt and wait until complete.\n * @param params Text-to-video parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToVideoResponse;\n }\n\n /**\n * Create a text-to-video task; returns immediately with a task id.\n * @param params Text-to-video parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n rejectUnsupportedV3TurboFields(body as Record<string, unknown>);\n validateParams(contract['text-to-video'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-video task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-video task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToVideoResponse> {\n return this.http.request<TextToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n\nfunction rejectUnsupportedV3TurboFields(body: Record<string, unknown>): void {\n if (body.model !== V3_TURBO_MODEL) return;\n\n const field = V3_TURBO_UNSUPPORTED_FIELDS.find((candidate) => fieldPresent(body, candidate));\n if (field) {\n throw new ValidationError(`${field} is not supported by ${V3_TURBO_MODEL}`);\n }\n}\n\nfunction fieldPresent(params: Record<string, unknown>, field: string): boolean {\n if (!(field in params)) return false;\n const value = params[field];\n if (value === false) return true;\n if (Array.isArray(value)) return value.some((item) => presentValue(item));\n return presentValue(value);\n}\n\nfunction presentValue(value: unknown): boolean {\n if (value === null || value === undefined || value === false) return false;\n if (value === true) return true;\n if (typeof value === 'string') return value.trim() !== '';\n if (Array.isArray(value)) return value.length > 0;\n if (typeof value === 'object') return Object.keys(value as object).length > 0;\n return true;\n}\n","export const contract = {\n \"avatar\": {\n \"models\": [\n \"kling-ai-avatar-pro\",\n \"kling-ai-avatar-standard\",\n \"kling-ai-avatar-v1-pro\",\n \"kling-v1-avatar-standard\"\n ],\n \"fields_by_model\": {\n \"kling-ai-avatar-pro\": {\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_audio_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n },\n \"kling-ai-avatar-standard\": {\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_audio_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n },\n \"kling-ai-avatar-v1-pro\": {\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_audio_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n },\n \"kling-v1-avatar-standard\": {\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_audio_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n }\n }\n },\n \"image-to-video\": {\n \"models\": [\n \"kling-v2.1-master-image-to-video\",\n \"kling-v2.1-pro\",\n \"kling-v2.1-standard\",\n \"kling-v2.5-turbo-image-to-video-pro\",\n \"kling-v3-turbo-image-to-video\"\n ],\n \"fields_by_model\": {\n \"kling-v2.1-master-image-to-video\": {\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"kling-v2.1-pro\": {\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"kling-v2.1-standard\": {\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"kling-v2.5-turbo-image-to-video-pro\": {\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"kling-v3-turbo-image-to-video\": {\n \"duration_seconds\": {\n \"enum\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\"\n ]\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 2500,\n \"length\": true\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"kling-v2.1-master-image-to-video\"\n },\n \"forbidden\": [\n \"output_resolution\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v2.1-pro\"\n },\n \"forbidden\": [\n \"output_resolution\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v2.1-standard\"\n },\n \"forbidden\": [\n \"output_resolution\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v2.5-turbo-image-to-video-pro\"\n },\n \"forbidden\": [\n \"output_resolution\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v3-turbo-image-to-video\"\n },\n \"forbidden\": [\n \"aspect_ratio\",\n \"negative_prompt\",\n \"cfg_scale\",\n \"last_frame_image_url\"\n ]\n }\n ]\n },\n \"motion-control\": {\n \"models\": [\n \"kling-3.0\"\n ],\n \"fields_by_model\": {\n \"kling-3.0\": {\n \"background_source\": {\n \"enum\": [\n \"video\",\n \"image\"\n ]\n },\n \"character_orientation\": {\n \"enum\": [\n \"video\",\n \"image\"\n ]\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\"\n ]\n },\n \"reference_video_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-video\": {\n \"models\": [\n \"kling-3.0\",\n \"kling-v2.1-master-text-to-video\",\n \"kling-v2.5-turbo-text-to-video-pro\",\n \"kling-v3-turbo-text-to-video\"\n ],\n \"fields_by_model\": {\n \"kling-3.0\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\",\n \"4k\"\n ]\n }\n },\n \"kling-v2.1-master-text-to-video\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n }\n },\n \"kling-v2.5-turbo-text-to-video-pro\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n }\n },\n \"kling-v3-turbo-text-to-video\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\"\n ]\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 2500,\n \"length\": true\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"kling-v3-turbo-text-to-video\"\n },\n \"forbidden\": [\n \"enable_sound\",\n \"negative_prompt\",\n \"cfg_scale\",\n \"multi_shots\",\n \"multi_prompt\",\n \"first_frame_image_url\",\n \"last_frame_image_url\",\n \"kling_elements\"\n ]\n }\n ]\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { ValidationError, compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedImageToVideoResponse,\n ImageToVideoParams,\n ImageToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/image_to_video';\nconst V3_TURBO_MODEL = 'kling-v3-turbo-image-to-video';\nconst V3_TURBO_UNSUPPORTED_FIELDS = [\n 'aspect_ratio',\n 'negative_prompt',\n 'cfg_scale',\n 'last_frame_image_url',\n];\n\n/** Animate a still image into video, guided by a text prompt and first-frame image. */\nexport class ImageToVideo {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video from an input image and wait until complete.\n * @param params Image-to-video parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<ImageToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedImageToVideoResponse;\n }\n\n /**\n * Create an image-to-video task; returns immediately with a task id.\n * @param params Image-to-video parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n rejectUnsupportedV3TurboFields(body as Record<string, unknown>);\n validateParams(contract['image-to-video'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image-to-video task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image-to-video task status.\n */\n async get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse> {\n return this.http.request<ImageToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n\nfunction rejectUnsupportedV3TurboFields(body: Record<string, unknown>): void {\n if (body.model !== V3_TURBO_MODEL) return;\n\n const field = V3_TURBO_UNSUPPORTED_FIELDS.find((candidate) => fieldPresent(body, candidate));\n if (field) {\n throw new ValidationError(`${field} is not supported by ${V3_TURBO_MODEL}`);\n }\n}\n\nfunction fieldPresent(params: Record<string, unknown>, field: string): boolean {\n if (!(field in params)) return false;\n const value = params[field];\n if (value === false) return true;\n if (Array.isArray(value)) return value.some((item) => presentValue(item));\n return presentValue(value);\n}\n\nfunction presentValue(value: unknown): boolean {\n if (value === null || value === undefined || value === false) return false;\n if (value === true) return true;\n if (typeof value === 'string') return value.trim() !== '';\n if (Array.isArray(value)) return value.length > 0;\n if (typeof value === 'object') return Object.keys(value as object).length > 0;\n return true;\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedAiAvatarResponse,\n AiAvatarParams,\n AiAvatarResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/ai_avatar';\n\n/** Lip-sync a face image to an audio track, producing a talking-head video. */\nexport class AiAvatar {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an AI avatar video and wait until complete.\n * @param params AI avatar parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<AiAvatarResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedAiAvatarResponse;\n }\n\n /**\n * Create an AI avatar generation task; returns immediately with a task id.\n * @param params AI avatar parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['avatar'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an AI avatar task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current AI avatar task status.\n */\n async get(id: string, options?: RequestOptions): Promise<AiAvatarResponse> {\n return this.http.request<AiAvatarResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedMotionControlResponse,\n MotionControlParams,\n MotionControlResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/motion_control';\n\n/** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */\nexport class MotionControl {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video with motion transfer from a reference video and wait until complete.\n * @param params Motion control parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<MotionControlResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedMotionControlResponse;\n }\n\n /**\n * Create a motion control generation task; returns immediately with a task id.\n * @param params Motion control parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['motion-control'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a motion control task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current motion control task status.\n */\n async get(id: string, options?: RequestOptions): Promise<MotionControlResponse> {\n return this.http.request<MotionControlResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA+C;;;ACC/C,kBAA+D;AAC/D,sBAAkC;;;ACF3B,IAAM,WAAW;AAAA,EACtB,UAAU;AAAA,IACR,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,uBAAuB;AAAA,QACrB,SAAS;AAAA,UACP,YAAY;AAAA,QACd;AAAA,QACA,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,UAClB,YAAY;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,UAClB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,4BAA4B;AAAA,QAC1B,SAAS;AAAA,UACP,YAAY;AAAA,QACd;AAAA,QACA,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,UAClB,YAAY;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,UAClB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,0BAA0B;AAAA,QACxB,SAAS;AAAA,UACP,YAAY;AAAA,QACd;AAAA,QACA,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,UAClB,YAAY;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,UAClB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,4BAA4B;AAAA,QAC1B,SAAS;AAAA,UACP,YAAY;AAAA,QACd;AAAA,QACA,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,UAClB,YAAY;AAAA,QACd;AAAA,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,SAAuD;AAC/F,UAAM,WAAO,4BAAc,MAAM;AACjC,qCAAe,SAAS,gBAAgB,GAAmB,IAA+B;AAC1F,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU;AAAA,MAC7D;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAA0D;AAC9E,WAAO,KAAK,KAAK,QAA+B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MAC1E,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ALvCO,IAAM,cAAN,cAA0B,wBAAW;AAAA;AAAA,EAE1B;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,eAAe,IAAI,aAAa,KAAK,IAAI;AAC9C,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AACtC,SAAK,gBAAgB,IAAI,cAAc,KAAK,IAAI;AAAA,EAClD;AACF;;;ADjCA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","V3_TURBO_MODEL","V3_TURBO_UNSUPPORTED_FIELDS","rejectUnsupportedV3TurboFields","fieldPresent","presentValue","import_core","import_internal","ENDPOINT","import_core","import_internal","ENDPOINT","import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-video.ts","../src/contract_gen.ts","../src/resources/image-to-video.ts","../src/resources/ai-avatar.ts","../src/resources/motion-control.ts","../src/resources/extend-video.ts"],"sourcesContent":["export { KlingClient } from './client';\nexport * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToVideo } from './resources/text-to-video';\nimport { ImageToVideo } from './resources/image-to-video';\nimport { AiAvatar } from './resources/ai-avatar';\nimport { MotionControl } from './resources/motion-control';\nimport { ExtendVideo } from './resources/extend-video';\n\n/**\n * Kling video generation, AI avatar lip-sync, and motion control API client.\n *\n * @example\n * ```typescript\n * const client = new KlingClient({ apiKey: 'your-api-key' });\n *\n * const result = await client.textToVideo.run({\n * model: 'kling-3.0',\n * prompt: 'A cat walking through a garden',\n * });\n * ```\n */\nexport class KlingClient extends BaseClient {\n /** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */\n public readonly textToVideo: TextToVideo;\n /** Image-to-video animation from a first-frame image guided by a text prompt. */\n public readonly imageToVideo: ImageToVideo;\n /** AI avatar lip-sync: animate a face image to match an audio track. */\n public readonly aiAvatar: AiAvatar;\n /** Transfer motion from a reference video onto a subject image. */\n public readonly motionControl: MotionControl;\n public readonly extendVideo: ExtendVideo;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToVideo = new TextToVideo(this.http);\n this.imageToVideo = new ImageToVideo(this.http);\n this.aiAvatar = new AiAvatar(this.http);\n this.motionControl = new MotionControl(this.http);\n this.extendVideo = new ExtendVideo(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { ValidationError, compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedTextToVideoResponse,\n TextToVideoParams,\n TextToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/text_to_video';\nconst V26_MODEL = 'kling-v2.6';\nconst V3_TURBO_MODEL = 'kling-v3-turbo-text-to-video';\nconst V3_TURBO_UNSUPPORTED_FIELDS = [\n 'enable_sound',\n 'negative_prompt',\n 'cfg_scale',\n 'multi_shots',\n 'multi_prompt',\n 'first_frame_image_url',\n 'last_frame_image_url',\n 'kling_elements',\n];\n\n/** Generate video from text prompts. Supports multi-shot, sound, first/last frame images, and Kling elements on kling-3.0; negative prompts and cfg_scale on V2.x models. */\nexport class TextToVideo {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video from a text prompt and wait until complete.\n * @param params Text-to-video parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: TextToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToVideoResponse;\n }\n\n /**\n * Create a text-to-video task; returns immediately with a task id.\n * @param params Text-to-video parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n rejectUnsupportedV3TurboFields(body as Record<string, unknown>);\n validateParams(contract['text-to-video'] as ActionSchema, body as Record<string, unknown>);\n validateV26Params(body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-video task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-video task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToVideoResponse> {\n return this.http.request<TextToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n\nfunction validateV26Params(body: Record<string, unknown>): void {\n if (body.model !== V26_MODEL) return;\n if (body.enable_sound === true && body.mode !== 'pro') {\n throw new ValidationError(`enable_sound requires mode pro for ${V26_MODEL}`);\n }\n}\n\nfunction rejectUnsupportedV3TurboFields(body: Record<string, unknown>): void {\n if (body.model !== V3_TURBO_MODEL) return;\n\n const field = V3_TURBO_UNSUPPORTED_FIELDS.find((candidate) => fieldPresent(body, candidate));\n if (field) {\n throw new ValidationError(`${field} is not supported by ${V3_TURBO_MODEL}`);\n }\n}\n\nfunction fieldPresent(params: Record<string, unknown>, field: string): boolean {\n if (!(field in params)) return false;\n const value = params[field];\n if (value === false) return true;\n if (Array.isArray(value)) return value.some((item) => presentValue(item));\n return presentValue(value);\n}\n\nfunction presentValue(value: unknown): boolean {\n if (value === null || value === undefined || value === false) return false;\n if (value === true) return true;\n if (typeof value === 'string') return value.trim() !== '';\n if (Array.isArray(value)) return value.length > 0;\n if (typeof value === 'object') return Object.keys(value as object).length > 0;\n return true;\n}\n","export const contract = {\n \"avatar\": {\n \"models\": [\n \"kling-ai-avatar-pro\",\n \"kling-ai-avatar-standard\",\n \"kling-ai-avatar-v1-pro\",\n \"kling-v1-avatar-standard\"\n ],\n \"fields_by_model\": {\n \"kling-ai-avatar-pro\": {\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_audio_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n },\n \"kling-ai-avatar-standard\": {\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_audio_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n },\n \"kling-ai-avatar-v1-pro\": {\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_audio_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n },\n \"kling-v1-avatar-standard\": {\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_audio_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n }\n }\n },\n \"extend-video\": {\n \"models\": [\n \"kling-v2.5-turbo-image-to-video-pro\",\n \"kling-v2.5-turbo-text-to-video-pro\"\n ],\n \"fields_by_model\": {\n \"kling-v2.5-turbo-image-to-video-pro\": {\n \"mode\": {\n \"enum\": [\n \"std\",\n \"pro\"\n ]\n },\n \"source_task_id\": {\n \"required\": true\n }\n },\n \"kling-v2.5-turbo-text-to-video-pro\": {\n \"mode\": {\n \"enum\": [\n \"std\",\n \"pro\"\n ]\n },\n \"source_task_id\": {\n \"required\": true\n }\n }\n }\n },\n \"image-to-video\": {\n \"models\": [\n \"kling-v2.1-master-image-to-video\",\n \"kling-v2.1-pro\",\n \"kling-v2.1-standard\",\n \"kling-v2.5-turbo-image-to-video-pro\",\n \"kling-v2.6\",\n \"kling-v3-omni\",\n \"kling-v3-turbo-image-to-video\"\n ],\n \"fields_by_model\": {\n \"kling-v2.1-master-image-to-video\": {\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"kling-v2.1-pro\": {\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"kling-v2.1-standard\": {\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"kling-v2.5-turbo-image-to-video-pro\": {\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"kling-v2.6\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"mode\": {\n \"enum\": [\n \"std\",\n \"pro\"\n ]\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 2500,\n \"length\": true\n }\n },\n \"kling-v3-omni\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\",\n \"4k\"\n ]\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 2500,\n \"length\": true\n }\n },\n \"kling-v3-turbo-image-to-video\": {\n \"duration_seconds\": {\n \"enum\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15\n ],\n \"type\": \"integer\"\n },\n \"first_frame_image_url\": {\n \"required\": true\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\"\n ]\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 2500,\n \"length\": true\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"kling-v2.1-master-image-to-video\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"enable_sound\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v2.1-pro\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"enable_sound\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v2.1-standard\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"enable_sound\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v2.5-turbo-image-to-video-pro\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"enable_sound\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v2.6\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"negative_prompt\",\n \"cfg_scale\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v3-omni\"\n },\n \"forbidden\": [\n \"negative_prompt\",\n \"cfg_scale\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v3-turbo-image-to-video\"\n },\n \"forbidden\": [\n \"enable_sound\",\n \"aspect_ratio\",\n \"negative_prompt\",\n \"cfg_scale\",\n \"last_frame_image_url\"\n ]\n }\n ]\n },\n \"motion-control\": {\n \"models\": [\n \"kling-3.0\"\n ],\n \"fields_by_model\": {\n \"kling-3.0\": {\n \"background_source\": {\n \"enum\": [\n \"video\",\n \"image\"\n ]\n },\n \"character_orientation\": {\n \"enum\": [\n \"video\",\n \"image\"\n ]\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\"\n ]\n },\n \"reference_video_url\": {\n \"required\": true\n },\n \"source_image_url\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-video\": {\n \"models\": [\n \"kling-3.0\",\n \"kling-v2.1-master-text-to-video\",\n \"kling-v2.5-turbo-text-to-video-pro\",\n \"kling-v2.6\",\n \"kling-v3-omni\",\n \"kling-v3-turbo-text-to-video\"\n ],\n \"fields_by_model\": {\n \"kling-3.0\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\",\n \"4k\"\n ]\n }\n },\n \"kling-v2.1-master-text-to-video\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n }\n },\n \"kling-v2.5-turbo-text-to-video-pro\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n }\n },\n \"kling-v2.6\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 5,\n 10\n ],\n \"type\": \"integer\"\n },\n \"mode\": {\n \"enum\": [\n \"std\",\n \"pro\"\n ]\n },\n \"model\": {\n \"required\": true\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 2500,\n \"length\": true\n }\n },\n \"kling-v3-omni\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\",\n \"4k\"\n ]\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 2500,\n \"length\": true\n }\n },\n \"kling-v3-turbo-text-to-video\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"16:9\",\n \"9:16\",\n \"1:1\"\n ]\n },\n \"duration_seconds\": {\n \"enum\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15\n ],\n \"type\": \"integer\"\n },\n \"model\": {\n \"required\": true\n },\n \"output_resolution\": {\n \"enum\": [\n \"720p\",\n \"1080p\"\n ]\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 2500,\n \"length\": true\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"kling-v2.5-turbo-text-to-video-pro\"\n },\n \"forbidden\": [\n \"mode\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v2.6\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"negative_prompt\",\n \"cfg_scale\",\n \"multi_shots\",\n \"multi_prompt\",\n \"first_frame_image_url\",\n \"last_frame_image_url\",\n \"kling_elements\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v3-omni\"\n },\n \"forbidden\": [\n \"negative_prompt\",\n \"cfg_scale\",\n \"multi_shots\",\n \"multi_prompt\",\n \"first_frame_image_url\",\n \"last_frame_image_url\",\n \"kling_elements\"\n ]\n },\n {\n \"when\": {\n \"model\": \"kling-v3-turbo-text-to-video\"\n },\n \"forbidden\": [\n \"enable_sound\",\n \"negative_prompt\",\n \"cfg_scale\",\n \"multi_shots\",\n \"multi_prompt\",\n \"first_frame_image_url\",\n \"last_frame_image_url\",\n \"kling_elements\"\n ]\n }\n ]\n }\n} as const;\n\nexport const modelValues = {\n \"textToVideo\": {\n \"KLING_3_0\": \"kling-3.0\",\n \"KLING_V2_1_MASTER_TEXT_TO_VIDEO\": \"kling-v2.1-master-text-to-video\",\n \"KLING_V2_5_TURBO_TEXT_TO_VIDEO_PRO\": \"kling-v2.5-turbo-text-to-video-pro\",\n \"KLING_V2_6\": \"kling-v2.6\",\n \"KLING_V3_OMNI\": \"kling-v3-omni\",\n \"KLING_V3_TURBO_TEXT_TO_VIDEO\": \"kling-v3-turbo-text-to-video\"\n },\n \"imageToVideo\": {\n \"KLING_V2_1_MASTER_IMAGE_TO_VIDEO\": \"kling-v2.1-master-image-to-video\",\n \"KLING_V2_1_PRO\": \"kling-v2.1-pro\",\n \"KLING_V2_1_STANDARD\": \"kling-v2.1-standard\",\n \"KLING_V2_5_TURBO_IMAGE_TO_VIDEO_PRO\": \"kling-v2.5-turbo-image-to-video-pro\",\n \"KLING_V2_6\": \"kling-v2.6\",\n \"KLING_V3_OMNI\": \"kling-v3-omni\",\n \"KLING_V3_TURBO_IMAGE_TO_VIDEO\": \"kling-v3-turbo-image-to-video\"\n },\n \"avatar\": {\n \"KLING_AI_AVATAR_PRO\": \"kling-ai-avatar-pro\",\n \"KLING_AI_AVATAR_STANDARD\": \"kling-ai-avatar-standard\",\n \"KLING_AI_AVATAR_V1_PRO\": \"kling-ai-avatar-v1-pro\",\n \"KLING_V1_AVATAR_STANDARD\": \"kling-v1-avatar-standard\"\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { ValidationError, compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedImageToVideoResponse,\n ImageToVideoParams,\n ImageToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/image_to_video';\nconst V26_MODEL = 'kling-v2.6';\nconst V3_OMNI_MODEL = 'kling-v3-omni';\nconst V3_TURBO_MODEL = 'kling-v3-turbo-image-to-video';\nconst V3_TURBO_UNSUPPORTED_FIELDS = [\n 'aspect_ratio',\n 'negative_prompt',\n 'cfg_scale',\n 'last_frame_image_url',\n];\n\n/** Animate a still image into video, guided by a text prompt and first-frame image. */\nexport class ImageToVideo {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video from an input image and wait until complete.\n * @param params Image-to-video parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: ImageToVideoParams, options?: RequestOptions & PollingOptions): Promise<CompletedImageToVideoResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<ImageToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedImageToVideoResponse;\n }\n\n /**\n * Create an image-to-video task; returns immediately with a task id.\n * @param params Image-to-video parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n rejectUnsupportedV3TurboFields(body as Record<string, unknown>);\n validateParams(contract['image-to-video'] as ActionSchema, body as Record<string, unknown>);\n validateV26Params(body as Record<string, unknown>);\n validateV3OmniFields(body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image-to-video task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image-to-video task status.\n */\n async get(id: string, options?: RequestOptions): Promise<ImageToVideoResponse> {\n return this.http.request<ImageToVideoResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n\nfunction validateV26Params(body: Record<string, unknown>): void {\n if (body.model !== V26_MODEL) return;\n if (body.enable_sound === true && body.mode !== 'pro') {\n throw new ValidationError(`enable_sound requires mode pro for ${V26_MODEL}`);\n }\n if (!fieldPresent(body, 'last_frame_image_url')) return;\n if (body.mode !== 'pro') {\n throw new ValidationError(`last_frame_image_url requires mode pro for ${V26_MODEL}`);\n }\n if (body.duration_seconds !== undefined && body.duration_seconds !== 5) {\n throw new ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V26_MODEL}`);\n }\n}\n\nfunction validateV3OmniFields(body: Record<string, unknown>): void {\n if (body.model !== V3_OMNI_MODEL || !fieldPresent(body, 'last_frame_image_url')) return;\n if ((body.duration_seconds ?? 5) !== 5) {\n throw new ValidationError(`last_frame_image_url requires duration_seconds 5 for ${V3_OMNI_MODEL}`);\n }\n}\n\nfunction rejectUnsupportedV3TurboFields(body: Record<string, unknown>): void {\n if (body.model !== V3_TURBO_MODEL) return;\n\n const field = V3_TURBO_UNSUPPORTED_FIELDS.find((candidate) => fieldPresent(body, candidate));\n if (field) {\n throw new ValidationError(`${field} is not supported by ${V3_TURBO_MODEL}`);\n }\n}\n\nfunction fieldPresent(params: Record<string, unknown>, field: string): boolean {\n if (!(field in params)) return false;\n const value = params[field];\n if (value === false) return true;\n if (Array.isArray(value)) return value.some((item) => presentValue(item));\n return presentValue(value);\n}\n\nfunction presentValue(value: unknown): boolean {\n if (value === null || value === undefined || value === false) return false;\n if (value === true) return true;\n if (typeof value === 'string') return value.trim() !== '';\n if (Array.isArray(value)) return value.length > 0;\n if (typeof value === 'object') return Object.keys(value as object).length > 0;\n return true;\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedAiAvatarResponse,\n AiAvatarParams,\n AiAvatarResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/ai_avatar';\n\n/** Lip-sync a face image to an audio track, producing a talking-head video. */\nexport class AiAvatar {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an AI avatar video and wait until complete.\n * @param params AI avatar parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: AiAvatarParams, options?: RequestOptions & PollingOptions): Promise<CompletedAiAvatarResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<AiAvatarResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedAiAvatarResponse;\n }\n\n /**\n * Create an AI avatar generation task; returns immediately with a task id.\n * @param params AI avatar parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['avatar'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an AI avatar task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current AI avatar task status.\n */\n async get(id: string, options?: RequestOptions): Promise<AiAvatarResponse> {\n return this.http.request<AiAvatarResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedMotionControlResponse,\n MotionControlParams,\n MotionControlResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/motion_control';\n\n/** Transfer motion from a reference video onto a subject image, preserving the subject's appearance. */\nexport class MotionControl {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate a video with motion transfer from a reference video and wait until complete.\n * @param params Motion control parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with videos.\n */\n async run(params: MotionControlParams, options?: RequestOptions & PollingOptions): Promise<CompletedMotionControlResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<MotionControlResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedMotionControlResponse;\n }\n\n /**\n * Create a motion control generation task; returns immediately with a task id.\n * @param params Motion control parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['motion-control'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a motion control task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current motion control task status.\n */\n async get(id: string, options?: RequestOptions): Promise<MotionControlResponse> {\n return this.http.request<MotionControlResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { KlingExtendVideoParams, TextToVideoResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/kling/extend_video';\n\nexport class ExtendVideo {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: KlingExtendVideoParams, options?: RequestOptions & PollingOptions): Promise<TextToVideoResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToVideoResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n async create(params: KlingExtendVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['extend-video'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, { body, ...options });\n }\n\n async get(id: string, options?: RequestOptions): Promise<TextToVideoResponse> {\n return this.http.request<TextToVideoResponse>('GET', `${ENDPOINT}/${id}`, { ...options });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA+C;;;ACC/C,kBAA+D;AAC/D,sBAAkC;;;ACF3B,IAAM,WAAW;AAAA,EACtB,UAAU;AAAA,IACR,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,uBAAuB;AAAA,QACrB,SAAS;AAAA,UACP,YAAY;AAAA,QACd;AAAA,QACA,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,UAClB,YAAY;AAAA,QACd;AAAA,QAC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A,EAEA;AAAA,EACA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,eAAe,IAAI,aAAa,KAAK,IAAI;AAC9C,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AACtC,SAAK,gBAAgB,IAAI,cAAc,KAAK,IAAI;AAChD,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAAA,EAC9C;AACF;;;ADpCA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","V26_MODEL","V3_TURBO_MODEL","V3_TURBO_UNSUPPORTED_FIELDS","rejectUnsupportedV3TurboFields","validateV26Params","fieldPresent","presentValue","import_core","import_internal","ENDPOINT","import_core","import_internal","ENDPOINT","import_core","import_internal","ENDPOINT","import_core"]}
|
package/dist/index.mjs
CHANGED
|
@@ -73,12 +73,44 @@ var contract = {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
+
"extend-video": {
|
|
77
|
+
"models": [
|
|
78
|
+
"kling-v2.5-turbo-image-to-video-pro",
|
|
79
|
+
"kling-v2.5-turbo-text-to-video-pro"
|
|
80
|
+
],
|
|
81
|
+
"fields_by_model": {
|
|
82
|
+
"kling-v2.5-turbo-image-to-video-pro": {
|
|
83
|
+
"mode": {
|
|
84
|
+
"enum": [
|
|
85
|
+
"std",
|
|
86
|
+
"pro"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"source_task_id": {
|
|
90
|
+
"required": true
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"kling-v2.5-turbo-text-to-video-pro": {
|
|
94
|
+
"mode": {
|
|
95
|
+
"enum": [
|
|
96
|
+
"std",
|
|
97
|
+
"pro"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"source_task_id": {
|
|
101
|
+
"required": true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
76
106
|
"image-to-video": {
|
|
77
107
|
"models": [
|
|
78
108
|
"kling-v2.1-master-image-to-video",
|
|
79
109
|
"kling-v2.1-pro",
|
|
80
110
|
"kling-v2.1-standard",
|
|
81
111
|
"kling-v2.5-turbo-image-to-video-pro",
|
|
112
|
+
"kling-v2.6",
|
|
113
|
+
"kling-v3-omni",
|
|
82
114
|
"kling-v3-turbo-image-to-video"
|
|
83
115
|
],
|
|
84
116
|
"fields_by_model": {
|
|
@@ -154,6 +186,86 @@ var contract = {
|
|
|
154
186
|
"required": true
|
|
155
187
|
}
|
|
156
188
|
},
|
|
189
|
+
"kling-v2.6": {
|
|
190
|
+
"aspect_ratio": {
|
|
191
|
+
"enum": [
|
|
192
|
+
"16:9",
|
|
193
|
+
"9:16",
|
|
194
|
+
"1:1"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
"duration_seconds": {
|
|
198
|
+
"enum": [
|
|
199
|
+
5,
|
|
200
|
+
10
|
|
201
|
+
],
|
|
202
|
+
"type": "integer"
|
|
203
|
+
},
|
|
204
|
+
"first_frame_image_url": {
|
|
205
|
+
"required": true
|
|
206
|
+
},
|
|
207
|
+
"mode": {
|
|
208
|
+
"enum": [
|
|
209
|
+
"std",
|
|
210
|
+
"pro"
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
"model": {
|
|
214
|
+
"required": true
|
|
215
|
+
},
|
|
216
|
+
"prompt": {
|
|
217
|
+
"required": true,
|
|
218
|
+
"min": 1,
|
|
219
|
+
"max": 2500,
|
|
220
|
+
"length": true
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"kling-v3-omni": {
|
|
224
|
+
"aspect_ratio": {
|
|
225
|
+
"enum": [
|
|
226
|
+
"16:9",
|
|
227
|
+
"9:16",
|
|
228
|
+
"1:1"
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
"duration_seconds": {
|
|
232
|
+
"enum": [
|
|
233
|
+
3,
|
|
234
|
+
4,
|
|
235
|
+
5,
|
|
236
|
+
6,
|
|
237
|
+
7,
|
|
238
|
+
8,
|
|
239
|
+
9,
|
|
240
|
+
10,
|
|
241
|
+
11,
|
|
242
|
+
12,
|
|
243
|
+
13,
|
|
244
|
+
14,
|
|
245
|
+
15
|
|
246
|
+
],
|
|
247
|
+
"type": "integer"
|
|
248
|
+
},
|
|
249
|
+
"first_frame_image_url": {
|
|
250
|
+
"required": true
|
|
251
|
+
},
|
|
252
|
+
"model": {
|
|
253
|
+
"required": true
|
|
254
|
+
},
|
|
255
|
+
"output_resolution": {
|
|
256
|
+
"enum": [
|
|
257
|
+
"720p",
|
|
258
|
+
"1080p",
|
|
259
|
+
"4k"
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
"prompt": {
|
|
263
|
+
"required": true,
|
|
264
|
+
"min": 1,
|
|
265
|
+
"max": 2500,
|
|
266
|
+
"length": true
|
|
267
|
+
}
|
|
268
|
+
},
|
|
157
269
|
"kling-v3-turbo-image-to-video": {
|
|
158
270
|
"duration_seconds": {
|
|
159
271
|
"enum": [
|
|
@@ -199,7 +311,8 @@ var contract = {
|
|
|
199
311
|
"model": "kling-v2.1-master-image-to-video"
|
|
200
312
|
},
|
|
201
313
|
"forbidden": [
|
|
202
|
-
"output_resolution"
|
|
314
|
+
"output_resolution",
|
|
315
|
+
"enable_sound"
|
|
203
316
|
]
|
|
204
317
|
},
|
|
205
318
|
{
|
|
@@ -207,7 +320,8 @@ var contract = {
|
|
|
207
320
|
"model": "kling-v2.1-pro"
|
|
208
321
|
},
|
|
209
322
|
"forbidden": [
|
|
210
|
-
"output_resolution"
|
|
323
|
+
"output_resolution",
|
|
324
|
+
"enable_sound"
|
|
211
325
|
]
|
|
212
326
|
},
|
|
213
327
|
{
|
|
@@ -215,7 +329,8 @@ var contract = {
|
|
|
215
329
|
"model": "kling-v2.1-standard"
|
|
216
330
|
},
|
|
217
331
|
"forbidden": [
|
|
218
|
-
"output_resolution"
|
|
332
|
+
"output_resolution",
|
|
333
|
+
"enable_sound"
|
|
219
334
|
]
|
|
220
335
|
},
|
|
221
336
|
{
|
|
@@ -223,7 +338,27 @@ var contract = {
|
|
|
223
338
|
"model": "kling-v2.5-turbo-image-to-video-pro"
|
|
224
339
|
},
|
|
225
340
|
"forbidden": [
|
|
226
|
-
"output_resolution"
|
|
341
|
+
"output_resolution",
|
|
342
|
+
"enable_sound"
|
|
343
|
+
]
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"when": {
|
|
347
|
+
"model": "kling-v2.6"
|
|
348
|
+
},
|
|
349
|
+
"forbidden": [
|
|
350
|
+
"output_resolution",
|
|
351
|
+
"negative_prompt",
|
|
352
|
+
"cfg_scale"
|
|
353
|
+
]
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"when": {
|
|
357
|
+
"model": "kling-v3-omni"
|
|
358
|
+
},
|
|
359
|
+
"forbidden": [
|
|
360
|
+
"negative_prompt",
|
|
361
|
+
"cfg_scale"
|
|
227
362
|
]
|
|
228
363
|
},
|
|
229
364
|
{
|
|
@@ -231,6 +366,7 @@ var contract = {
|
|
|
231
366
|
"model": "kling-v3-turbo-image-to-video"
|
|
232
367
|
},
|
|
233
368
|
"forbidden": [
|
|
369
|
+
"enable_sound",
|
|
234
370
|
"aspect_ratio",
|
|
235
371
|
"negative_prompt",
|
|
236
372
|
"cfg_scale",
|
|
@@ -280,6 +416,8 @@ var contract = {
|
|
|
280
416
|
"kling-3.0",
|
|
281
417
|
"kling-v2.1-master-text-to-video",
|
|
282
418
|
"kling-v2.5-turbo-text-to-video-pro",
|
|
419
|
+
"kling-v2.6",
|
|
420
|
+
"kling-v3-omni",
|
|
283
421
|
"kling-v3-turbo-text-to-video"
|
|
284
422
|
],
|
|
285
423
|
"fields_by_model": {
|
|
@@ -358,6 +496,80 @@ var contract = {
|
|
|
358
496
|
"required": true
|
|
359
497
|
}
|
|
360
498
|
},
|
|
499
|
+
"kling-v2.6": {
|
|
500
|
+
"aspect_ratio": {
|
|
501
|
+
"enum": [
|
|
502
|
+
"16:9",
|
|
503
|
+
"9:16",
|
|
504
|
+
"1:1"
|
|
505
|
+
]
|
|
506
|
+
},
|
|
507
|
+
"duration_seconds": {
|
|
508
|
+
"enum": [
|
|
509
|
+
5,
|
|
510
|
+
10
|
|
511
|
+
],
|
|
512
|
+
"type": "integer"
|
|
513
|
+
},
|
|
514
|
+
"mode": {
|
|
515
|
+
"enum": [
|
|
516
|
+
"std",
|
|
517
|
+
"pro"
|
|
518
|
+
]
|
|
519
|
+
},
|
|
520
|
+
"model": {
|
|
521
|
+
"required": true
|
|
522
|
+
},
|
|
523
|
+
"prompt": {
|
|
524
|
+
"required": true,
|
|
525
|
+
"min": 1,
|
|
526
|
+
"max": 2500,
|
|
527
|
+
"length": true
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
"kling-v3-omni": {
|
|
531
|
+
"aspect_ratio": {
|
|
532
|
+
"enum": [
|
|
533
|
+
"16:9",
|
|
534
|
+
"9:16",
|
|
535
|
+
"1:1"
|
|
536
|
+
]
|
|
537
|
+
},
|
|
538
|
+
"duration_seconds": {
|
|
539
|
+
"enum": [
|
|
540
|
+
3,
|
|
541
|
+
4,
|
|
542
|
+
5,
|
|
543
|
+
6,
|
|
544
|
+
7,
|
|
545
|
+
8,
|
|
546
|
+
9,
|
|
547
|
+
10,
|
|
548
|
+
11,
|
|
549
|
+
12,
|
|
550
|
+
13,
|
|
551
|
+
14,
|
|
552
|
+
15
|
|
553
|
+
],
|
|
554
|
+
"type": "integer"
|
|
555
|
+
},
|
|
556
|
+
"model": {
|
|
557
|
+
"required": true
|
|
558
|
+
},
|
|
559
|
+
"output_resolution": {
|
|
560
|
+
"enum": [
|
|
561
|
+
"720p",
|
|
562
|
+
"1080p",
|
|
563
|
+
"4k"
|
|
564
|
+
]
|
|
565
|
+
},
|
|
566
|
+
"prompt": {
|
|
567
|
+
"required": true,
|
|
568
|
+
"min": 1,
|
|
569
|
+
"max": 2500,
|
|
570
|
+
"length": true
|
|
571
|
+
}
|
|
572
|
+
},
|
|
361
573
|
"kling-v3-turbo-text-to-video": {
|
|
362
574
|
"aspect_ratio": {
|
|
363
575
|
"enum": [
|
|
@@ -402,6 +614,43 @@ var contract = {
|
|
|
402
614
|
}
|
|
403
615
|
},
|
|
404
616
|
"rules": [
|
|
617
|
+
{
|
|
618
|
+
"when": {
|
|
619
|
+
"model": "kling-v2.5-turbo-text-to-video-pro"
|
|
620
|
+
},
|
|
621
|
+
"forbidden": [
|
|
622
|
+
"mode"
|
|
623
|
+
]
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"when": {
|
|
627
|
+
"model": "kling-v2.6"
|
|
628
|
+
},
|
|
629
|
+
"forbidden": [
|
|
630
|
+
"output_resolution",
|
|
631
|
+
"negative_prompt",
|
|
632
|
+
"cfg_scale",
|
|
633
|
+
"multi_shots",
|
|
634
|
+
"multi_prompt",
|
|
635
|
+
"first_frame_image_url",
|
|
636
|
+
"last_frame_image_url",
|
|
637
|
+
"kling_elements"
|
|
638
|
+
]
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
"when": {
|
|
642
|
+
"model": "kling-v3-omni"
|
|
643
|
+
},
|
|
644
|
+
"forbidden": [
|
|
645
|
+
"negative_prompt",
|
|
646
|
+
"cfg_scale",
|
|
647
|
+
"multi_shots",
|
|
648
|
+
"multi_prompt",
|
|
649
|
+
"first_frame_image_url",
|
|
650
|
+
"last_frame_image_url",
|
|
651
|
+
"kling_elements"
|
|
652
|
+
]
|
|
653
|
+
},
|
|
405
654
|
{
|
|
406
655
|
"when": {
|
|
407
656
|
"model": "kling-v3-turbo-text-to-video"
|
|
@@ -423,6 +672,7 @@ var contract = {
|
|
|
423
672
|
|
|
424
673
|
// src/resources/text-to-video.ts
|
|
425
674
|
var ENDPOINT = "/api/v1/kling/text_to_video";
|
|
675
|
+
var V26_MODEL = "kling-v2.6";
|
|
426
676
|
var V3_TURBO_MODEL = "kling-v3-turbo-text-to-video";
|
|
427
677
|
var V3_TURBO_UNSUPPORTED_FIELDS = [
|
|
428
678
|
"enable_sound",
|
|
@@ -463,6 +713,7 @@ var TextToVideo = class {
|
|
|
463
713
|
const body = compactParams(params);
|
|
464
714
|
rejectUnsupportedV3TurboFields(body);
|
|
465
715
|
validateParams(contract["text-to-video"], body);
|
|
716
|
+
validateV26Params(body);
|
|
466
717
|
return this.http.request("POST", ENDPOINT, {
|
|
467
718
|
body,
|
|
468
719
|
...options
|
|
@@ -480,6 +731,12 @@ var TextToVideo = class {
|
|
|
480
731
|
});
|
|
481
732
|
}
|
|
482
733
|
};
|
|
734
|
+
function validateV26Params(body) {
|
|
735
|
+
if (body.model !== V26_MODEL) return;
|
|
736
|
+
if (body.enable_sound === true && body.mode !== "pro") {
|
|
737
|
+
throw new ValidationError(`enable_sound requires mode pro for ${V26_MODEL}`);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
483
740
|
function rejectUnsupportedV3TurboFields(body) {
|
|
484
741
|
if (body.model !== V3_TURBO_MODEL) return;
|
|
485
742
|
const field = V3_TURBO_UNSUPPORTED_FIELDS.find((candidate) => fieldPresent(body, candidate));
|
|
@@ -507,6 +764,8 @@ function presentValue(value) {
|
|
|
507
764
|
import { ValidationError as ValidationError2, compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
|
|
508
765
|
import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
|
|
509
766
|
var ENDPOINT2 = "/api/v1/kling/image_to_video";
|
|
767
|
+
var V26_MODEL2 = "kling-v2.6";
|
|
768
|
+
var V3_OMNI_MODEL = "kling-v3-omni";
|
|
510
769
|
var V3_TURBO_MODEL2 = "kling-v3-turbo-image-to-video";
|
|
511
770
|
var V3_TURBO_UNSUPPORTED_FIELDS2 = [
|
|
512
771
|
"aspect_ratio",
|
|
@@ -543,6 +802,8 @@ var ImageToVideo = class {
|
|
|
543
802
|
const body = compactParams2(params);
|
|
544
803
|
rejectUnsupportedV3TurboFields2(body);
|
|
545
804
|
validateParams2(contract["image-to-video"], body);
|
|
805
|
+
validateV26Params2(body);
|
|
806
|
+
validateV3OmniFields(body);
|
|
546
807
|
return this.http.request("POST", ENDPOINT2, {
|
|
547
808
|
body,
|
|
548
809
|
...options
|
|
@@ -560,6 +821,25 @@ var ImageToVideo = class {
|
|
|
560
821
|
});
|
|
561
822
|
}
|
|
562
823
|
};
|
|
824
|
+
function validateV26Params2(body) {
|
|
825
|
+
if (body.model !== V26_MODEL2) return;
|
|
826
|
+
if (body.enable_sound === true && body.mode !== "pro") {
|
|
827
|
+
throw new ValidationError2(`enable_sound requires mode pro for ${V26_MODEL2}`);
|
|
828
|
+
}
|
|
829
|
+
if (!fieldPresent2(body, "last_frame_image_url")) return;
|
|
830
|
+
if (body.mode !== "pro") {
|
|
831
|
+
throw new ValidationError2(`last_frame_image_url requires mode pro for ${V26_MODEL2}`);
|
|
832
|
+
}
|
|
833
|
+
if (body.duration_seconds !== void 0 && body.duration_seconds !== 5) {
|
|
834
|
+
throw new ValidationError2(`last_frame_image_url requires duration_seconds 5 for ${V26_MODEL2}`);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
function validateV3OmniFields(body) {
|
|
838
|
+
if (body.model !== V3_OMNI_MODEL || !fieldPresent2(body, "last_frame_image_url")) return;
|
|
839
|
+
if ((body.duration_seconds ?? 5) !== 5) {
|
|
840
|
+
throw new ValidationError2(`last_frame_image_url requires duration_seconds 5 for ${V3_OMNI_MODEL}`);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
563
843
|
function rejectUnsupportedV3TurboFields2(body) {
|
|
564
844
|
if (body.model !== V3_TURBO_MODEL2) return;
|
|
565
845
|
const field = V3_TURBO_UNSUPPORTED_FIELDS2.find((candidate) => fieldPresent2(body, candidate));
|
|
@@ -683,6 +963,32 @@ var MotionControl = class {
|
|
|
683
963
|
}
|
|
684
964
|
};
|
|
685
965
|
|
|
966
|
+
// src/resources/extend-video.ts
|
|
967
|
+
import { compactParams as compactParams5, validateParams as validateParams5 } from "@runapi.ai/core";
|
|
968
|
+
import { pollUntilComplete as pollUntilComplete5 } from "@runapi.ai/core/internal";
|
|
969
|
+
var ENDPOINT5 = "/api/v1/kling/extend_video";
|
|
970
|
+
var ExtendVideo = class {
|
|
971
|
+
constructor(http) {
|
|
972
|
+
this.http = http;
|
|
973
|
+
}
|
|
974
|
+
http;
|
|
975
|
+
async run(params, options) {
|
|
976
|
+
const { id } = await this.create(params, options);
|
|
977
|
+
return pollUntilComplete5(() => this.get(id, options), {
|
|
978
|
+
maxWaitMs: options?.maxWaitMs,
|
|
979
|
+
pollIntervalMs: options?.pollIntervalMs
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
async create(params, options) {
|
|
983
|
+
const body = compactParams5(params);
|
|
984
|
+
validateParams5(contract["extend-video"], body);
|
|
985
|
+
return this.http.request("POST", ENDPOINT5, { body, ...options });
|
|
986
|
+
}
|
|
987
|
+
async get(id, options) {
|
|
988
|
+
return this.http.request("GET", `${ENDPOINT5}/${id}`, { ...options });
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
|
|
686
992
|
// src/client.ts
|
|
687
993
|
var KlingClient = class extends BaseClient {
|
|
688
994
|
/** Text-to-video generation with multi-shot, sound, and Kling elements support on kling-3.0. */
|
|
@@ -693,12 +999,14 @@ var KlingClient = class extends BaseClient {
|
|
|
693
999
|
aiAvatar;
|
|
694
1000
|
/** Transfer motion from a reference video onto a subject image. */
|
|
695
1001
|
motionControl;
|
|
1002
|
+
extendVideo;
|
|
696
1003
|
constructor(options = {}) {
|
|
697
1004
|
super(options);
|
|
698
1005
|
this.textToVideo = new TextToVideo(this.http);
|
|
699
1006
|
this.imageToVideo = new ImageToVideo(this.http);
|
|
700
1007
|
this.aiAvatar = new AiAvatar(this.http);
|
|
701
1008
|
this.motionControl = new MotionControl(this.http);
|
|
1009
|
+
this.extendVideo = new ExtendVideo(this.http);
|
|
702
1010
|
}
|
|
703
1011
|
};
|
|
704
1012
|
|