@runapi.ai/kling 0.2.7 → 0.2.9

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/resources/text-to-video.ts","../src/resources/image-to-video.ts","../src/resources/ai-avatar.ts","../src/resources/motion-control.ts","../src/index.ts"],"sourcesContent":["import { createHttpClient, 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/** Kling video API client. */\nexport class KlingClient {\n /** Text-to-video operations. */\n public readonly textToVideo: TextToVideo;\n /** Image-to-video operations. */\n public readonly imageToVideo: ImageToVideo;\n /** AI avatar operations. */\n public readonly aiAvatar: AiAvatar;\n /** Motion control operations. */\n public readonly motionControl: MotionControl;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToVideo = new TextToVideo(http);\n this.imageToVideo = new ImageToVideo(http);\n this.aiAvatar = new AiAvatar(http);\n this.motionControl = new MotionControl(http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedTextToVideoResponse,\n TextToVideoParams,\n TextToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/text_to_video';\n\nexport class TextToVideo {\n constructor(private readonly http: HttpClient) {}\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 async create(params: TextToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\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","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedImageToVideoResponse,\n ImageToVideoParams,\n ImageToVideoResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/image_to_video';\n\nexport class ImageToVideo {\n constructor(private readonly http: HttpClient) {}\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 async create(params: ImageToVideoParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\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","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedAiAvatarResponse,\n AiAvatarParams,\n AiAvatarResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/ai_avatar';\n\nexport class AiAvatar {\n constructor(private readonly http: HttpClient) {}\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 async create(params: AiAvatarParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\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 } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedMotionControlResponse,\n MotionControlParams,\n MotionControlResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/kling/motion_control';\n\nexport class MotionControl {\n constructor(private readonly http: HttpClient) {}\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 async create(params: MotionControlParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\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","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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,EAE7B,MAAM,IAAI,QAA6B,SAAoF;AACzH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAMD,mBAAyC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MAC3F,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA6B,SAAuD;AAC/F,WAAO,KAAK,KAAK,QAA4B,QAAQC,WAAU;AAAA,MAC7D,MAAMF,eAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAA0D;AAC9E,WAAO,KAAK,KAAK,QAA+B,OAAO,GAAGE,SAAQ,IAAI,EAAE,IAAI;AAAA,MAC1E,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AJ7BO,IAAM,cAAN,MAAkB;AAAA;AAAA,EAEP;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO,iBAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,eAAe,IAAI,aAAa,IAAI;AACzC,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,gBAAgB,IAAI,cAAc,IAAI;AAAA,EAC7C;AACF;;;AKrBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","pollUntilComplete","ENDPOINT","compactParams","pollUntilComplete","ENDPOINT","compactParams","pollUntilComplete","ENDPOINT"]}
1
+ {"version":3,"sources":["../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/index.ts"],"sourcesContent":["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","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"],"mappings":";AAAA,SAAS,kBAAsC;;;ACC/C,SAAS,iBAAiB,eAAe,sBAAsB;AAC/D,SAAS,yBAAyB;;;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;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CO,IAAM,cAAN,cAA0B,WAAW;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;;;AMjCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAAI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["ValidationError","compactParams","validateParams","pollUntilComplete","ENDPOINT","V3_TURBO_MODEL","V3_TURBO_UNSUPPORTED_FIELDS","pollUntilComplete","compactParams","rejectUnsupportedV3TurboFields","validateParams","fieldPresent","ValidationError","presentValue","compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams","compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams","ValidationError"]}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@runapi.ai/kling",
3
- "version": "0.2.7",
4
- "description": "RunAPI Kling SDK for JavaScript, Ruby, and Go",
3
+ "runapi": {
4
+ "slug": "kling"
5
+ },
6
+ "version": "0.2.9",
7
+ "description": "RunAPI Kling SDK for text-to-video, image-to-video, avatar, and motion-control workflows in JavaScript, Python, Ruby, Go, Java, and PHP",
5
8
  "main": "./dist/index.js",
6
9
  "module": "./dist/index.mjs",
7
10
  "types": "./dist/index.d.ts",
@@ -28,7 +31,7 @@
28
31
  "clean": "rm -rf dist"
29
32
  },
30
33
  "dependencies": {
31
- "@runapi.ai/core": "^0.2.5"
34
+ "@runapi.ai/core": "^0.2.11"
32
35
  },
33
36
  "devDependencies": {
34
37
  "@types/node": "^20.0.0",
@@ -49,8 +52,16 @@
49
52
  "api",
50
53
  "sdk",
51
54
  "typescript",
55
+ "python",
52
56
  "ruby",
53
- "golang"
57
+ "golang",
58
+ "java",
59
+ "maven",
60
+ "gradle",
61
+ "video-generation",
62
+ "text-to-video",
63
+ "video-api",
64
+ "kling-ai-api"
54
65
  ],
55
66
  "author": "RunAPI",
56
67
  "license": "Apache-2.0",
@@ -58,5 +69,8 @@
58
69
  "repository": {
59
70
  "type": "git",
60
71
  "url": "git+https://github.com/runapi-ai/kling-sdk.git"
72
+ },
73
+ "bugs": {
74
+ "url": "https://github.com/runapi-ai/kling-sdk/issues"
61
75
  }
62
76
  }
@@ -71,6 +71,8 @@ const url = result.videos[0].url;
71
71
  ## Variants
72
72
 
73
73
  - [Kling 3.0](https://runapi.ai/models/kling/3.0)
74
+ - [V3 Turbo text to video](https://runapi.ai/models/kling/v3-turbo-text-to-video)
75
+ - [V3 Turbo image to video](https://runapi.ai/models/kling/v3-turbo-image-to-video)
74
76
  - [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro)
75
77
  - [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard)
76
78
  - [AI avatar v1 pro](https://runapi.ai/models/kling/ai-avatar-v1-pro)
@@ -84,9 +86,11 @@ const url = result.videos[0].url;
84
86
 
85
87
  ## Agent rules
86
88
 
89
+ - Integration work uses the target language SDK; one-off generation, manual smoke tests, debugging, or user-requested CLI runs use the RunAPI CLI skill: https://github.com/runapi-ai/cli-skill
90
+ - RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
87
91
  - Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
88
92
  - Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
89
- - For kling ai api pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
93
+ - For pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
90
94
 
91
95
  ## License
92
96
 
@@ -25,14 +25,24 @@ metadata:
25
25
 
26
26
  Generate and edit video with Kling through RunAPI. The default path for one-off agent tasks is the `runapi` CLI; SDKs are for application integration.
27
27
 
28
- ## Routing decision
28
+ ## Critical: Integration Runtime
29
29
 
30
- - One-off generation, editing, or transformation for the user → use the **CLI path** with the `runapi` binary.
31
- - Building an app, backend, worker, library, or production codebase → use the **SDK integration path**.
30
+ - Integration work (app, backend, worker, library, Rails service, Node service, Go service, webhook pipeline, or production codebase) uses the **SDK integration path** for the target language.
31
+ - One-off generation, editing, transformation, manual smoke tests, debugging, or user-requested CLI runs use the **CLI path** with the `runapi` binary. For full CLI-specific agent guidance, see https://github.com/runapi-ai/cli-skill.
32
+ - Never shell out to the `runapi` CLI as the production runtime integration layer.
33
+
34
+ ## SDK integration path
35
+
36
+ When integrating Kling into an app, backend, worker, library, Rails service, Node service, Go service, webhook pipeline, or production workflow, start by checking the current SDK package and official usage. Confirm install commands, client methods (`create`, `get`, `run`), request fields, response shape, and error classes before using CLI help or raw HTTP examples. Use a RunAPI SDK package:
37
+
38
+ - JavaScript / TypeScript: `@runapi.ai/kling`
39
+ - PHP: `runapi-ai/kling`
40
+ - Ruby: `runapi-kling`
41
+ - Go: `github.com/runapi-ai/kling-sdk/go`
32
42
 
33
43
  ## CLI path
34
44
 
35
- The `runapi` binary is the runtime dependency. Run `runapi auth status` first. For agents and headless runs, prefer `RUNAPI_API_KEY` or import it into saved config with `printf '%s' "$RUNAPI_API_KEY" | runapi auth import-token --token -`. Use `runapi login` only when the user explicitly wants interactive browser auth.
45
+ The `runapi` binary is the one-off and manual testing runtime dependency. For full CLI-specific agent guidance, see https://github.com/runapi-ai/cli-skill. Run `runapi auth status` first. For agents and headless runs, prefer `RUNAPI_API_KEY` or import it into saved config with `printf '%s' "$RUNAPI_API_KEY" | runapi auth import-token --token -`. Use `runapi login` only when the user explicitly wants interactive browser auth.
36
46
 
37
47
  Inspect the available commands and request fields with CLI help:
38
48
 
@@ -57,14 +67,12 @@ runapi wait <task-id> --service kling --action text-to-video
57
67
  Available commands: `text-to-video`, `avatar`, `image-to-video`, `motion-control`.
58
68
 
59
69
  For Kling 3.0 text-to-video requests, keep `model: "kling-3.0"` and choose `output_resolution: "720p"`, `"1080p"`, or `"4k"` as needed.
70
+ For V3 Turbo text-to-video requests, use `model: "kling-v3-turbo-text-to-video"` with `output_resolution: "720p"` or `"1080p"`.
71
+ For V3 Turbo image-to-video requests, use `model: "kling-v3-turbo-image-to-video"` and provide `first_frame_image_url`.
60
72
 
61
- ## SDK integration path
62
-
63
- When integrating Kling into an app, backend, worker, or library — not for one-off tasks — use a RunAPI SDK package:
73
+ ## Generated file storage
64
74
 
65
- - JavaScript / TypeScript: `@runapi.ai/kling`
66
- - Ruby: `runapi-kling`
67
- - Go: `github.com/runapi-ai/kling-sdk/go`
75
+ RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
68
76
 
69
77
  ## References
70
78
 
@@ -75,6 +83,8 @@ When integrating Kling into an app, backend, worker, or library — not for one-
75
83
  ## Variants
76
84
 
77
85
  - [Kling 3.0](https://runapi.ai/models/kling/3.0.md)
86
+ - [V3 Turbo text to video](https://runapi.ai/models/kling/v3-turbo-text-to-video.md)
87
+ - [V3 Turbo image to video](https://runapi.ai/models/kling/v3-turbo-image-to-video.md)
78
88
  - [AI avatar pro](https://runapi.ai/models/kling/ai-avatar-pro.md)
79
89
  - [AI avatar standard](https://runapi.ai/models/kling/ai-avatar-standard.md)
80
90
  - [AI avatar v1 pro](https://runapi.ai/models/kling/ai-avatar-v1-pro.md)