Create your API key
Sign up and grab an API key from the PiAPI workspace — free credits are included on sign-up.
Kling 2.0 Master brings text-to-video and image-to-video generation to PiAPI.
Sign up and grab an API key from the PiAPI workspace — free credits are included on sign-up.
Add credits on the billing page when you are ready to scale beyond the free tier.
POST your first task following the API docs, then poll the task until the result is ready.
Prototype prompts and settings in the the playground above before wiring them into your product.
curl -X POST 'https://api.piapi.ai/api/v1/task' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "kling",
"task_type": "video_generation",
"input": {
"version": "2.0",
"mode": "std",
"duration": 5,
"aspect_ratio": "16:9",
"prompt": "A cinematic shot of a futuristic city at sunset."
}
}'
# → { "task_id": "9d5a…", "status": "pending" }curl 'https://api.piapi.ai/api/v1/task/{task_id}' \
-H 'X-API-Key: YOUR_API_KEY'
# poll until status = completed
{
"data": {
"status": "completed",
"output": {
"video_url": "https://img.theapi.app/ephemeral/…"
}
}
}$ npm install -g piapi-cli $ piapi run kling-api-v2 \ version=2.0 \ mode=std \ duration=5 \ aspect_ratio=16:9 \ prompt="A cinematic shot of a futuristic city at sunset." ✓ Task completed! https://img.theapi.app/ephemeral/…