| name | klingai-hello-world |
| description | Create your first Kling AI video generation with a minimal working example. Use when learning
Kling AI or testing your setup. Trigger with phrases like 'kling ai hello world', 'first kling video',
'klingai quickstart', 'test klingai'.
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Grep |
| version | 1.18.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","kling-ai","quickstart"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Kling AI Hello World
Overview
Generate your first AI video in under 20 lines of code. This skill walks through the complete create-poll-download cycle using the Kling AI REST API.
Base URL: https://api.klingai.com/v1
Prerequisites
- Completed
klingai-install-auth setup
- Python 3.8+ with
requests and PyJWT
- At least 10 credits in your Kling AI account
Minimal Example — Python
import jwt, time, os, requests
def get_token():
ak = os.environ["KLING_ACCESS_KEY"]
sk = os.environ["KLING_SECRET_KEY"]
payload = {"iss": ak, "exp": int(time.time()) + 1800, "nbf": int(time.time()) - 5}
return jwt.encode(payload, sk, algorithm="HS256",
headers={"alg": "HS256", "typ": "JWT"})
BASE = "https://api.klingai.com/v1"
HEADERS = {"Authorization": f"Bearer {get_token()}", "Content-Type": "application/json"}
task = requests.post(f"{BASE}/videos/text2video", headers=HEADERS, json={
"model_name": "kling-v2-master",
"prompt": "A golden retriever running through autumn leaves in slow motion, cinematic lighting",
"duration": "5",
"aspect_ratio": ,
: ,
}).json()
task_id = task[][]
()
time t
:
t.sleep()
status = requests.get(, headers=HEADERS).json()
state = status[][]
()
state == :
video_url = status[][][][][]
()
state == :
()