Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Integrating Kling Video Generation Through a Gateway: My 2026 Implementation Notes

Description and use

Automated integration of Kling video generation via CometAPI: from model verification to asynchronous job polling and result storage.

Problem

Integrating Kling video generation into an application while managing authentication, workflow selection, and asynchronous job handling.

Outcome

Implemented a robust, credential‑secure pipeline that submits Kling video jobs, polls asynchronously, and stores results, enabling easy comparison of model modes and durations.

Workflow

  • 1. Verify model availability and region eligibility via CometAPI catalog.
  • 2. Create a CometAPI key in the console and store it as COMETAPI_KEY server‑side.
  • 3. Decide persistence strategy for job records, task IDs, and video URLs.
  • 4. Submit a text‑to‑video job using the /kling/v1/videos/text2video endpoint with required JSON body.
  • 5. Immediately store the returned task_id and mark the job as pending.
  • 6. Poll the /kling/v1/videos/text2video/{task_id} endpoint until the task reaches a terminal state.
  • 7. On success, retrieve the video URL from the task object and store it in application storage.
  • 8. Optionally compare std vs pro modes by repeating steps 4‑7 with different mode values.
  • 9. Handle errors and non‑terminal states gracefully, retrying or aborting as needed.
  • 10. Clean up expired tasks and manage rate limits per CometAPI documentation.

Evidence

Confirm that the required model is available to your account and region.

Source

Create a key in the console and store it server‑side as COMETAPI_KEY.

Source

A successful submission includes data.task_id and a task status.

Source

  • Record date: 2026-09-21T14:45:33.693Z