
Kling Official Direct API
FreeIntegrate OpenMontage with Kling's official tools.
Free · Opens the source repo
What Kling Official Direct API does
The Kling Official Direct API skill provides developers with the necessary instructions to utilize Kling's official endpoints within OpenMontage. This skill is essential for those looking to implement video, image, text-to-speech, avatar, and lip-sync functionalities using the Kling API. It guides users on how to authenticate requests and manage task protocols effectively, ensuring seamless integration into their applications.
Using this skill, developers can specify the provider as kling_official to access the official API functionalities. It is crucial to understand the distinction between using the official Kling API and the fal.ai gateway, as the two operate under different authentication and task management protocols. The skill emphasizes the importance of maintaining clear boundaries between these providers to avoid confusion and ensure proper functionality.
The skill also details the required parameters for various tasks, including video generation, image processing, text-to-speech, avatar creation, and lip-syncing. Each task type has specific requirements for input, such as the need for valid URLs, JSON structures, and specific API family designations. This level of detail helps developers avoid common pitfalls when integrating with the Kling API, making the process more efficient and reliable.
Overall, this skill is designed for developers and designers who are working with OpenMontage and require access to Kling's advanced capabilities. It serves as a comprehensive guide for implementing these features while adhering to the necessary protocols and requirements.
When to use it
Use this skill when you need to integrate Kling's official API functionalities into your OpenMontage projects.
When not to use it
Avoid this skill if you are not using OpenMontage or if you require features from the fal.ai gateway instead.
What you can build with it
Integrating Video Generation
Developers can use this skill to integrate Kling's video generation capabilities into their OpenMontage applications, following the specified task protocols.
Implementing Text-to-Speech Features
This skill allows designers to add text-to-speech functionalities using Kling's official endpoints, ensuring proper authentication and parameter usage.
Creating Custom Avatars
With this skill, users can create custom avatars for their projects by following the outlined parameters for avatar generation and lip-syncing.
How to install Kling Official Direct API
View source1. Install with the skills CLI
npx skills add calesthio/openmontage/kling-official --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by calesthioKling Official Direct API
Use this skill for OpenMontage tools with provider="kling_official". This is not the fal.ai Kling gateway. Official Kling uses KLING_API_KEY, optional KLING_API_BASE_URL, and Authorization: Bearer <KLING_API_KEY>.
Provider Split
kling_videouses fal.ai,FAL_KEY, fal.ai queue URLs, andprovider="kling".kling_official_videouses Kling official API,KLING_API_KEY, official task protocols, andprovider="kling_official".kling_official_imageuses the same official auth and task protocol for image generation.kling_ttsuses the official audio TTS endpoint and stays in the existingttscapability.kling_avatarandkling_lip_syncuse official avatar/lip-sync endpoints and stay in the existingavatarcapability. They do not replace localtalking_headorlip_sync.
Never silently switch between these paths. If the selected provider is unavailable, surface the blocker and ask before substituting.
Auth And Endpoint
Default base URL:
https://api-singapore.klingai.com
Users may override it with KLING_API_BASE_URL, for example for a regional endpoint. All requests send JSON and:
Authorization: Bearer <KLING_API_KEY>
Task Protocols
Classic APIs:
- Create ID path:
data.task_id - Statuses:
submitted,processing,succeed,failed - Result paths:
data.task_result.videos[],data.task_result.images[],data.task_result.audios[]
Turbo APIs:
- Create ID path:
data.id - Poll path:
GET /tasks?task_ids=<id> - Statuses:
submitted,processing,succeeded,failed - Result path:
data[0].outputs[]
Keep the parsers separate. Do not write a fuzzy parser that guesses between task_id and id or between succeed and succeeded.
Omni References
Video Omni and Image Omni stay inside the existing provider tools through api_family="omni".
Do not create selector-level Omni operations.
Video Omni accepts official reference structures:
image_list[]withimage_urland optionaltypesuch asfirst_frameorend_frame.video_list[]withvideo_url, officialrefer_typevalues such asfeatureorbase, and optionalkeep_original_sound.element_list[]with officialelement_idvalues.- Structured
multi_prompt[]; do not split natural language into shots automatically.
Local image references may be normalized through tools/_kling/media.py. Local video paths must not be silently uploaded through fal.ai; ask for or require a reachable URL.
Image Omni accepts image_list[] with official image values. Prompt placeholders such as <<<image_1>>> must map stably to the provided image order. If the prompt already contains placeholders, validate that the referenced images exist and do not insert duplicates.
Capability Boundaries
TTS, avatar, and lip sync are provider additions to existing OpenMontage capabilities. Audio effects and video effects are official Kling endpoints, but they are not registered as default OpenMontage tools until a pipeline has a stable capability slot for them.
- Do not add
sound_effectsorvideo_effectscapabilities from inside a provider implementation. - Do not let video effects enter the ordinary
video_generationselector path. - Do not disguise short sound effects as long background music unless a pipeline explicitly consumes that shape and the tool's
best_for/not_good_forsays so.
Video Parameters
Use operation for OpenMontage semantics:
text_to_videoimage_to_videoreference_to_video
Use api_family for official protocol choice:
classicturboomni
Important constraints:
- Official video provider input schema must not expose top-level
image_url; usereference_image_urlorreference_image_path. - Classic image-to-video accepts
reference_image_urlor a local path converted to raw base64 in official fieldimage. - Turbo image-to-video requires a URL first frame. Do not upload local files through fal.ai as a fallback.
- Send
aspect_ratioonly where the current schema supports it: Classic text-to-video, Turbo text-to-video, and Video Omni. - Default paid path should avoid
4k, native sound, or batch behavior unless explicitly selected.
Image Parameters
Use api_family="generation" for /v1/images/generations and api_family="omni" for /v1/images/omni-image.
Generation/edit path:
promptis required and should stay under the official 2500 character limit.image_urlpasses through as officialimage.image_pathis converted to raw base64 and sent as officialimage.image_referencecan besubjectorface.
Omni path:
- Put references in
image_list[]using officialimagevalues. - Use prompt placeholders such as
<<<image_1>>>only when the prompt needs to bind a specific reference image.
TTS Parameters
kling_tts uses:
textvoice_idvoice_language, currentlyzhorenvoice_speed
Require an explicit voice_id unless an official account-specific default has been verified. Do not hard-code a made-up voice. Download every returned audio item, set data.output_path to the first local file, and include voice_id, voice_language, voice_speed, task_id, and non-zero cost_usd.
Avatar Parameters
kling_avatar uses /v1/videos/avatar/image2video and accepts:
- avatar image via URL or local path converted to raw base64
audio_idorsound_file- optional
prompt mode, such asstdorpro
Keep it separate from local talking_head. Pipelines that want Kling avatar output must list and choose it explicitly.
Lip Sync Parameters
kling_lip_sync has two steps:
POST /v1/videos/identify-facewithvideo_idorvideo_url; read faces fromdata.face_data[]POST /v1/videos/advanced-lip-syncwithsession_idand oneface_choose[]item containingface_id,audio_idorsound_file, and the sound start/end/insert times
Local video paths must not be silently uploaded through fal.ai or any other provider. If multiple faces are returned and the user did not pass face_id or face_choose, stop and return the face list for confirmation unless auto_select_face=True was explicitly set. If auto-selecting, record the selection reason and selected face in the result/artifact.
Audio Effects And Video Effects
Official Kling audio effects (/v1/audio/text-to-audio, /v1/audio/video-to-audio) and video effects (/v1/videos/effects) are intentionally not default OpenMontage selector tools. Record the non-mapping reason in docs/tests instead of registering tools that current pipelines might misuse.
Elements Helper
Elements are an internal Kling Official helper, not a new OpenMontage tool capability.
Use tools/_kling/elements.py to normalize element_list[].element_id, optionally query read-only element endpoints, and record element metadata when queried. Do not create or delete elements from the default provider path.
Account Usage Helper
Account Usage is diagnostic only. Use tools/_kling/account.py for low-frequency /account/costs checks, with local cache and throttle protection. Do not call it before every generation and do not put it in selectors or production pipeline stages.
For 1101 or 1102, surface that the account or resource pack is exhausted and include an account-usage diagnostic hint.
Callback Notes
Providers may accept callback_url, but polling remains the default execution mode.
- Classic and Omni paths pass
callback_urlat the top level. - Turbo paths pass it as
options.callback_url. - Successful results should record
callback_requested=true,polling_used=true, thecallback_url, andtask_id. - Validate callback URLs before sending; only absolute
httporhttpsURLs should pass.
Error Handling
Surface official code, message, and request_id whenever available.
Do not retry:
- Auth failures:
1000-1004 - Balance/resource-pack exhaustion:
1101,1102 - Permission/model access:
1103 - Parameter errors:
1200,1201 - Safety policy:
1301
Limited retry is acceptable for:
1302request too fast1303concurrency/resource-pack slot limit5000,5001,5002server/maintenance/backlog errors
For 1303, explain that the account hit a concurrency or resource-pack slot limit.
Cost Governance
Official Kling is a paid remote API. Provider tools must return non-zero conservative estimates from estimate_cost() and include cost_usd on successful paid results. Treat estimates as low-confidence until account usage reconciliation is implemented.
High-cost Omni inputs such as multiple references, element IDs, result_type="series", mode="4k", and sound="on" must increase or flag the cost estimate.
Prompt Notes
For video, start from the universal OpenMontage video prompt skeleton: subject, subject motion, scene, spatial framing, and camera. Kling tends to respond well to clear temporal action order, camera movement verbs, and concise negative prompts. For reference workflows, state what should stay consistent from the reference and what should change.
Frequently asked questions about Kling Official Direct API
Similar skills
WinMD API Search
Easily find and explore Windows desktop APIs.
WebMCPify
Transform any web app into an agent-ready platform.
Phoenix Tracing
Instrument LLM applications with OpenInference tracing.
Foundry Hosted Agent CopilotKit
Guidance for developing agentic web apps on Azure.
Power Automate Foundation
Connect AI agents to Power Automate seamlessly.
Power Automate Flow Builder
Efficiently build and deploy Power Automate flows programmatically.
