| name | klingai-storage-integration |
| description | Download and store Kling AI generated videos in cloud storage (S3, GCS, Azure). Use when
persisting videos or building CDN pipelines. Trigger with phrases like 'klingai storage',
'save klingai video', 'kling ai s3 upload', 'klingai cloud storage'.
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Grep |
| version | 1.18.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","kling-ai","storage","s3","gcs"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Kling AI Storage Integration
Overview
Kling AI video URLs from task_result.videos[].url are temporary CDN links that expire. You must download and store videos in your own storage. This skill covers S3, GCS, and Azure Blob.
Download from Kling CDN
import requests
import os
def download_video(video_url: str, output_dir: str = "output") -> str:
"""Download generated video from Kling CDN."""
os.makedirs(output_dir, exist_ok=True)
filename = video_url.split("/")[-1].split("?")[0]
if not filename.endswith(".mp4"):
filename = f"kling_{int(time.time())}.mp4"
filepath = os.path.join(output_dir, filename)
response = requests.get(video_url, stream=True, timeout=120)
response.raise_for_status()
with open(filepath, "wb") as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
size_mb = os.path.getsize(filepath) / (1024 * 1024)
print(f"Downloaded: {filepath} ({size_mb:.1f} MB)")
return filepath
Upload to AWS S3
import boto3
() -> :
s3 = boto3.client()
filename = os.path.basename(filepath)
s3_key =
s3.upload_file(
filepath, bucket, s3_key,
ExtraArgs={: , : }
)
url =
()
url
() -> :
s3 = boto3.client()
s3.generate_presigned_url(
,
Params={: bucket, : key},
ExpiresIn=expiry,
)